From 1cfcc07eb23827184287cc635f9b36bcd5ba781b Mon Sep 17 00:00:00 2001 From: JinWang An Date: Mon, 27 Mar 2023 17:02:36 +0900 Subject: [PATCH] Imported Upstream version 58.1.0 --- .bumpversion.cfg | 2 +- .github/workflows/main.yml | 2 +- .gitignore | 1 + CHANGES.rst | 9 +++++++ changelog.d/1988-change.rst | 2 ++ changelog.d/2785-change.rst | 2 ++ docs/userguide/entry_point.rst | 2 +- docs/userguide/quickstart.rst | 2 +- setup.cfg | 2 +- setuptools/_distutils/command/build_ext.py | 2 +- setuptools/_distutils/command/install.py | 1 + setuptools/_distutils/sysconfig.py | 23 +++++++++------- setuptools/_distutils/tests/test_sysconfig.py | 17 +++++++++++- .../_distutils/tests/test_unixccompiler.py | 16 ++++++++--- setuptools/_distutils/unixccompiler.py | 4 +-- setuptools/command/bdist_rpm.py | 9 +++++++ setuptools/command/easy_install.py | 2 +- setuptools/tests/test_bdist_deprecations.py | 27 +++++++++++++++++++ setuptools/tests/test_setopt.py | 9 ++++--- 19 files changed, 108 insertions(+), 26 deletions(-) create mode 100644 changelog.d/1988-change.rst create mode 100644 changelog.d/2785-change.rst create mode 100644 setuptools/tests/test_bdist_deprecations.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 4871a5e..c7fab7f 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 58.0.4 +current_version = 58.1.0 commit = True tag = True diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6af3ac7..b348056 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,10 +7,10 @@ jobs: strategy: matrix: python: + - pypy3 - 3.6 - 3.9 - 3.10.0-alpha - 3.10.99 - - pypy3 platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/.gitignore b/.gitignore index 90ae805..dc14826 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ docs/build include lib distribute.egg-info +foo.egg-info setuptools.egg-info .coverage .eggs diff --git a/CHANGES.rst b/CHANGES.rst index dab7400..a77a8f1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,12 @@ +v58.1.0 +------- + + +Changes +^^^^^^^ +* #2796: Merge with pypa/distutils@02e9f65ab0 + + v58.0.4 ------- diff --git a/changelog.d/1988-change.rst b/changelog.d/1988-change.rst new file mode 100644 index 0000000..4f10463 --- /dev/null +++ b/changelog.d/1988-change.rst @@ -0,0 +1,2 @@ +Deprecated the ``bdist_rpm`` command. Binary packages should be built as wheels instead. +-- by :user:`hugovk` diff --git a/changelog.d/2785-change.rst b/changelog.d/2785-change.rst new file mode 100644 index 0000000..7e9631b --- /dev/null +++ b/changelog.d/2785-change.rst @@ -0,0 +1,2 @@ +Replace confirparser's readfp with read_file, deprecated since Python 3.2. +-- by :user:`hugovk` diff --git a/docs/userguide/entry_point.rst b/docs/userguide/entry_point.rst index c92ccf7..21edc69 100644 --- a/docs/userguide/entry_point.rst +++ b/docs/userguide/entry_point.rst @@ -141,7 +141,7 @@ Dependency Management ===================== Some entry points may require additional dependencies to properly function. -For such an entry point, declare in square brakets any number of dependency +For such an entry point, declare in square brackets any number of dependency ``extras`` following the entry point definition. Such entry points will only be viable if their extras were declared and installed. See the :doc:`guide on dependencies management ` for diff --git a/docs/userguide/quickstart.rst b/docs/userguide/quickstart.rst index 1bd04de..bcb282e 100644 --- a/docs/userguide/quickstart.rst +++ b/docs/userguide/quickstart.rst @@ -201,7 +201,7 @@ Then:: pip install --editable . This creates a link file in your interpreter site package directory which -associate with your source code. For more information, see: (WIP) +associate with your source code. For more information, see :doc:`development_mode`. Uploading your package to PyPI diff --git a/setup.cfg b/setup.cfg index fb25e6c..0bee3cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = setuptools -version = 58.0.4 +version = 58.1.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/command/build_ext.py b/setuptools/_distutils/command/build_ext.py index f7ab32c..22628ba 100644 --- a/setuptools/_distutils/command/build_ext.py +++ b/setuptools/_distutils/command/build_ext.py @@ -220,7 +220,7 @@ class build_ext(Command): # For extensions under Cygwin, Python's library directory must be # appended to library_dirs if sys.platform[:6] == 'cygwin': - if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): + if not sysconfig.python_build: # building third party extensions self.library_dirs.append(os.path.join(sys.prefix, "lib", "python" + get_python_version(), diff --git a/setuptools/_distutils/command/install.py b/setuptools/_distutils/command/install.py index 400fb45..866e2d5 100644 --- a/setuptools/_distutils/command/install.py +++ b/setuptools/_distutils/command/install.py @@ -470,6 +470,7 @@ class install(Command): """Sets the install directories by applying the install schemes.""" # it's the caller's problem if they supply a bad name! if (hasattr(sys, 'pypy_version_info') and + sys.version_info < (3, 8) and not name.endswith(('_user', '_home'))): if os.name == 'nt': name = 'pypy_nt' diff --git a/setuptools/_distutils/sysconfig.py b/setuptools/_distutils/sysconfig.py index 879b698..8832b3e 100644 --- a/setuptools/_distutils/sysconfig.py +++ b/setuptools/_distutils/sysconfig.py @@ -99,9 +99,9 @@ def get_python_inc(plat_specific=0, prefix=None): """ if prefix is None: prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX - if IS_PYPY: - return os.path.join(prefix, 'include') - elif os.name == "posix": + if os.name == "posix": + if IS_PYPY and sys.version_info < (3, 8): + return os.path.join(prefix, 'include') if python_build: # Assume the executable is in the build directory. The # pyconfig.h file should be in the same directory. Since @@ -113,7 +113,8 @@ def get_python_inc(plat_specific=0, prefix=None): else: incdir = os.path.join(get_config_var('srcdir'), 'Include') return os.path.normpath(incdir) - python_dir = 'python' + get_python_version() + build_flags + implementation = 'pypy' if IS_PYPY else 'python' + python_dir = implementation + get_python_version() + build_flags return os.path.join(prefix, "include", python_dir) elif os.name == "nt": if python_build: @@ -142,7 +143,8 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): If 'prefix' is supplied, use it instead of sys.base_prefix or sys.base_exec_prefix -- i.e., ignore 'plat_specific'. """ - if IS_PYPY: + + if IS_PYPY and sys.version_info < (3, 8): # PyPy-specific schema if prefix is None: prefix = PREFIX @@ -164,8 +166,9 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): else: # Pure Python libdir = "lib" + implementation = 'pypy' if IS_PYPY else 'python' libpython = os.path.join(prefix, libdir, - "python" + get_python_version()) + implementation + get_python_version()) if standard_lib: return libpython else: @@ -211,10 +214,9 @@ def customize_compiler(compiler): if 'CC' in os.environ: newcc = os.environ['CC'] - if (sys.platform == 'darwin' - and 'LDSHARED' not in os.environ + if('LDSHARED' not in os.environ and ldshared.startswith(cc)): - # On OS X, if CC is overridden, use that as the default + # If CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc):] cc = newcc @@ -252,6 +254,9 @@ def customize_compiler(compiler): linker_exe=cc, archiver=archiver) + if 'RANLIB' in os.environ and compiler.executables.get('ranlib', None): + compiler.set_executables(ranlib=os.environ['RANLIB']) + compiler.shared_lib_extension = shlib_suffix diff --git a/setuptools/_distutils/tests/test_sysconfig.py b/setuptools/_distutils/tests/test_sysconfig.py index c757194..80cd159 100644 --- a/setuptools/_distutils/tests/test_sysconfig.py +++ b/setuptools/_distutils/tests/test_sysconfig.py @@ -9,6 +9,7 @@ import unittest from distutils import sysconfig from distutils.ccompiler import get_default_compiler +from distutils.unixccompiler import UnixCCompiler from distutils.tests import support from test.support import run_unittest, swap_item @@ -84,9 +85,14 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): # make sure AR gets caught class compiler: compiler_type = 'unix' + executables = UnixCCompiler.executables + + def __init__(self): + self.exes = {} def set_executables(self, **kw): - self.exes = kw + for k, v in kw.items(): + self.exes[k] = v sysconfig_vars = { 'AR': 'sc_ar', @@ -125,6 +131,7 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): os.environ['ARFLAGS'] = '--env-arflags' os.environ['CFLAGS'] = '--env-cflags' os.environ['CPPFLAGS'] = '--env-cppflags' + os.environ['RANLIB'] = 'env_ranlib' comp = self.customize_compiler() self.assertEqual(comp.exes['archiver'], @@ -145,6 +152,12 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): ' --env-cppflags')) self.assertEqual(comp.shared_lib_extension, 'sc_shutil_suffix') + if sys.platform == "darwin": + self.assertEqual(comp.exes['ranlib'], + 'env_ranlib') + else: + self.assertTrue('ranlib' not in comp.exes) + del os.environ['AR'] del os.environ['CC'] del os.environ['CPP'] @@ -154,6 +167,7 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): del os.environ['ARFLAGS'] del os.environ['CFLAGS'] del os.environ['CPPFLAGS'] + del os.environ['RANLIB'] comp = self.customize_compiler() self.assertEqual(comp.exes['archiver'], @@ -171,6 +185,7 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): self.assertEqual(comp.exes['linker_so'], 'sc_ldshared') self.assertEqual(comp.shared_lib_extension, 'sc_shutil_suffix') + self.assertTrue('ranlib' not in comp.exes) def test_parse_makefile_base(self): self.makefile = TESTFN diff --git a/setuptools/_distutils/tests/test_unixccompiler.py b/setuptools/_distutils/tests/test_unixccompiler.py index ebd7c16..1008f58 100644 --- a/setuptools/_distutils/tests/test_unixccompiler.py +++ b/setuptools/_distutils/tests/test_unixccompiler.py @@ -140,6 +140,14 @@ class UnixCCompilerTestCase(unittest.TestCase): sysconfig.get_config_var = gcv self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo') + def gcv(v): + if v == 'CC': + return 'gcc -pthread -B /bar' + elif v == 'GNULD': + return 'yes' + sysconfig.get_config_var = gcv + self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo') + # GCC non-GNULD sys.platform = 'bar' def gcv(v): @@ -181,8 +189,8 @@ class UnixCCompilerTestCase(unittest.TestCase): sysconfig.get_config_var = gcv self.assertEqual(self.cc.rpath_foo(), '-R/foo') - @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for OS X') - def test_osx_cc_overrides_ldshared(self): + @unittest.skipIf(sys.platform == 'win32', "can't test on Windows") + def test_cc_overrides_ldshared(self): # Issue #18080: # ensure that setting CC env variable also changes default linker def gcv(v): @@ -202,8 +210,8 @@ class UnixCCompilerTestCase(unittest.TestCase): sysconfig.customize_compiler(self.cc) self.assertEqual(self.cc.linker_so[0], 'my_cc') - @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for OS X') - def test_osx_explicit_ldshared(self): + @unittest.skipIf(sys.platform == 'win32', "can't test on Windows") + def test_explicit_ldshared(self): # Issue #18080: # ensure that setting CC env variable does not change # explicit LDSHARED setting for linker diff --git a/setuptools/_distutils/unixccompiler.py b/setuptools/_distutils/unixccompiler.py index f51977a..349cc16 100644 --- a/setuptools/_distutils/unixccompiler.py +++ b/setuptools/_distutils/unixccompiler.py @@ -13,7 +13,7 @@ the "typical" Unix-style command-line C compiler: * link shared library handled by 'cc -shared' """ -import os, sys, re +import os, sys, re, shlex from distutils import sysconfig from distutils.dep_util import newer @@ -231,7 +231,7 @@ class UnixCCompiler(CCompiler): # this time, there's no way to determine this information from # the configuration data stored in the Python installation, so # we use this hack. - compiler = os.path.basename(sysconfig.get_config_var("CC")) + compiler = os.path.basename(shlex.split(sysconfig.get_config_var("CC"))[0]) if sys.platform[:6] == "darwin": from distutils.util import get_macosx_target_ver, split_version macosx_target_ver = get_macosx_target_ver() diff --git a/setuptools/command/bdist_rpm.py b/setuptools/command/bdist_rpm.py index 0eb1b9c..98bf5de 100644 --- a/setuptools/command/bdist_rpm.py +++ b/setuptools/command/bdist_rpm.py @@ -1,4 +1,7 @@ import distutils.command.bdist_rpm as orig +import warnings + +from setuptools import SetuptoolsDeprecationWarning class bdist_rpm(orig.bdist_rpm): @@ -11,6 +14,12 @@ class bdist_rpm(orig.bdist_rpm): """ def run(self): + warnings.warn( + "bdist_rpm is deprecated and will be removed in a future " + "version. Use bdist_wheel (wheel packages) instead.", + SetuptoolsDeprecationWarning, + ) + # ensure distro name is up-to-date self.run_command('egg_info') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 43bd295..5e0f97c 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1508,7 +1508,7 @@ def extract_wininst_cfg(dist_filename): # Now the config is in bytes, but for RawConfigParser, it should # be text, so decode it. config = config.decode(sys.getfilesystemencoding()) - cfg.readfp(io.StringIO(config)) + cfg.read_file(io.StringIO(config)) except configparser.Error: return None if not cfg.has_section('metadata') or not cfg.has_section('Setup'): diff --git a/setuptools/tests/test_bdist_deprecations.py b/setuptools/tests/test_bdist_deprecations.py new file mode 100644 index 0000000..28482fd --- /dev/null +++ b/setuptools/tests/test_bdist_deprecations.py @@ -0,0 +1,27 @@ +"""develop tests +""" +import mock +import sys + +import pytest + +from setuptools.dist import Distribution +from setuptools import SetuptoolsDeprecationWarning + + +@pytest.mark.skipif(sys.platform == 'win32', reason='non-Windows only') +@mock.patch('distutils.command.bdist_rpm.bdist_rpm') +def test_bdist_rpm_warning(distutils_cmd): + dist = Distribution( + dict( + script_name='setup.py', + script_args=['bdist_rpm'], + name='foo', + py_modules=['hi'], + ) + ) + dist.parse_command_line() + with pytest.warns(SetuptoolsDeprecationWarning): + dist.run_commands() + + distutils_cmd.run.assert_called_once() diff --git a/setuptools/tests/test_setopt.py b/setuptools/tests/test_setopt.py index 61dc68b..3600863 100644 --- a/setuptools/tests/test_setopt.py +++ b/setuptools/tests/test_setopt.py @@ -31,8 +31,11 @@ class TestEdit: def test_case_retained(self, tmpdir): """ + When editing a file, case of keys should be retained. """ config = tmpdir.join('setup.cfg') - self.write_text(str(config), '[names]\nJARACO=jaraco') - setopt.edit_config(str(config), dict()) - assert 'JARACO' in config.read_text(encoding='ascii') + self.write_text(str(config), '[names]\nFoO=bAr') + setopt.edit_config(str(config), dict(names=dict(oTher='yes'))) + actual = config.read_text(encoding='ascii') + assert 'FoO' in actual + assert 'oTher' in actual -- 2.34.1