From: JinWang An Date: Mon, 27 Mar 2023 08:02:56 +0000 (+0900) Subject: Imported Upstream version 65.2.0 X-Git-Tag: upstream/65.2.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=296802b5b5e0e9a2e7b375d1b218923b90be67cd;p=platform%2Fupstream%2Fpython-setuptools.git Imported Upstream version 65.2.0 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 6df865b..cf3c02a 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 65.1.1 +current_version = 65.2.0 commit = True tag = True diff --git a/CHANGES.rst b/CHANGES.rst index 448c6e8..09a7c1b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,12 @@ +v65.2.0 +------- + + +Changes +^^^^^^^ +* #3553: Sync with pypa/distutils@22b9bcf, including fixed cross-compiling support and removing deprecation warning per pypa/distutils#169. + + v65.1.1 ------- diff --git a/docs/userguide/extension.rst b/docs/userguide/extension.rst index b49816b..6f8cbbb 100644 --- a/docs/userguide/extension.rst +++ b/docs/userguide/extension.rst @@ -57,7 +57,7 @@ a ``foo`` command, you might add something like this to your project: foo = mypackage.some_module:foo Assuming, of course, that the ``foo`` class in ``mypackage.some_module`` is -a ``setuptools.Command`` subclass (documented bellow). +a ``setuptools.Command`` subclass (documented below). Once a project containing such entry points has been activated on ``sys.path``, (e.g. by running ``pip install``) the command(s) will be available to any diff --git a/pytest.ini b/pytest.ini index 892714b..50a7971 100644 --- a/pytest.ini +++ b/pytest.ini @@ -60,7 +60,7 @@ filterwarnings= ignore:Setuptools is replacing distutils # suppress warnings in deprecated msvc compilers - ignore:msvc9?compiler is deprecated + ignore:(bcpp|msvc9?)compiler is deprecated ignore:Support for .* in .pyproject.toml. is still .beta. ignore::setuptools.command.editable_wheel.InformationOnly diff --git a/setup.cfg b/setup.cfg index ca95d7d..16fe951 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = setuptools -version = 65.1.1 +version = 65.2.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/_msvccompiler.py b/setuptools/_distutils/_msvccompiler.py index ade8005..729c2dd 100644 --- a/setuptools/_distutils/_msvccompiler.py +++ b/setuptools/_distutils/_msvccompiler.py @@ -318,38 +318,16 @@ class MSVCCompiler(CCompiler): # -- Worker methods ------------------------------------------------ - def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): - ext_map = { - **{ext: self.obj_extension for ext in self.src_extensions}, + @property + def out_extensions(self): + return { + **super().out_extensions, **{ ext: self.res_extension for ext in self._rc_extensions + self._mc_extensions }, } - output_dir = output_dir or '' - - def make_out_path(p): - base, ext = os.path.splitext(p) - if strip_dir: - base = os.path.basename(base) - else: - _, base = os.path.splitdrive(base) - if base.startswith((os.path.sep, os.path.altsep)): - base = base[1:] - try: - # XXX: This may produce absurdly long paths. We should check - # the length of the result and trim base until we fit within - # 260 characters. - return os.path.join(output_dir, base + ext_map[ext]) - except LookupError: - # Better to raise an exception instead of silently continuing - # and later complain about sources and targets having - # different lengths - raise CompileError(f"Don't know how to compile {p}") - - return list(map(make_out_path, source_filenames)) - def compile( # noqa: C901 self, sources, diff --git a/setuptools/_distutils/bcppcompiler.py b/setuptools/_distutils/bcppcompiler.py index ee033ed..80b6bd8 100644 --- a/setuptools/_distutils/bcppcompiler.py +++ b/setuptools/_distutils/bcppcompiler.py @@ -13,6 +13,8 @@ for the Borland C++ compiler. import os +import warnings + from distutils.errors import ( DistutilsExecError, CompileError, @@ -26,6 +28,14 @@ from distutils.dep_util import newer from distutils import log +warnings.warn( + "bcppcompiler is deprecated and slated to be removed " + "in the future. Please discontinue use or file an issue " + "with pypa/distutils describing your use case.", + DeprecationWarning, +) + + class BCPPCompiler(CCompiler): """Concrete class that implements an interface to the Borland C/C++ compiler, as defined by the CCompiler abstract class. diff --git a/setuptools/_distutils/ccompiler.py b/setuptools/_distutils/ccompiler.py index c8d3b24..97551c9 100644 --- a/setuptools/_distutils/ccompiler.py +++ b/setuptools/_distutils/ccompiler.py @@ -6,7 +6,6 @@ for the Distutils compiler abstraction model.""" import sys import os import re -import warnings from distutils.errors import ( CompileError, @@ -924,37 +923,39 @@ int main (int argc, char **argv) { def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): if output_dir is None: output_dir = '' - obj_names = [] - for src_name in source_filenames: - base, ext = os.path.splitext(src_name) - base = self._mangle_base(base) - if ext not in self.src_extensions: - raise UnknownFileError( - "unknown file type '{}' (from '{}')".format(ext, src_name) - ) - if strip_dir: - base = os.path.basename(base) - obj_names.append(os.path.join(output_dir, base + self.obj_extension)) - return obj_names + return list( + self._make_out_path(output_dir, strip_dir, src_name) + for src_name in source_filenames + ) + + @property + def out_extensions(self): + return dict.fromkeys(self.src_extensions, self.obj_extension) + + def _make_out_path(self, output_dir, strip_dir, src_name): + base, ext = os.path.splitext(src_name) + base = self._make_relative(base) + try: + new_ext = self.out_extensions[ext] + except LookupError: + raise UnknownFileError( + "unknown file type '{}' (from '{}')".format(ext, src_name) + ) + if strip_dir: + base = os.path.basename(base) + return os.path.join(output_dir, base + new_ext) @staticmethod - def _mangle_base(base): + def _make_relative(base): """ - For unknown reasons, absolute paths are mangled. + In order to ensure that a filename always honors the + indicated output_dir, make sure it's relative. + Ref python/cpython#37775. """ # Chop off the drive no_drive = os.path.splitdrive(base)[1] # If abs, chop off leading / - rel = no_drive[os.path.isabs(no_drive) :] - if rel != base: - msg = ( - f"Absolute path {base!r} is being replaced with a " - f"relative path {rel!r} for outputs. This behavior is " - "deprecated. If this behavior is desired, please " - "comment in pypa/distutils#169." - ) - warnings.warn(msg, DeprecationWarning) - return rel + return no_drive[os.path.isabs(no_drive) :] def shared_object_filename(self, basename, strip_dir=0, output_dir=''): assert output_dir is not None diff --git a/setuptools/_distutils/cygwinccompiler.py b/setuptools/_distutils/cygwinccompiler.py index 63910f2..2c4da5b 100644 --- a/setuptools/_distutils/cygwinccompiler.py +++ b/setuptools/_distutils/cygwinccompiler.py @@ -20,7 +20,6 @@ from distutils.errors import ( DistutilsPlatformError, CCompilerError, CompileError, - UnknownFileError, ) from distutils.version import LooseVersion, suppress_known_deprecation @@ -242,28 +241,20 @@ class CygwinCCompiler(UnixCCompiler): # -- Miscellaneous methods ----------------------------------------- - def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): - """Adds supports for rc and res files.""" - if output_dir is None: - output_dir = '' - obj_names = [] - for src_name in source_filenames: - # use normcase to make sure '.rc' is really '.rc' and not '.RC' - base, ext = os.path.splitext(os.path.normcase(src_name)) - if ext not in (self.src_extensions + ['.rc', '.res']): - raise UnknownFileError( - "unknown file type '{}' (from '{}')".format(ext, src_name) - ) - if strip_dir: - base = os.path.basename(base) - if ext in ('.res', '.rc'): - # these need to be compiled to object files - obj_names.append( - os.path.join(output_dir, base + ext + self.obj_extension) - ) - else: - obj_names.append(os.path.join(output_dir, base + self.obj_extension)) - return obj_names + def _make_out_path(self, output_dir, strip_dir, src_name): + # use normcase to make sure '.rc' is really '.rc' and not '.RC' + norm_src_name = os.path.normcase(src_name) + return super()._make_out_path(output_dir, strip_dir, norm_src_name) + + @property + def out_extensions(self): + """ + Add support for rc and res files. + """ + return { + **super().out_extensions, + **{ext: ext + self.obj_extension for ext in ('.res', '.rc')}, + } # the same as cygwin plus some additional parameters diff --git a/setuptools/_distutils/sysconfig.py b/setuptools/_distutils/sysconfig.py index aae9c1b..3dd8185 100644 --- a/setuptools/_distutils/sysconfig.py +++ b/setuptools/_distutils/sysconfig.py @@ -164,10 +164,19 @@ def _get_python_inc_from_config(plat_specific, spec_prefix): the host platform Python installation, while the current Python executable is from the build platform installation. + + >>> monkeypatch = getfixture('monkeypatch') + >>> gpifc = _get_python_inc_from_config + >>> monkeypatch.setitem(gpifc.__globals__, 'get_config_var', str.lower) + >>> gpifc(False, '/usr/bin/') + >>> gpifc(False, '') + >>> gpifc(False, None) + 'includepy' + >>> gpifc(True, None) + 'confincludepy' """ - if not spec_prefix: - return - return get_config_var('CONF' * plat_specific + 'INCLUDEPY') + if spec_prefix is None: + return get_config_var('CONF' * plat_specific + 'INCLUDEPY') def _get_python_inc_posix_prefix(prefix):