From 8688fe6800daa665a70056d687938818c987bb28 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 30 Dec 2020 07:08:52 +0900 Subject: [PATCH] Imported Upstream version 50.2.0 --- .bumpversion.cfg | 2 +- CHANGES.rst | 10 ++++++++++ _distutils_hack/__init__.py | 17 +++++++++++++++-- setup.cfg | 2 +- setuptools/command/bdist_rpm.py | 14 +------------- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 34b34fd..0bb91b4 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 50.1.0 +current_version = 50.2.0 commit = True tag = True diff --git a/CHANGES.rst b/CHANGES.rst index a00d827..9962f63 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,13 @@ +v50.2.0 +------- + +* #2355: When pip is imported as part of a build, leave distutils patched. +* #2380: There are some setuptools specific changes in the + `setuptools.command.bdist_rpm` module that are no longer needed, because + they are part of the `bdist_rpm` module in distutils in Python + 3.5.0. Therefore, code was removed from `setuptools.command.bdist_rpm`. + + v50.1.0 ------- diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 3325817..c31edfe 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -20,8 +20,8 @@ def warn_distutils_present(): "also replaces the `distutils` module in `sys.modules`. This may lead " "to undesirable behaviors or errors. To avoid these issues, avoid " "using distutils directly, ensure that setuptools is installed in the " - "traditional way (e.g. not an editable install), and/or make sure that " - "setuptools is always imported before distutils.") + "traditional way (e.g. not an editable install), and/or make sure " + "that setuptools is always imported before distutils.") def clear_distutils(): @@ -92,9 +92,22 @@ class DistutilsMetaFinder: Ensure stdlib distutils when running under pip. See pypa/pip#8761 for rationale. """ + if self.pip_imported_during_build(): + return clear_distutils() self.spec_for_distutils = lambda: None + @staticmethod + def pip_imported_during_build(): + """ + Detect if pip is being imported in a build script. Ref #2355. + """ + import traceback + return any( + frame.f_globals['__file__'].endswith('setup.py') + for frame, line in traceback.walk_stack(None) + ) + DISTUTILS_FINDER = DistutilsMetaFinder() diff --git a/setup.cfg b/setup.cfg index 692eb1f..d35e5fa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ formats = zip [metadata] name = setuptools -version = 50.1.0 +version = 50.2.0 description = Easily download, build, install, upgrade, and uninstall Python packages author = Python Packaging Authority author_email = distutils-sig@python.org diff --git a/setuptools/command/bdist_rpm.py b/setuptools/command/bdist_rpm.py index 7073092..0eb1b9c 100644 --- a/setuptools/command/bdist_rpm.py +++ b/setuptools/command/bdist_rpm.py @@ -8,8 +8,6 @@ class bdist_rpm(orig.bdist_rpm): 1. Run egg_info to ensure the name and version are properly calculated. 2. Always run 'install' using --single-version-externally-managed to disable eggs in RPM distributions. - 3. Replace dash with underscore in the version numbers for better RPM - compatibility. """ def run(self): @@ -19,25 +17,15 @@ class bdist_rpm(orig.bdist_rpm): orig.bdist_rpm.run(self) def _make_spec_file(self): - version = self.distribution.get_version() - rpmversion = version.replace('-', '_') spec = orig.bdist_rpm._make_spec_file(self) - line23 = '%define version ' + version - line24 = '%define version ' + rpmversion spec = [ line.replace( - "Source0: %{name}-%{version}.tar", - "Source0: %{name}-%{unmangled_version}.tar" - ).replace( "setup.py install ", "setup.py install --single-version-externally-managed " ).replace( "%setup", "%setup -n %{name}-%{unmangled_version}" - ).replace(line23, line24) + ) for line in spec ] - insert_loc = spec.index(line24) + 1 - unmangled_version = "%define unmangled_version " + version - spec.insert(insert_loc, unmangled_version) return spec -- 2.34.1