Open seasonedfish opened 2 years ago
I'm getting a different result than you are:
which python3.10 ~
/Users/spott/.nix-profile/bin/python
λ › python3.10 ~
Python 3.10.12 (main, Aug 24 2023, 05:19:11) [Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; sys.executable
'/nix/store/my12ln4rzvqiinyi2f3cyyvsvs29s7aq-python3-3.10.12-env/bin/python3.10'
I get the same result with python3
, and python
.
The env variable PIPX_DEFAULT_PYTHON
can change the python interpreter that is used. I'm not sure if there is a way to set that for the python package when it is installed.
It looks like PIPX_DEFAULT_PYTHON
can be set by adding makeWrapperArgs = ["--set PIPX_DEFAULT_PYTHON ${nix_profile_path_for_python}"]
to the buildPythonPackage
function.
Unfortunately, there is the issue that this kind of breaks purity for the pipx package if you depend on a profile path within a derivation. Is there a way to prevent the GC from cleaning up the locations?
Describe the bug
If you install pipx through Nix and use pipx to install packages, pipx's virtual environment symlink points to the Nix store path instead of the Nix profile path.
The result is that whenever the user upgrades Python and collects garbage using Nix, the symlink will be invalid.
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
The virtual environment symlink should point to the Nix profile path. Using
venv
by itself yields the correct behavior:Additional context
If I may speculate, this seems to be a Nix packaging issue. On creating a venv, pipx uses the DEFAULT_PYTHON variable, which is set to the output of
sys.executable
.Running
sys.executable
from a REPL gives me the correct result.Notify maintainers
@yshym
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.