Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the need for migrating tool to user lockfiles for export (Cherry-pick of #20604) #20615

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading