<#16566 pants export doesn't use proper Python ver...
# github-notifications
q
#16566 pants export doesn't use proper Python version for virtualenv Issue created by gabrielhora Describe the bug Given a project with multiple Python versions I would expect the exported virtualenvs to use the correct version as specified in
interpreter_constraints
. For example: • pants.toml
interpreter_constraints = [">= 3.8"]
• project_1 (no constraints, uses default) • project_2 (specific requirements.txt +
interpreter_constraints = [">= 3.10"]
) In this scenario, when running
./pants export ::
I get two virtualenvs, one for each project, but both use the same Python version 3.8.*. I realise my explanation might be confusing, so I created an example small repository here. In this repo I expected
py310
virtualenv to use Python 3.10.* (I do have it installed with pyenv), but as you can see bellow both use 3.8.*.
Copy code
$ python/pants_export % ./pants export ::         
11:30:16.82 [INFO] Completed: Building 1 requirement for requirements.pex from the 3rdparty/python/py310.lock resolve: boto3
Wrote virtualenv for the resolve 'py310' (using Python 3.8.13) to dist/export/python/virtualenvs/py310
Wrote virtualenv for the resolve 'py38' (using Python 3.8.13) to dist/export/python/virtualenvs/py38
Wrote virtualenv for the tool 'pytest' to dist/export/python/virtualenvs/tools
When running the code the projects do use the correct Python versions though.
Copy code
$ python/pants_export % ./pants run src/with_py38:bin                                                                                                                                  master
Running with 3.8.13 (default, Jul 26 2022, 09:50:21) 
[Clang 13.1.6 (clang-1316.0.21.2.5)]

$ python/pants_export % ./pants run src/with_py310:bin                                                                                                                                 master
Running with 3.10.5 (main, Jul 13 2022, 10:34:57) [Clang 13.1.6 (clang-1316.0.21.2.5)]
Pants version 2.12.0 OS MacOS 12.4 pantsbuild/pants