Unsure if this is expected behaviour or a bug. I’d...
# general
d
Unsure if this is expected behaviour or a bug. I’d like pants to be able to automatically manage python installations for me. I don’t have a compatible 3.11 interpreter on my system.
Copy code
[GLOBAL]
pants_version = "2.20.1"
backend_packages = [
  "pants.backend.python",
  "pants.backend.python.providers.experimental.pyenv",
]

[python]
interpreter_constraints = ['==3.11.*']
but if I do
pants run app.py
It will fetch a compatible interpreter for me and keep it in a virtualnev
Copy code
root@a2f5788007ff:/stuff# /root/.local/bin/pants run app.py
Bootstrapping Pants 2.20.1
Installing pantsbuild.pants==2.20.1 into a virtual environment at /root/.cache/nce/edc831b89dbe2507e3e6601f0222f6534ce454293e8ea4a079f14f5e8948dc1f/bindings/venvs/2.20.1
New virtual environment successfully created at /root/.cache/nce/edc831b89dbe2507e3e6601f0222f6534ce454293e8ea4a079f14f5e8948dc1f/bindings/venvs/2.20.1.
⠈ 4.57s Install Python 3.11
app.py
prints the interpreter version
Copy code
3.11.2 (main, May 17 2024, 16:32:11) [GCC 12.2.0]
/root/.cache/pants/named_caches/pex_root/venvs/s/39253589/venv/bin/python3.11
If I enable resolves and try to generate a lockfile I’d expect it to use this newly installed Python version
Copy code
[python]
interpreter_constraints = ['==3.11.*']
enable_resolves = true
Instead it breaks
Copy code
pants generate-lockfiles

When creating a universal lock with an --interpreter-constraint, an interpreter matching the constraint must be found on the local system but none was: Could not find a compatible interpreter.

No interpreters could be found on the system.
How is it
run
is able to find + install a correct interpreter for me, but
generate-lockfiles
can’t ?
b
Sorry for the trouble. I think this a bug: https://github.com/pantsbuild/pants/issues/20550 . I think
generate-lockfiles
is likely missing some code to hook into the interpreter that
run
finds. Are you interested in trying to fix it?
d
going to take a look into it yes, thanks for confirming