From: JinWang An Date: Mon, 27 Mar 2023 08:02:35 +0000 (+0900) Subject: Imported Upstream version 57.4.0 X-Git-Tag: upstream/57.4.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=785c7b89c304cec9872a5e8c0317006a6c265d04;p=platform%2Fupstream%2Fpython-setuptools.git Imported Upstream version 57.4.0 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 6c93847..53c5152 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 57.3.0 +current_version = 57.4.0 commit = True tag = True diff --git a/CHANGES.rst b/CHANGES.rst index fde2da1..d995138 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,12 @@ +v57.4.0 +------- + + +Changes +^^^^^^^ +* #2722: Added support for ``SETUPTOOLS_EXT_SUFFIX`` environment variable to override the suffix normally detected from the ``sysconfig`` module. + + v57.3.0 ------- diff --git a/setup.cfg b/setup.cfg index ef6d763..790b5c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ license_files = LICENSE name = setuptools -version = 57.3.0 +version = 57.4.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/command/build_ext.py b/setuptools/command/build_ext.py index 03a72b4..c59eff8 100644 --- a/setuptools/command/build_ext.py +++ b/setuptools/command/build_ext.py @@ -104,14 +104,20 @@ class build_ext(_build_ext): self.write_stub(package_dir or os.curdir, ext, True) def get_ext_filename(self, fullname): - filename = _build_ext.get_ext_filename(self, fullname) + so_ext = os.getenv('SETUPTOOLS_EXT_SUFFIX') + if so_ext: + filename = os.path.join(*fullname.split('.')) + so_ext + else: + filename = _build_ext.get_ext_filename(self, fullname) + so_ext = get_config_var('EXT_SUFFIX') + if fullname in self.ext_map: ext = self.ext_map[fullname] use_abi3 = getattr(ext, 'py_limited_api') and get_abi3_suffix() if use_abi3: - so_ext = get_config_var('EXT_SUFFIX') filename = filename[:-len(so_ext)] - filename = filename + get_abi3_suffix() + so_ext = get_abi3_suffix() + filename = filename + so_ext if isinstance(ext, Library): fn, ext = os.path.splitext(filename) return self.shlib_compiler.library_filename(fn, libtype) diff --git a/setuptools/tests/test_build_ext.py b/setuptools/tests/test_build_ext.py index b6deebe..3177a2c 100644 --- a/setuptools/tests/test_build_ext.py +++ b/setuptools/tests/test_build_ext.py @@ -1,3 +1,4 @@ +import os import sys import distutils.command.build_ext as orig from distutils.sysconfig import get_config_var @@ -12,6 +13,9 @@ from . import environment from .textwrap import DALS +IS_PYPY = '__pypy__' in sys.builtin_module_names + + class TestBuildExt: def test_get_ext_filename(self): """ @@ -47,6 +51,38 @@ class TestBuildExt: else: assert 'abi3' in res + def test_ext_suffix_override(self): + """ + SETUPTOOLS_EXT_SUFFIX variable always overrides + default extension options. + """ + dist = Distribution() + cmd = build_ext(dist) + cmd.ext_map['for_abi3'] = ext = Extension( + 'for_abi3', + ['s.c'], + # Override shouldn't affect abi3 modules + py_limited_api=True, + ) + # Mock value needed to pass tests + ext._links_to_dynamic = False + + if not IS_PYPY: + expect = cmd.get_ext_filename('for_abi3') + else: + # PyPy builds do not use ABI3 tag, so they will + # also get the overridden suffix. + expect = 'for_abi3.test-suffix' + + try: + os.environ['SETUPTOOLS_EXT_SUFFIX'] = '.test-suffix' + res = cmd.get_ext_filename('normal') + assert 'normal.test-suffix' == res + res = cmd.get_ext_filename('for_abi3') + assert expect == res + finally: + del os.environ['SETUPTOOLS_EXT_SUFFIX'] + def test_build_ext_config_handling(tmpdir_cwd): files = {