Skip to content

bpo-38927: Use python -m pip to upgrade venv deps #17403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,18 @@ def test_prompt(self):
def test_upgrade_dependencies(self):
builder = venv.EnvBuilder()
bin_path = 'Scripts' if sys.platform == 'win32' else 'bin'
pip_exe = 'pip.exe' if sys.platform == 'win32' else 'pip'
python_exe = 'python.exe' if sys.platform == 'win32' else 'python'
with tempfile.TemporaryDirectory() as fake_env_dir:

def pip_cmd_checker(cmd):
self.assertEqual(
cmd,
[
os.path.join(fake_env_dir, bin_path, pip_exe),
os.path.join(fake_env_dir, bin_path, python_exe),
'-m',
'pip',
'install',
'-U',
'--upgrade',
'pip',
'setuptools'
]
Expand Down
6 changes: 3 additions & 3 deletions Lib/venv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ def upgrade_dependencies(self, context):
f'Upgrading {CORE_VENV_DEPS} packages in {context.bin_path}'
)
if sys.platform == 'win32':
pip_exe = os.path.join(context.bin_path, 'pip.exe')
python_exe = os.path.join(context.bin_path, 'python.exe')
else:
pip_exe = os.path.join(context.bin_path, 'pip')
cmd = [pip_exe, 'install', '-U']
python_exe = os.path.join(context.bin_path, 'python')
cmd = [python_exe, '-m', 'pip', 'install', '--upgrade']
cmd.extend(CORE_VENV_DEPS)
subprocess.check_call(cmd)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use ``python -m pip`` instead of ``pip`` to upgrade dependencies in venv.