diff --git a/pkgs/modules/python/sitecustomize.py b/pkgs/modules/python/sitecustomize.py index ab1d7bbe..3c02c4fa 100644 --- a/pkgs/modules/python/sitecustomize.py +++ b/pkgs/modules/python/sitecustomize.py @@ -21,6 +21,15 @@ def pip_build_shebang(self, executable, post_interp): return result import sys +import os + +repl_home = os.getenv('REPL_HOME') +if repl_home and sys.executable.startswith(repl_home + '/.pythonlibs/bin'): + # unset `PIP_CONFIG_FILE` (see pip.nix's pip.conf) if we are in + # a virtualenv because `--user` install mode doesn't work in virtualenv. + if 'PIP_CONFIG_FILE' in os.environ: + os.environ.pop('PIP_CONFIG_FILE') + exe = sys.argv[0] if exe.endswith('/pip') or exe.endswith('/pip3') or exe.endswith('/.pip-wrapped'): from pip._vendor.distlib.scripts import ScriptMaker