Skip to content

Commit

Permalink
Document the need for migrating tool to user lockfiles for export (Ch…
Browse files Browse the repository at this point in the history
…erry-pick of #20604) (#20615)

backports [here](pantsbuild/pantsbuild.org#157)

Co-authored-by: Daniel Goldman <[email protected]>
  • Loading branch information
WorkerPants and lilatomic authored Feb 26, 2024
1 parent 5eb4962 commit 863ca91
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/docs/python/overview/lockfiles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ It is strongly recommended that these tools be installed from a hermetic lockfil

The only time you need to think about this is if you want to customize the tool requirements that Pants uses. This might be the case if you want to modify the version of a tool or add extra requirements (for example, tool plugins).

:::caution Exporting tools requires a custom lockfile
:::

If you want a tool to be installed from some resolve, instead of from the built-in lockfile, you set `install_from_resolve` and `requirements` on the tool's config section:

```toml title="pants.toml"
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/using-pants/setting-up-an-ide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The `--py-resolve-format=symlinked_immutable_virtualenv` option symlinks to an i

### Tool virtualenvs

`pants export` can also create a virtualenv for each of the Python tools you use via Pants, such as `black`, `isort`, `pytest`, `mypy`, `flake8` and so on (you can run `/pants help tools` to get a list of the tools Pants uses). Use the tool name as the resolve name argument to the `--resolve` flag. This allows you to configure your editor to use the same version of the tool as Pants does for workflows like formatting on save.
`pants export` can also create a virtualenv for each of the Python tools you use via Pants, such as `black`, `isort`, `pytest`, `mypy`, `flake8` and so on. This allows you to configure your editor to use the same version of the tool as Pants does for workflows like formatting on save. Follow [the instructions for creating a tool lockfile](../../python/overview/lockfiles#lockfiles-for-tools).

## Generated code

Expand Down
11 changes: 10 additions & 1 deletion src/python/pants/core/goals/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from pants.option.option_types import StrListOption
from pants.util.dirutil import safe_rmtree
from pants.util.frozendict import FrozenDict
from pants.util.strutil import softwrap


class ExportError(Exception):
Expand Down Expand Up @@ -104,7 +105,15 @@ class ExportResults(Collection[ExportResult]):

class ExportSubsystem(GoalSubsystem):
name = "export"
help = "Export Pants data for use in other tools, such as IDEs."
help = softwrap(
"""
Export Pants data for use in other tools, such as IDEs.
:::caution Exporting tools requires creating a custom lockfile for them
Follow [the instructions for creating tool lockfiles](../../docs/python/overview/lockfiles#lockfiles-for-tools)
:::
"""
)

# NB: Only options that are relevant across many/most backends and languages
# should be defined here. Backend-specific options should be defined in that backend
Expand Down

0 comments on commit 863ca91

Please sign in to comment.