orion / rpms / python3x-pip

Forked from rpms/python3x-pip 2 years ago
Clone
b38b25
diff -up pip-19.3.1/news/7872.bugfix.pip7873 pip-19.3.1/news/7872.bugfix
b38b25
--- pip-19.3.1/news/7872.bugfix.pip7873	2022-05-24 08:34:03.285054864 -0600
b38b25
+++ pip-19.3.1/news/7872.bugfix	2022-05-24 08:34:03.285054864 -0600
b38b25
@@ -0,0 +1 @@
b38b25
+Prevent an infinite recursion with ``pip wheel`` when ``$TMPDIR`` is within the source directory.
b38b25
diff -up pip-19.3.1/src/pip/_internal/download.py.pip7873 pip-19.3.1/src/pip/_internal/download.py
b38b25
--- pip-19.3.1/src/pip/_internal/download.py.pip7873	2019-10-17 13:32:34.000000000 -0600
b38b25
+++ pip-19.3.1/src/pip/_internal/download.py	2022-05-24 08:35:17.013833331 -0600
b38b25
@@ -350,12 +350,24 @@ def _copy2_ignoring_special_files(src, d
b38b25
 
b38b25
 def _copy_source_tree(source, target):
b38b25
     # type: (str, str) -> None
b38b25
+    target_abspath = os.path.abspath(target)
b38b25
+    target_basename = os.path.basename(target_abspath)
b38b25
+    target_dirname = os.path.dirname(target_abspath)
b38b25
+
b38b25
     def ignore(d, names):
b38b25
-        # Pulling in those directories can potentially be very slow,
b38b25
-        # exclude the following directories if they appear in the top
b38b25
-        # level dir (and only it).
b38b25
-        # See discussion at https://github.com/pypa/pip/pull/6770
b38b25
-        return ['.tox', '.nox'] if d == source else []
b38b25
+        skipped = []  # type: List[str]
b38b25
+        if d == source:
b38b25
+            # Pulling in those directories can potentially be very slow,
b38b25
+            # exclude the following directories if they appear in the top
b38b25
+            # level dir (and only it).
b38b25
+            # See discussion at https://github.com/pypa/pip/pull/6770
b38b25
+            skipped += ['.tox', '.nox']
b38b25
+        if os.path.abspath(d) == target_dirname:
b38b25
+            # Prevent an infinite recursion if the target is in source.
b38b25
+            # This can happen when TMPDIR is set to ${PWD}/...
b38b25
+            # and we copy PWD to TMPDIR.
b38b25
+            skipped += [target_basename]
b38b25
+        return skipped
b38b25
 
b38b25
     kwargs = dict(ignore=ignore, symlinks=True)  # type: CopytreeKwargs
b38b25
 
b38b25
diff -up pip-19.3.1/src/pip/_internal/operations/prepare.py.pip7873 pip-19.3.1/src/pip/_internal/operations/prepare.py
b38b25
diff -up pip-19.3.1/tests/data/src/extension/extension.c.pip7873 pip-19.3.1/tests/data/src/extension/extension.c
b38b25
diff -up pip-19.3.1/tests/data/src/extension/setup.py.pip7873 pip-19.3.1/tests/data/src/extension/setup.py
b38b25
--- pip-19.3.1/tests/data/src/extension/setup.py.pip7873	2022-05-24 08:34:03.285054864 -0600
b38b25
+++ pip-19.3.1/tests/data/src/extension/setup.py	2022-05-24 08:34:03.285054864 -0600
b38b25
@@ -0,0 +1,4 @@
b38b25
+from setuptools import Extension, setup
b38b25
+
b38b25
+module = Extension('extension', sources=['extension.c'])
b38b25
+setup(name='extension', version='0.0.1', ext_modules = [module])
b38b25
diff -up pip-19.3.1/tests/functional/test_wheel.py.pip7873 pip-19.3.1/tests/functional/test_wheel.py
b38b25
--- pip-19.3.1/tests/functional/test_wheel.py.pip7873	2019-10-17 13:32:34.000000000 -0600
b38b25
+++ pip-19.3.1/tests/functional/test_wheel.py	2022-05-24 08:34:03.285054864 -0600
b38b25
@@ -1,6 +1,7 @@
b38b25
 """'pip wheel' tests"""
b38b25
 import os
b38b25
 import re
b38b25
+import sys
b38b25
 from os.path import exists
b38b25
 
b38b25
 import pytest
b38b25
@@ -228,6 +229,24 @@ def test_pip_wheel_with_user_set_in_conf
b38b25
     assert "Successfully built withpyproject" in result.stdout, result.stdout
b38b25
 
b38b25
 
b38b25
+@pytest.mark.skipif(sys.platform.startswith('win'),
b38b25
+                    reason='The empty extension module does not work on Win')
b38b25
+def test_pip_wheel_ext_module_with_tmpdir_inside(script, data, common_wheels):
b38b25
+    tmpdir = data.src / 'extension/tmp'
b38b25
+    tmpdir.mkdir()
b38b25
+    script.environ['TMPDIR'] = str(tmpdir)
b38b25
+
b38b25
+    # To avoid a test dependency on a C compiler, we set the env vars to "noop"
b38b25
+    # The .c source is empty anyway
b38b25
+    script.environ['CC'] = script.environ['LDSHARED'] = str('true')
b38b25
+
b38b25
+    result = script.pip(
b38b25
+        'wheel', data.src / 'extension',
b38b25
+        '--no-index', '-f', common_wheels
b38b25
+    )
b38b25
+    assert "Successfully built extension" in result.stdout, result.stdout
b38b25
+
b38b25
+
b38b25
 @pytest.mark.network
b38b25
 def test_pep517_wheels_are_not_confused_with_other_files(script, tmpdir, data):
b38b25
     """Check correct wheels are copied. (#6196)