[Python-checkins] bpo-38927: Use python -m pip to upgrade venv deps (GH-17403)
Vinay Sajip
webhook-mailer at python.org
Wed Nov 27 15:25:29 EST 2019
https://github.com/python/cpython/commit/d9aa216d49423d58e192cd7a25016f90fe771ce7
commit: d9aa216d49423d58e192cd7a25016f90fe771ce7
branch: master
author: Tzu-ping Chung <uranusjr at gmail.com>
committer: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: 2019-11-27T20:25:23Z
summary:
bpo-38927: Use python -m pip to upgrade venv deps (GH-17403)
I suggest you add `bpo-NNNNN: ` as a prefix for the first commit for future PRs. Thanks!
files:
A Misc/NEWS.d/next/Library/2019-11-27-17-47-00.bpo-38927.qT7xKY.rst
M Lib/test/test_venv.py
M Lib/venv/__init__.py
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index 0103de8828dd1..741ac109bbc8c 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -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'
]
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index 4ab9cc6d6fb2b..81cb1d13e2163 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -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)
diff --git a/Misc/NEWS.d/next/Library/2019-11-27-17-47-00.bpo-38927.qT7xKY.rst b/Misc/NEWS.d/next/Library/2019-11-27-17-47-00.bpo-38927.qT7xKY.rst
new file mode 100644
index 0000000000000..ca6ed63e5ccc1
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-11-27-17-47-00.bpo-38927.qT7xKY.rst
@@ -0,0 +1 @@
+Use ``python -m pip`` instead of ``pip`` to upgrade dependencies in venv.
More information about the Python-checkins
mailing list