Imported Upstream version 60.3.1 upstream/60.3.1
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
CHANGES.rst
_distutils_hack/__init__.py
setup.cfg
setuptools/tests/test_distutils_adoption.py

index 36b712694ab0c45eba0d0fab4db45fd7681576f3..ca91c30e23596f1ec78a53eb423aec4493a4869a 100644 (file)
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 60.3.0
+current_version = 60.3.1
 commit = True
 tag = True
 
index 51fab99e6cbc0e00bdddfdc48b46918914257f88..2c52ecfc2844302fe3fa7fada1f4f721b5c10d50 100644 (file)
@@ -1,3 +1,12 @@
+v60.3.1
+-------
+
+
+Misc
+^^^^
+* #3002: Suppress AttributeError when detecting get-pip.
+
+
 v60.3.0
 -------
 
index 4745f8b9dafc851c436d877b789d8d50a67d4a1f..75bc4463bbc0b45f4155c2018cc78165640b24dc 100644 (file)
@@ -73,6 +73,17 @@ def do_override():
         ensure_local_distutils()
 
 
+class suppress(contextlib.suppress, contextlib.ContextDecorator):
+    """
+    A version of contextlib.suppress with decorator support.
+
+    >>> @suppress(KeyError)
+    ... def key_error():
+    ...     {}['']
+    >>> key_error()
+    """
+
+
 class DistutilsMetaFinder:
     def find_spec(self, fullname, path, target=None):
         if path is not None:
@@ -133,6 +144,7 @@ class DistutilsMetaFinder:
         )
 
     @classmethod
+    @suppress(AttributeError)
     def is_get_pip(cls):
         """
         Detect if get-pip is being invoked. Ref #2993.
index 0af9cd5e9564c5623bb96136529f407ca05427ef..a726d2f668ca7631c3a5bc318ea6e155878d9c29 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = setuptools
-version = 60.3.0
+version = 60.3.1
 author = Python Packaging Authority
 author_email = distutils-sig@python.org
 description = Easily download, build, install, upgrade, and uninstall Python packages
index 27759b1df831f71e420c186b7a4198813ddb7bcb..1e73f9aa1873466e054ea82d0a66ebf684c5dd14 100644 (file)
@@ -42,12 +42,24 @@ def popen_text(call):
         if sys.version_info < (3, 7) else functools.partial(call, text=True)
 
 
+def win_sr(env):
+    """
+    On Windows, SYSTEMROOT must be present to avoid
+
+    > Fatal Python error: _Py_HashRandomization_Init: failed to
+    > get random numbers to initialize Python
+    """
+    if env is None:
+        return
+    if platform.system() == 'Windows':
+        env['SYSTEMROOT'] = os.environ['SYSTEMROOT']
+    return env
+
+
 def find_distutils(venv, imports='distutils', env=None, **kwargs):
     py_cmd = 'import {imports}; print(distutils.__file__)'.format(**locals())
     cmd = ['python', '-c', py_cmd]
-    if platform.system() == 'Windows':
-        env['SYSTEMROOT'] = os.environ['SYSTEMROOT']
-    return popen_text(venv.run)(cmd, env=env, **kwargs)
+    return popen_text(venv.run)(cmd, env=win_sr(env), **kwargs)
 
 
 def count_meta_path(venv, env=None):
@@ -58,7 +70,7 @@ def count_meta_path(venv, env=None):
         print(len(list(filter(is_distutils, sys.meta_path))))
         """)
     cmd = ['python', '-c', py_cmd]
-    return int(popen_text(venv.run)(cmd, env=env))
+    return int(popen_text(venv.run)(cmd, env=win_sr(env)))
 
 
 def test_distutils_stdlib(venv):
@@ -89,3 +101,12 @@ def test_distutils_local(venv):
     env = dict(SETUPTOOLS_USE_DISTUTILS='local')
     assert venv.name in find_distutils(venv, env=env).split(os.sep)
     assert count_meta_path(venv, env=env) <= 1
+
+
+def test_pip_import(venv):
+    """
+    Ensure pip can be imported.
+    Regression test for #3002.
+    """
+    cmd = ['python', '-c', 'import pip']
+    popen_text(venv.run)(cmd)