Poetry bundle uses wrong Python while preparing venv bundle
Environment
I have got the following poetry (poetry env info):
Virtualenv
Python: 3.10.13
Implementation: CPython
Path: /Users/adamko/Library/Caches/pypoetry/virtualenvs/xxx-library-S7aa1Bec-py3.10
Executable: /Users/adamko/Library/Caches/pypoetry/virtualenvs/xxx-library-S7aa1Bec-py3.10/bin/python
Valid: True
I don't have 3.9 available:
pip env list
xxx-library-S7aa1Bec-py3.10 (Activated)
xxx-library-S7aa1Bec-py3.11
Issue However when I invoke: poetry bundle venv --without dev dist/venv_pack;
I see: • Bundling xxx-library (0.1.0) into dist/venv_pack: Creating a virtual environment using Python 3.9.6
When I try to force 3.10 via --python 3.10 I am getting (poetry bundle venv --python 3.10 --without dev dist/venv_pack):
• Bundling data-contracts-library (0.1.0) into dist/venv_pack: Creating a virtual environment using Python 3.10.13
[Errno 2] No such file or directory: '/Users/adamko/work/hf/xxx-library/python3.10'
So it almost works, but why I suddenly receive no such file or directory error? Of course I don't have this directory, but don't get why it tries to touch anything there.
Any help appreciated. Thanks
To add, my local "default" python is 3.10 also: poetry run python return 3.10.13
"Naked" python returns 3.10.13. So confused!
Ok, what seems to work is providing full path to Python executable (i.e. one taken from poetry env info). Nevertheless, this behavious is confusing and doesn't seem to work as expected? 🤔
I noticed the same behavior.
pyproject.toml contains:
[tool.poetry.dependencies]
python = "^3.11"
$ poetry env info
Virtualenv
Python: 3.11.5
Implementation: CPython
Path: /home/.../tests/integration/.venv
Executable: /home/.../tests/integration/.venv/bin/python
Valid: True
System
Platform: linux
OS: posix
Python: 3.11.5
Path: /usr
Executable: /usr/bin/python3.11
But when bundling the app, it fails because it uses python3.10 and one of the editable dependency requires python^3.11.
$ poetry bundle venv ./bundle
• Bundling integration-tests (0.1.0) into bundle: Installing dependencies
The current project's Python requirement (3.10.12) is not compatible with some of the required packages Python requirement:
- py-data-core requires Python ^3.11, so it will not be satisfied for Python 3.10.12
Note that poetry install uses the correct python interpreter.
Oh, I noticed it is working as expected:
By default, the command uses the current Python executable to build the virtual environment.
Would be a nice improvement to try to find the proper version the same way as poetry install.