Skip to content

Commit 9f6e7cb

Browse files
Include <PYENV> in [python-setup].interpreter_search_paths default (#10998)
Pyenv interpreters are often very likely to work (compared to some system Pythons), so it's sensible to include in the default. If the user does not use Pyenv, the `<PYENV>` value will simply no-op. We keep `<PATH>` in the default so that it's more likely Pants works Out Of The Box for new users. [ci skip-rust] [ci skip-build-wheels]
1 parent 56b2562 commit 9f6e7cb

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/python/pants/python/python_setup.py

+17-10
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,19 @@ def register_options(cls, register):
8989
"--interpreter-search-paths",
9090
advanced=True,
9191
type=list,
92-
default=["<PEXRC>", "<PATH>"],
92+
default=["<PYENV>", "<PATH>"],
9393
metavar="<binary-paths>",
94-
help="A list of paths to search for python interpreters. The following special "
95-
"strings are supported: "
96-
'"<PATH>" (the contents of the PATH env var), '
97-
'"<PEXRC>" (paths in the PEX_PYTHON_PATH variable in a pexrc file), '
98-
'"<PYENV>" (all python versions under $(pyenv root)/versions).'
99-
'"<PYENV_LOCAL>" (the python version in BUILD_ROOT/.python-version).',
94+
help=(
95+
"A list of paths to search for Python interpreters that match your project's "
96+
"interpreter constraints. You can specify absolute paths to interpreter binaries "
97+
"and/or to directories containing interpreter binaries. The order of entries does "
98+
"not matter. The following special strings are supported:\n\n"
99+
'* "<PATH>", the contents of the PATH env var\n'
100+
'* "<PYENV>", all Python versions under $(pyenv root)/versions\n'
101+
'* "<PYENV_LOCAL>", the Pyenv interpreter with the version in '
102+
"BUILD_ROOT/.python-version\n"
103+
'* "<PEXRC>", paths in the PEX_PYTHON_PATH variable in /etc/pexrc or ~/.pexrc'
104+
),
100105
)
101106
register(
102107
"--resolver-manylinux",
@@ -257,15 +262,17 @@ def get_pyenv_paths(
257262
pyenv_root = pyenv_root_func()
258263
if pyenv_root is None:
259264
return []
265+
260266
versions_dir = Path(pyenv_root, "versions")
267+
if not versions_dir.is_dir():
268+
return []
261269

262270
if pyenv_local:
263-
264271
local_version_file = Path(get_buildroot(), ".python-version")
265272
if not local_version_file.exists():
266-
logger.info(
273+
logger.warning(
267274
"No `.python-version` file found in the build root, "
268-
"but <PYENV_LOCAL> was set in `--python-setup-interpreter-constraints`."
275+
"but <PYENV_LOCAL> was set in `[python-setup].interpreter_search_paths`."
269276
)
270277
return []
271278

0 commit comments

Comments
 (0)