Imported Upstream version 60.3.0 upstream/60.3.0
authorJinWang An <jinwang.an@samsung.com>
Mon, 27 Mar 2023 08:02:42 +0000 (17:02 +0900)
committerJinWang An <jinwang.an@samsung.com>
Mon, 27 Mar 2023 08:02:42 +0000 (17:02 +0900)
.bumpversion.cfg
.github/workflows/main.yml
CHANGES.rst
_distutils_hack/__init__.py
setup.cfg
setuptools/_distutils/_collections.py [new file with mode: 0644]
setuptools/_distutils/command/install.py
setuptools/_distutils/tests/py38compat.py
setuptools/_distutils/tests/test_bdist_rpm.py
setuptools/_distutils/tests/test_build_ext.py
setuptools/command/easy_install.py

index f696b076be19817f65047c1a9f8699ee035f17da..36b712694ab0c45eba0d0fab4db45fd7681576f3 100644 (file)
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 60.2.0
+current_version = 60.3.0
 commit = True
 tag = True
 
index 5a01e9a54213a05bf91c27270daae392bf455fc0..94d0a08ee68f9d489af29d797e993a4b519a84d1 100644 (file)
@@ -12,6 +12,7 @@ jobs:
         python:
         - pypy-3.7
         - 3.7
+        - 3.8
         - 3.9
         - "3.10"
         platform:
index 59b29fb51eeba6c052422943e9f3212d32aed557..51fab99e6cbc0e00bdddfdc48b46918914257f88 100644 (file)
@@ -1,3 +1,16 @@
+v60.3.0
+-------
+
+
+Changes
+^^^^^^^
+* #2993: In _distutils_hack, bypass the distutils exception for pip when get-pip is being invoked, because it imports setuptools.
+
+Misc
+^^^^
+* #2989: Merge with pypa/distutils@788cc159. Includes fix for config vars missing from sysconfig.
+
+
 v60.2.0
 -------
 
index c0170d0908ff6319a145e088d9b27d74f9bdab5b..4745f8b9dafc851c436d877b789d8d50a67d4a1f 100644 (file)
@@ -116,6 +116,8 @@ class DistutilsMetaFinder:
         """
         if self.pip_imported_during_build():
             return
+        if self.is_get_pip():
+            return
         clear_distutils()
         self.spec_for_distutils = lambda: None
 
@@ -130,6 +132,14 @@ class DistutilsMetaFinder:
             for frame, line in traceback.walk_stack(None)
         )
 
+    @classmethod
+    def is_get_pip(cls):
+        """
+        Detect if get-pip is being invoked. Ref #2993.
+        """
+        import __main__
+        return os.path.basename(__main__.__file__) == 'get-pip.py'
+
     @staticmethod
     def frame_file_is_setup(frame):
         """
index 75a41c848414c71d519b8cd70a341452be6873dc..0af9cd5e9564c5623bb96136529f407ca05427ef 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = setuptools
-version = 60.2.0
+version = 60.3.0
 author = Python Packaging Authority
 author_email = distutils-sig@python.org
 description = Easily download, build, install, upgrade, and uninstall Python packages
diff --git a/setuptools/_distutils/_collections.py b/setuptools/_distutils/_collections.py
new file mode 100644 (file)
index 0000000..98fce80
--- /dev/null
@@ -0,0 +1,56 @@
+import collections
+import itertools
+
+
+# from jaraco.collections 3.5.1
+class DictStack(list, collections.abc.Mapping):
+    """
+    A stack of dictionaries that behaves as a view on those dictionaries,
+    giving preference to the last.
+
+    >>> stack = DictStack([dict(a=1, c=2), dict(b=2, a=2)])
+    >>> stack['a']
+    2
+    >>> stack['b']
+    2
+    >>> stack['c']
+    2
+    >>> len(stack)
+    3
+    >>> stack.push(dict(a=3))
+    >>> stack['a']
+    3
+    >>> set(stack.keys()) == set(['a', 'b', 'c'])
+    True
+    >>> set(stack.items()) == set([('a', 3), ('b', 2), ('c', 2)])
+    True
+    >>> dict(**stack) == dict(stack) == dict(a=3, c=2, b=2)
+    True
+    >>> d = stack.pop()
+    >>> stack['a']
+    2
+    >>> d = stack.pop()
+    >>> stack['a']
+    1
+    >>> stack.get('b', None)
+    >>> 'c' in stack
+    True
+    """
+
+    def __iter__(self):
+        dicts = list.__iter__(self)
+        return iter(set(itertools.chain.from_iterable(c.keys() for c in dicts)))
+
+    def __getitem__(self, key):
+        for scope in reversed(tuple(list.__iter__(self))):
+            if key in scope:
+                return scope[key]
+        raise KeyError(key)
+
+    push = list.append
+
+    def __contains__(self, other):
+        return collections.abc.Mapping.__contains__(self, other)
+
+    def __len__(self):
+        return len(list(iter(self)))
index cdcc05281437bd03b27008796ede8f6f6eee7ac7..511938f47f122cd01b2b06f94401a24710c5e25c 100644 (file)
@@ -17,6 +17,7 @@ from distutils.file_util import write_file
 from distutils.util import convert_path, subst_vars, change_root
 from distutils.util import get_platform
 from distutils.errors import DistutilsOptionError
+from .. import _collections
 
 from site import USER_BASE
 from site import USER_SITE
@@ -394,7 +395,8 @@ class install(Command):
         except AttributeError:
             # sys.abiflags may not be defined on all platforms.
             abiflags = ''
-        self.config_vars = {'dist_name': self.distribution.get_name(),
+        local_vars = {
+            'dist_name': self.distribution.get_name(),
                             'dist_version': self.distribution.get_version(),
                             'dist_fullname': self.distribution.get_fullname(),
                             'py_version': py_version,
@@ -408,12 +410,14 @@ class install(Command):
                             'platlibdir': getattr(sys, 'platlibdir', 'lib'),
                             'implementation_lower': _get_implementation().lower(),
                             'implementation': _get_implementation(),
-                            'platsubdir': sysconfig.get_config_var('platsubdir'),
                            }
 
         if HAS_USER_SITE:
-            self.config_vars['userbase'] = self.install_userbase
-            self.config_vars['usersite'] = self.install_usersite
+            local_vars['userbase'] = self.install_userbase
+            local_vars['usersite'] = self.install_usersite
+
+        self.config_vars = _collections.DictStack(
+            [sysconfig.get_config_vars(), local_vars])
 
         self.expand_basedirs()
 
@@ -421,15 +425,13 @@ class install(Command):
 
         # Now define config vars for the base directories so we can expand
         # everything else.
-        self.config_vars['base'] = self.install_base
-        self.config_vars['platbase'] = self.install_platbase
-        self.config_vars['installed_base'] = (
-            sysconfig.get_config_vars()['installed_base'])
+        local_vars['base'] = self.install_base
+        local_vars['platbase'] = self.install_platbase
 
         if DEBUG:
             from pprint import pprint
             print("config vars:")
-            pprint(self.config_vars)
+            pprint(dict(self.config_vars))
 
         # Expand "~" and configuration variables in the installation
         # directories.
index 32269c7b93e2a5cc58c9afde6284dbd9d2ce685b..c949f58ecde0180764322ab973922907dfd84e59 100644 (file)
@@ -2,6 +2,11 @@
 
 import contextlib
 import builtins
+import sys
+
+from test.support import requires_zlib
+import test.support
+
 
 ModuleNotFoundError = getattr(builtins, 'ModuleNotFoundError', ImportError)
 
@@ -51,3 +56,7 @@ try:
     from test.support.warnings_helper import save_restore_warnings_filters
 except (ModuleNotFoundError, ImportError):
     save_restore_warnings_filters = _save_restore_warnings_filters
+
+
+if sys.version_info < (3, 9):
+    requires_zlib = lambda: test.support.requires_zlib
index 3b22af3a90f962fcd05b54928e3481cc1ee1141f..08a7cb46d89b3540101a4d597b3319775c63cc39 100644 (file)
@@ -3,13 +3,16 @@
 import unittest
 import sys
 import os
-from test.support import run_unittest, requires_zlib
+from test.support import run_unittest
 
 from distutils.core import Distribution
 from distutils.command.bdist_rpm import bdist_rpm
 from distutils.tests import support
 from distutils.spawn import find_executable
 
+from .py38compat import requires_zlib
+
+
 SETUP_PY = """\
 from distutils.core import setup
 import foo
@@ -44,7 +47,7 @@ class BuildRpmTestCase(support.TempdirManager,
     # spurious sdtout/stderr output under Mac OS X
     @unittest.skipUnless(sys.platform.startswith('linux'),
                          'spurious sdtout/stderr output under Mac OS X')
-    @requires_zlib
+    @requires_zlib()
     @unittest.skipIf(find_executable('rpm') is None,
                      'the rpm command is not found')
     @unittest.skipIf(find_executable('rpmbuild') is None,
@@ -87,7 +90,7 @@ class BuildRpmTestCase(support.TempdirManager,
     # spurious sdtout/stderr output under Mac OS X
     @unittest.skipUnless(sys.platform.startswith('linux'),
                          'spurious sdtout/stderr output under Mac OS X')
-    @requires_zlib
+    @requires_zlib()
     # http://bugs.python.org/issue1533164
     @unittest.skipIf(find_executable('rpm') is None,
                      'the rpm command is not found')
index cb0db2b57a2eab90f39abec3c9fce8441b9fbfc4..920e4dc8707186ac606dc72967e399a445bd42a3 100644 (file)
@@ -493,12 +493,16 @@ class BuildExtTestCase(TempdirManager,
         # format the target value as defined in the Apple
         # Availability Macros.  We can't use the macro names since
         # at least one value we test with will not exist yet.
-        if target[1] < 10:
+        if target[:2] < (10, 10):
             # for 10.1 through 10.9.x -> "10n0"
             target = '%02d%01d0' % target
         else:
             # for 10.10 and beyond -> "10nn00"
-            target = '%02d%02d00' % target
+            if len(target) >= 2:
+                target = '%02d%02d00' % target
+            else:
+                # 11 and later can have no minor version (11 instead of 11.0)
+                target = '%02d0000' % target
         deptarget_ext = Extension(
             'deptarget',
             [deptarget_c],
index fb34d10e096be462285050d149b7416395ed8115..aad5794a330d3f04e612606975b85aaaef43f4af 100644 (file)
@@ -1350,7 +1350,7 @@ class easy_install(Command):
 
         if self.prefix:
             # Set default install_dir/scripts from --prefix
-            config_vars = config_vars.copy()
+            config_vars = dict(config_vars)
             config_vars['base'] = self.prefix
             scheme = self.INSTALL_SCHEMES.get(os.name, self.DEFAULT_SCHEME)
             for attr, val in scheme.items():