Skip to content
9 changes: 9 additions & 0 deletions pkgs/modules/python/sitecustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down