From: JinWang An Date: Mon, 27 Mar 2023 08:02:46 +0000 (+0900) Subject: Imported Upstream version 60.9.2 X-Git-Tag: upstream/60.9.2^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8586a024af98b7577f9953b2480b7d037c080f29;p=platform%2Fupstream%2Fpython-setuptools.git Imported Upstream version 60.9.2 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 7f5864f..e556292 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 60.9.1 +current_version = 60.9.2 commit = True tag = True diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c985f85..5a8d510 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/CHANGES.rst b/CHANGES.rst index efe34d3..3899933 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 ------- diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index c6f7de6..605a6ed 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -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): diff --git a/setup.cfg b/setup.cfg index 555038c..dc921fb 100644 --- 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 diff --git a/setuptools/tests/test_distutils_adoption.py b/setuptools/tests/test_distutils_adoption.py index 366f292..df8f354 100644 --- a/setuptools/tests/test_distutils_adoption.py +++ b/setuptools/tests/test_distutils_adoption.py @@ -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"