I am trying `pants.backend.python.providers.experi...
# general
f
I am trying
pants.backend.python.providers.experimental.pyenv
and I am wondering what the recommended way for specifying the exact Python version to install. It seems to take the
interpreter_constraints
in
pants.toml
into account, but only to pick e.g.
3.10
vs
3.11
, it always installs
3.10.10
even if I specify
3.10.14
. Also tried it with a
.python-version
file, same effect.
Copy code
# Caching the result is OK, since if the user really needs a different patch,
            # they should list a more precise IC.
https://github.com/pantsbuild/pants/blob/211f7e4eb289b28b8c4a9018abf8d98a088dd120/src/python/pants/backend/python/providers/pyenv/rules.py#L24[…]C50 I found this in this in the code but in my experiments this doesn’t work, the patch version specified in the IC does not get respected.
I think the issue is that this line only considers major/minor and does not return the patch version:
Copy code
python_to_use = request.interpreter_constraints.minimum_python_version(
        python_setup.interpreter_versions_universe
    )
https://github.com/pantsbuild/pants/blob/211f7e4eb289b28b8c4a9018abf8d98a088dd120/src/python/pants/backend/python/providers/pyenv/rules.py#L23[…]4C6 Should we be using something different here?
b
I think https://github.com/pantsbuild/pants/issues/19462 may have a fix for that, that could be ported across if you were looking to contribute. (Most welcome to!) (I’m on mobile so a bit brief, sorry)
👍 1
f
But turns out my problem above (where I want a newer version than what
pyenv latest --known
currently returns) has more to with the fact that the included version of
pyenv
is old and doesn’t know the patch version I want. (Fixed that by configuring
[pyenv-python-provider]
in
pants.toml
to use a newer
pyenv
.)
b
Thanks for taking the time to contribute! I'm a bit busy so cannot review just yet, but maybe someone else will.
Fixed that by configuring
[pyenv-python-provider]
in
pants.toml
to use a newer
pyenv
Ah, good catch. If you'd like to contribute a separate fix, bumping the version in https://github.com/huonw/pants/blob/cfb3cafcac2386c909bc4a3fee3997e1bd8b03d7/src/python/pants/backend/python/providers/pyenv/rules.py#L63-L100 would be awesome!
f