forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run ruff as an external tool, not via Python/PEX (pantsbuild#21237)
This switches the Ruff subsystem to download and run it via the artifacts published to GitHub releases. Ruff is published to PyPI and thus runnable as a PEX, which is what Pants currently does... but under the hood ruff is a single binary, and the PyPI package is for convenience. The package leads to a bit of extra overhead (e.g. have to build a `VenvPex` before being able to run it). It is also fiddly to change the version of a Python tool, requiring building a resolve and using `python_requirement`s. By downloading from GitHub releases, we can: - more easily support multiple ruff versions and allow users to pin to one/switch between them with a `version = "..."` (this PR demonstrates this, by including both 0.6.4 as in `main`, and 0.4.9 as in 2.23, i.e. if someone upgrades to 2.24 and wants to stick with 0.4.9, they can just add `version = "0.4.9"`, no need to fiddle with `known_versions`) - eliminate any Python/pex overhead by invoking the binary directly - side-step fiddle like interpreter constraints (pantsbuild#21235 (comment)) Potential issues: - If Ruff adds plugins via Python in future, maybe we will want it installed in a venv so that the venv can include those plugins... astral-sh/ruff#283 seems to be inconclusive about the direction, so I'm inclined to not worry and deal with it in future, if it happens. This PR does: - Switches the ruff subsystem to be a `TemplatedExternalTool` subclass, not `PythonToolBase` - Plumbs through the requisite changes, including: setting up some `default_known_versions` for the `main` and 2.23 versions (0.6.4 and 0.4.9 respectively), changing how the tool is installed, removing metadata about interpreter constraints that is no longer relveant or computable - Eases the upgrade by adding deprecated instances of the fields provided by `PythonToolBase`: people may've customised the Ruff version with `install_from_resolve`. If the field was just removed, running any pants command will fail on start-up with `Invalid option 'install_from_resolve' under [ruff] in path/to/pants.toml`, which isn't very helpful. By having the fields exist, we ensure the user gets a descriptive warning about what to do. NB. the backend is labelled experimental, so I haven't tried to preserve behaviour, just focused on ensuring we can show a removal error message to them.
- Loading branch information
Showing
12 changed files
with
122 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.