Commit ff826335 authored by Godefroid Chapelle's avatar Godefroid Chapelle

Problem: pip is called via internals

Solution: use `python -m pip`
parent 2b6995c6
Call pip via `python -m pip`.
...@@ -40,7 +40,6 @@ import zc.buildout ...@@ -40,7 +40,6 @@ import zc.buildout
import zc.buildout.rmtree import zc.buildout.rmtree
from zc.buildout import WINDOWS from zc.buildout import WINDOWS
from zc.buildout import PY3 from zc.buildout import PY3
from zc.buildout.pip_support import pip_install_cmd as _pip_install_cmd
import warnings import warnings
import csv import csv
...@@ -1656,11 +1655,7 @@ def call_pip_install(spec, dest): ...@@ -1656,11 +1655,7 @@ def call_pip_install(spec, dest):
distribution specified by `spec` into `dest`. distribution specified by `spec` into `dest`.
Returns all the paths inside `dest` created by the above. Returns all the paths inside `dest` created by the above.
""" """
path = pip_path args = [sys.executable, '-m', 'pip', 'install', '--no-deps', '-t', dest]
args = [sys.executable, '-c',
('import sys; sys.path[0:0] = %r; ' % path) +
_pip_install_cmd, 'install', '--no-deps', '-t', dest]
level = logger.getEffectiveLevel() level = logger.getEffectiveLevel()
if level >= logging.INFO: if level >= logging.INFO:
args.append('-q') args.append('-q')
...@@ -1680,13 +1675,18 @@ def call_pip_install(spec, dest): ...@@ -1680,13 +1675,18 @@ def call_pip_install(spec, dest):
else: else:
args.append('--no-python-version-warning') 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: if level <= logging.DEBUG:
logger.debug('Running pip install:\n"%s"\npath=%s\n', 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 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: if exit_code:
logger.error( logger.error(
......
try:
# support pip>=19.0
from pip._internal.cli.main import main
pip_install_cmd = (
'from pip._internal.cli.main import main; sys.exit(main())'
)
except ImportError:
# support pip>=10.0
from pip._internal import main
pip_install_cmd = 'from pip._internal import main; sys.exit(main())'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment