]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38927: Use python -m pip to upgrade venv deps (GH-17403)
authorTzu-ping Chung <uranusjr@gmail.com>
Wed, 27 Nov 2019 20:25:23 +0000 (04:25 +0800)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 27 Nov 2019 20:25:23 +0000 (20:25 +0000)
I suggest you add `bpo-NNNNN: ` as a prefix for the first commit for future PRs. Thanks!

Lib/test/test_venv.py
Lib/venv/__init__.py
Misc/NEWS.d/next/Library/2019-11-27-17-47-00.bpo-38927.qT7xKY.rst [new file with mode: 0644]

index 0103de8828dd1b6a14b8aac465b5b5cdc524af23..741ac109bbc8c5ac79912960b179a7ad2b565248 100644 (file)
@@ -141,16 +141,18 @@ class BasicTest(BaseTest):
     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'
                     ]
index 4ab9cc6d6fb2bc413d4e2af8816868ea160323a9..81cb1d13e216387cef3261e42ea425066d71bc6a 100644 (file)
@@ -393,10 +393,10 @@ class EnvBuilder:
             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 (file)
index 0000000..ca6ed63
--- /dev/null
@@ -0,0 +1 @@
+Use ``python -m pip`` instead of ``pip`` to upgrade dependencies in venv.