Skip to content

Commit

Permalink
Problem: pip is called via internals
Browse files Browse the repository at this point in the history
Solution: use `python -m pip`
  • Loading branch information
gotcha committed Dec 16, 2021
1 parent 2b6995c commit ff82633
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
1 change: 1 addition & 0 deletions news/569.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Call pip via `python -m pip`.
16 changes: 8 additions & 8 deletions src/zc/buildout/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import zc.buildout.rmtree
from zc.buildout import WINDOWS
from zc.buildout import PY3
from zc.buildout.pip_support import pip_install_cmd as _pip_install_cmd
import warnings
import csv

Expand Down Expand Up @@ -1656,11 +1655,7 @@ def call_pip_install(spec, dest):
distribution specified by `spec` into `dest`.
Returns all the paths inside `dest` created by the above.
"""
path = pip_path

args = [sys.executable, '-c',
('import sys; sys.path[0:0] = %r; ' % path) +
_pip_install_cmd, 'install', '--no-deps', '-t', dest]
args = [sys.executable, '-m', 'pip', 'install', '--no-deps', '-t', dest]
level = logger.getEffectiveLevel()
if level >= logging.INFO:
args.append('-q')
Expand All @@ -1680,13 +1675,18 @@ def call_pip_install(spec, dest):
else:
args.append('--no-python-version-warning')

env = copy.copy(os.environ)
python_path = copy.copy(pip_path)
python_path.append(env.get('PYTHONPATH', ''))
env['PYTHONPATH'] = os.pathsep.join(python_path)

if level <= logging.DEBUG:
logger.debug('Running pip install:\n"%s"\npath=%s\n',
'" "'.join(args), path)
'" "'.join(args), pip_path)

sys.stdout.flush() # We want any pending output first

exit_code = subprocess.call(list(args))
exit_code = subprocess.call(list(args), env=env)

if exit_code:
logger.error(
Expand Down
10 changes: 0 additions & 10 deletions src/zc/buildout/pip_support.py

This file was deleted.

0 comments on commit ff82633

Please sign in to comment.