You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
While trying to pipx inject a local wheel with specific Python version constraints into a compatible environment (i.e. with a valid interpreter for those constraints), I keep getting the following error:
ERROR: Package 'my-local-package' requires a different Python: 3.11.1 not in '<3.11,>=3.8'
Here are the relevant versions and constraints 👇
package (to be injected) interpreter constraints: <3.11, >=3.8
environment interpreter: 3.8
pipx interpreter: 3.11.1
After seeing the error, it became clear that somehow in the middle of the injection process, pipx was trying to install the package with a different interpreter for some reason. After some debugging, I noticed that when the package is a local distribution we need to install it (without its dependencies) into a temporary venv in order to extract its name. However, when we do it, we end up using a default Python interpreter, instead of the one associated with the venv here 👇
I locally replaced venv.python (which maps to a default interpreter in this case) with venv.python_path (which maps to venv-specific interpreter) and it worked 😃
How to reproduce
Verbose logs for the inject command
pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: /path/to/my-local-package-1.0.0-py3-none-any.whl
creating virtual environment...
pipx >(run_subprocess:173): running /opt/homebrew/Cellar/pipx/1.1.0/libexec/bin/python3.11 -m venv --without-pip /var/folders/vj/chbx1tms2c93nmnnp2gw4wh80000gq/T/tmpe5g_foll
pipx >(run_subprocess:173): running /var/folders/vj/chbx1tms2c93nmnnp2gw4wh80000gq/T/tmpe5g_foll/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:173): running /Users/me/.local/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:173): running /var/folders/vj/chbx1tms2c93nmnnp2gw4wh80000gq/T/tmpe5g_foll/bin/python --version
determining package name from '/path/to/my-local-package-1.0.0-py3-none-any.whl'...
pipx >(run_subprocess:173): running /var/folders/vj/chbx1tms2c93nmnnp2gw4wh80000gq/T/tmpe5g_foll/bin/python -m pip list --format=json
pipx >(run_subprocess:173): running /var/folders/vj/chbx1tms2c93nmnnp2gw4wh80000gq/T/tmpe5g_foll/bin/python -m pip install --no-dependencies /path/to/my-local-package-1.0.0-py3-none-any.whl
Looking in indexes: https://pypi.org/simple
Processing /path/to/my-local-package-1.0.0-py3-none-any.whl
ERROR: Package 'my-local-package' requires a different Python: 3.11.1 not in '<3.11,>=3.8'
pipx >(subprocess_post_check:207): '/var/folders/vj/chbx1tms2c93nmnnp2gw4wh80000gq/T/tmpe5g_foll/bin/python -m pip install --no-dependencies /path/to/my-local-package-1.0.0-py3-none-any.whl' failed
Cannot determine package name from spec '/path/to/my-local-package-1.0.0-py3-none-any.whl'. Check package spec for errors.
Expected behavior
pipx should be able to inject dependencies into existing environments if their interpreters are compatible.
The text was updated successfully, but these errors were encountered:
Describe the bug
While trying to
pipx inject
a local wheel with specific Python version constraints into a compatible environment (i.e. with a valid interpreter for those constraints), I keep getting the following error:Here are the relevant versions and constraints 👇
After seeing the error, it became clear that somehow in the middle of the injection process, pipx was trying to install the package with a different interpreter for some reason. After some debugging, I noticed that when the package is a local distribution we need to install it (without its dependencies) into a temporary venv in order to extract its name. However, when we do it, we end up using a default Python interpreter, instead of the one associated with the venv here 👇
pipx/src/pipx/commands/inject.py
Lines 46 to 51 in 726eaf8
I locally replaced
venv.python
(which maps to a default interpreter in this case) withvenv.python_path
(which maps to venv-specific interpreter) and it worked 😃How to reproduce
Verbose logs for the inject command
Expected behavior
pipx should be able to inject dependencies into existing environments if their interpreters are compatible.
The text was updated successfully, but these errors were encountered: