Imported Upstream version 60.9.2 upstream/60.9.2
authorJinWang An <jinwang.an@samsung.com>
Mon, 27 Mar 2023 08:02:46 +0000 (17:02 +0900)
committerJinWang An <jinwang.an@samsung.com>
Mon, 27 Mar 2023 08:02:46 +0000 (17:02 +0900)
.bumpversion.cfg
.github/workflows/main.yml
CHANGES.rst
_distutils_hack/__init__.py
setup.cfg
setuptools/tests/test_distutils_adoption.py

index 7f5864f86a52cb7e5590049748d0b3688483e862..e5562928fe64dd829704f1cc52369a89aaf2cab6 100644 (file)
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 60.9.1
+current_version = 60.9.2
 commit = True
 tag = True
 
index c985f851e7e80bdd235552be000c992e9a86b966..5a8d510def06f1fe8cf5de15a62072b9cdad4660 100644 (file)
@@ -29,6 +29,7 @@ jobs:
     runs-on: ${{ matrix.platform }}
     env:
       SETUPTOOLS_USE_DISTUTILS: ${{ matrix.distutils }}
+    timeout-minutes: 75
     steps:
       - uses: actions/checkout@v2
       - name: Setup Python
@@ -50,6 +51,7 @@ jobs:
 
   test_cygwin:
     runs-on: windows-latest
+    timeout-minutes: 75
     steps:
       - uses: actions/checkout@v2
       - name: Install Cygwin with Python
@@ -82,6 +84,7 @@ jobs:
     #    "integration")
     # With that in mind, the integration tests can run for a single setup
     runs-on: ubuntu-latest
+    timeout-minutes: 75
     steps:
       - uses: actions/checkout@v2
       - name: Install OS-level dependencies
@@ -103,7 +106,7 @@ jobs:
     needs: [test, test_cygwin, integration-test]
     if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
     runs-on: ubuntu-latest
-
+    timeout-minutes: 75
     steps:
       - uses: actions/checkout@v2
       - name: Setup Python
index efe34d3c7f915bf4166342e5eb02d4bf88198e6d..3899933148acd925f0c03220128c3734df490627 100644 (file)
@@ -1,3 +1,12 @@
+v60.9.2
+-------
+
+
+Misc
+^^^^
+* #3035: When loading distutils from the vendored copy, rewrite ``__name__`` to ensure consistent importing from inside and out.
+
+
 v60.9.1
 -------
 
index c6f7de6066857bfb5c6520728c3a1805c8465e79..605a6edc7cc69b24eaf0ac944d511ed39a78e06c 100644 (file)
@@ -57,6 +57,7 @@ def ensure_local_distutils():
     # check that submodules load as expected
     core = importlib.import_module('distutils.core')
     assert '_distutils' in core.__file__, core.__file__
+    assert 'setuptools._distutils.log' not in sys.modules
 
 
 def do_override():
@@ -112,6 +113,7 @@ class DistutilsMetaFinder:
         class DistutilsLoader(importlib.abc.Loader):
 
             def create_module(self, spec):
+                mod.__name__ = 'distutils'
                 return mod
 
             def exec_module(self, module):
index 555038c4902628c8117477cb083eb27a9a0da792..dc921fbff2648e91d79e0f76b6fc3c09bf4d7eb4 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = setuptools
-version = 60.9.1
+version = 60.9.2
 author = Python Packaging Authority
 author_email = distutils-sig@python.org
 description = Easily download, build, install, upgrade, and uninstall Python packages
index 366f2928a8d62430cded49ed83e26b1ec91cad65..df8f35419cb3786fadf95c790eecd52ce368e754 100644 (file)
@@ -93,3 +93,66 @@ def test_distutils_has_origin():
     Distutils module spec should have an origin. #2990.
     """
     assert __import__('distutils').__spec__.origin
+
+
+ENSURE_IMPORTS_ARE_NOT_DUPLICATED = r"""
+# Depending on the importlib machinery and _distutils_hack, some imports are
+# duplicated resulting in different module objects being loaded, which prevents
+# patches as shown in #3042.
+# This script provides a way of verifying if this duplication is happening.
+
+from distutils import cmd
+import distutils.command.sdist as sdist
+
+# import last to prevent caching
+from distutils import {imported_module}
+
+for mod in (cmd, sdist):
+    assert mod.{imported_module} == {imported_module}, (
+        f"\n{{mod.dir_util}}\n!=\n{{{imported_module}}}"
+    )
+
+print("success")
+"""
+
+
+@pytest.mark.parametrize(
+    "distutils_version, imported_module",
+    [
+        ("stdlib", "dir_util"),
+        ("stdlib", "file_util"),
+        ("stdlib", "archive_util"),
+        ("local", "dir_util"),
+        ("local", "file_util"),
+        ("local", "archive_util"),
+    ]
+)
+def test_modules_are_not_duplicated_on_import(
+        distutils_version, imported_module, tmpdir_cwd, venv
+):
+    env = dict(SETUPTOOLS_USE_DISTUTILS=distutils_version)
+    script = ENSURE_IMPORTS_ARE_NOT_DUPLICATED.format(imported_module=imported_module)
+    cmd = ['python', '-c', script]
+    output = popen_text(venv.run)(cmd, env=win_sr(env)).strip()
+    assert output == "success"
+
+
+ENSURE_LOG_IMPORT_IS_NOT_DUPLICATED = r"""
+# Similar to ENSURE_IMPORTS_ARE_NOT_DUPLICATED
+import distutils.dist as dist
+from distutils import log
+
+assert dist.log == log, (
+    f"\n{dist.log}\n!=\n{log}"
+)
+
+print("success")
+"""
+
+
+@pytest.mark.parametrize("distutils_version", "local stdlib".split())
+def test_log_module_is_not_duplicated_on_import(distutils_version, tmpdir_cwd, venv):
+    env = dict(SETUPTOOLS_USE_DISTUTILS=distutils_version)
+    cmd = ['python', '-c', ENSURE_LOG_IMPORT_IS_NOT_DUPLICATED]
+    output = popen_text(venv.run)(cmd, env=win_sr(env)).strip()
+    assert output == "success"