Imported Upstream version 67.2.0 upstream/67.2.0
authorJinWang An <jinwang.an@samsung.com>
Mon, 27 Mar 2023 08:03:00 +0000 (17:03 +0900)
committerJinWang An <jinwang.an@samsung.com>
Mon, 27 Mar 2023 08:03:00 +0000 (17:03 +0900)
56 files changed:
.bumpversion.cfg
CHANGES.rst
setup.cfg
setuptools/_distutils/_collections.py
setuptools/_distutils/_msvccompiler.py
setuptools/_distutils/bcppcompiler.py
setuptools/_distutils/ccompiler.py
setuptools/_distutils/cmd.py
setuptools/_distutils/command/bdist.py
setuptools/_distutils/command/bdist_dumb.py
setuptools/_distutils/command/bdist_rpm.py
setuptools/_distutils/command/build.py
setuptools/_distutils/command/build_clib.py
setuptools/_distutils/command/build_ext.py
setuptools/_distutils/command/build_py.py
setuptools/_distutils/command/build_scripts.py
setuptools/_distutils/command/clean.py
setuptools/_distutils/command/config.py
setuptools/_distutils/command/install.py
setuptools/_distutils/command/install_data.py
setuptools/_distutils/command/install_headers.py
setuptools/_distutils/command/install_lib.py
setuptools/_distutils/command/install_scripts.py
setuptools/_distutils/command/register.py
setuptools/_distutils/command/sdist.py
setuptools/_distutils/command/upload.py
setuptools/_distutils/core.py
setuptools/_distutils/cygwinccompiler.py
setuptools/_distutils/dir_util.py
setuptools/_distutils/dist.py
setuptools/_distutils/fancy_getopt.py
setuptools/_distutils/file_util.py
setuptools/_distutils/msvc9compiler.py
setuptools/_distutils/msvccompiler.py
setuptools/_distutils/sysconfig.py
setuptools/_distutils/tests/test_archive_util.py
setuptools/_distutils/tests/test_bdist_dumb.py
setuptools/_distutils/tests/test_build_clib.py
setuptools/_distutils/tests/test_build_ext.py
setuptools/_distutils/tests/test_ccompiler.py
setuptools/_distutils/tests/test_check.py
setuptools/_distutils/tests/test_cmd.py
setuptools/_distutils/tests/test_cygwinccompiler.py
setuptools/_distutils/tests/test_dep_util.py
setuptools/_distutils/tests/test_dir_util.py
setuptools/_distutils/tests/test_dist.py
setuptools/_distutils/tests/test_install.py
setuptools/_distutils/tests/test_register.py
setuptools/_distutils/tests/test_sdist.py
setuptools/_distutils/tests/test_sysconfig.py
setuptools/_distutils/tests/test_unixccompiler.py
setuptools/_distutils/tests/test_upload.py
setuptools/_distutils/text_file.py
setuptools/_distutils/unixccompiler.py
setuptools/_distutils/util.py
setuptools/_distutils/version.py

index 2c9f7bf81675423baab9d4038d81a2003833bde0..126aa1596d9a27b9be33535e442c3cbbf3647bb6 100644 (file)
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 67.1.0
+current_version = 67.2.0
 commit = True
 tag = True
 
index 245c32faa571fe915a99086fcda586259d147cd6..428b833946b508e698e23aac6ceca7c79e5450d3 100644 (file)
@@ -1,3 +1,12 @@
+v67.2.0
+-------
+
+
+Changes
+^^^^^^^
+* #3809: Merge with distutils@8c3c3d29, including fix for ``sysconfig.get_python_inc()`` (pypa/distutils#178), fix for segfault on MinGW (pypa/distutils#196), and better ``has_function`` support (pypa/distutils#195).
+
+
 v67.1.0
 -------
 
index 43816111442417570825fc14c13b7d6b90b39a49..41ca2f73d978766779b8b669f1025c1384d6945a 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = setuptools
-version = 67.1.0
+version = 67.2.0
 author = Python Packaging Authority
 author_email = distutils-sig@python.org
 description = Easily download, build, install, upgrade, and uninstall Python packages
index 02556614a5049d230a9bc9bf6a0ae8670bb338fc..5ad21cc7c909836931023a6feac195338825a4ea 100644 (file)
@@ -185,7 +185,7 @@ class RangeMap(dict):
         return (sorted_keys[RangeMap.first_item], sorted_keys[RangeMap.last_item])
 
     # some special values for the RangeMap
-    undefined_value = type(str('RangeValueUndefined'), (), {})()
+    undefined_value = type('RangeValueUndefined', (), {})()
 
     class Item(int):
         "RangeMap Item"
index 8b4023c4203d6ff5ab46638ca63d884b74e4d49e..4f081c7e9253f5f693a0f5506f5a0560386f0356 100644 (file)
@@ -339,7 +339,6 @@ class MSVCCompiler(CCompiler):
         extra_postargs=None,
         depends=None,
     ):
-
         if not self.initialized:
             self.initialize()
         compile_info = self._setup_compile(
@@ -413,8 +412,7 @@ class MSVCCompiler(CCompiler):
             args = [self.cc] + compile_opts + pp_opts
             if add_cpp_opts:
                 args.append('/EHsc')
-            args.append(input_opt)
-            args.append("/Fo" + obj)
+            args.extend((input_opt, "/Fo" + obj))
             args.extend(extra_postargs)
 
             try:
@@ -427,7 +425,6 @@ class MSVCCompiler(CCompiler):
     def create_static_lib(
         self, objects, output_libname, output_dir=None, debug=0, target_lang=None
     ):
-
         if not self.initialized:
             self.initialize()
         objects, output_dir = self._fix_object_args(objects, output_dir)
@@ -461,7 +458,6 @@ class MSVCCompiler(CCompiler):
         build_temp=None,
         target_lang=None,
     ):
-
         if not self.initialized:
             self.initialize()
         objects, output_dir = self._fix_object_args(objects, output_dir)
index 5d6b86536e0e04208e22298ee671b052189f8e72..ba45ea2b9500e62b8cf6786432336f5b1ddddec1 100644 (file)
@@ -64,7 +64,6 @@ class BCPPCompiler(CCompiler):
     exe_extension = '.exe'
 
     def __init__(self, verbose=0, dry_run=0, force=0):
-
         super().__init__(verbose, dry_run, force)
 
         # These executables are assumed to all be in the path.
@@ -98,7 +97,6 @@ class BCPPCompiler(CCompiler):
         extra_postargs=None,
         depends=None,
     ):
-
         macros, objects, extra_postargs, pp_opts, build = self._setup_compile(
             output_dir, macros, include_dirs, sources, depends, extra_postargs
         )
@@ -167,7 +165,6 @@ class BCPPCompiler(CCompiler):
     def create_static_lib(
         self, objects, output_libname, output_dir=None, debug=0, target_lang=None
     ):
-
         (objects, output_dir) = self._fix_object_args(objects, output_dir)
         output_filename = self.library_filename(output_libname, output_dir=output_dir)
 
@@ -200,7 +197,6 @@ class BCPPCompiler(CCompiler):
         build_temp=None,
         target_lang=None,
     ):
-
         # XXX this ignores 'build_temp'!  should follow the lead of
         # msvccompiler.py
 
@@ -219,7 +215,6 @@ class BCPPCompiler(CCompiler):
             output_filename = os.path.join(output_dir, output_filename)
 
         if self._need_link(objects, output_filename):
-
             # Figure out linker args based on type of target.
             if target_desc == CCompiler.EXECUTABLE:
                 startup_obj = 'c0w32'
@@ -294,8 +289,7 @@ class BCPPCompiler(CCompiler):
                     ld_args.append(libfile)
 
             # some default libraries
-            ld_args.append('import32')
-            ld_args.append('cw32mt')
+            ld_args.extend(('import32', 'cw32mt'))
 
             # def file for export symbols
             ld_args.extend([',', def_file])
@@ -381,7 +375,6 @@ class BCPPCompiler(CCompiler):
         extra_preargs=None,
         extra_postargs=None,
     ):
-
         (_, macros, include_dirs) = self._fix_compile_args(None, macros, include_dirs)
         pp_opts = gen_preprocess_options(macros, include_dirs)
         pp_args = ['cpp32.exe'] + pp_opts
index 646353111f6c22860edb2ceec8e5551dc2678dc7..f4a8a89760144f28cbeff505c86bdf538e65a1a8 100644 (file)
@@ -6,6 +6,7 @@ for the Distutils compiler abstraction model."""
 import sys
 import os
 import re
+import warnings
 
 from .errors import (
     CompileError,
@@ -388,7 +389,7 @@ class CCompiler:
             raise TypeError("'macros' (if supplied) must be a list of tuples")
 
         if include_dirs is None:
-            include_dirs = self.include_dirs
+            include_dirs = list(self.include_dirs)
         elif isinstance(include_dirs, (list, tuple)):
             include_dirs = list(include_dirs) + (self.include_dirs or [])
         else:
@@ -824,9 +825,19 @@ class CCompiler:
         libraries=None,
         library_dirs=None,
     ):
-        """Return a boolean indicating whether funcname is supported on
-        the current platform.  The optional arguments can be used to
-        augment the compilation environment.
+        """Return a boolean indicating whether funcname is provided as
+        a symbol on the current platform.  The optional arguments can
+        be used to augment the compilation environment.
+
+        The libraries argument is a list of flags to be passed to the
+        linker to make additional symbol definitions available for
+        linking.
+
+        The includes and include_dirs arguments are deprecated.
+        Usually, supplying include files with function declarations
+        will cause function detection to fail even in cases where the
+        symbol is available for linking.
+
         """
         # this can't be included at module scope because it tries to
         # import math which might not be available at that point - maybe
@@ -835,8 +846,12 @@ class CCompiler:
 
         if includes is None:
             includes = []
+        else:
+            warnings.warn("includes is deprecated", DeprecationWarning)
         if include_dirs is None:
             include_dirs = []
+        else:
+            warnings.warn("include_dirs is deprecated", DeprecationWarning)
         if libraries is None:
             libraries = []
         if library_dirs is None:
@@ -845,7 +860,24 @@ class CCompiler:
         f = os.fdopen(fd, "w")
         try:
             for incl in includes:
-                f.write("""#include "%s"\n""" % incl)
+                f.write("""#include %s\n""" % incl)
+            if not includes:
+                # Use "char func(void);" as the prototype to follow
+                # what autoconf does.  This prototype does not match
+                # any well-known function the compiler might recognize
+                # as a builtin, so this ends up as a true link test.
+                # Without a fake prototype, the test would need to
+                # know the exact argument types, and the has_function
+                # interface does not provide that level of information.
+                f.write(
+                    """\
+#ifdef __cplusplus
+extern "C"
+#endif
+char %s(void);
+"""
+                    % funcname
+                )
             f.write(
                 """\
 int main (int argc, char **argv) {
@@ -871,7 +903,9 @@ int main (int argc, char **argv) {
         except (LinkError, TypeError):
             return False
         else:
-            os.remove(os.path.join(self.output_dir or '', "a.out"))
+            os.remove(
+                self.executable_filename("a.out", output_dir=self.output_dir or '')
+            )
         finally:
             for fn in objects:
                 os.remove(fn)
index 918db85325c70c35dedef01549d1bbb54e60edf1..3860c3ff1e0095c27fcfa36501c8c3fcbb1f4674 100644 (file)
@@ -160,7 +160,7 @@ class Command:
             header = "command options for '%s':" % self.get_command_name()
         self.announce(indent + header, level=logging.INFO)
         indent = indent + "  "
-        for (option, _, _) in self.user_options:
+        for option, _, _ in self.user_options:
             option = option.translate(longopt_xlate)
             if option[-1] == "=":
                 option = option[:-1]
@@ -291,7 +291,7 @@ class Command:
         # Option_pairs: list of (src_option, dst_option) tuples
         src_cmd_obj = self.distribution.get_command_obj(src_cmd)
         src_cmd_obj.ensure_finalized()
-        for (src_option, dst_option) in option_pairs:
+        for src_option, dst_option in option_pairs:
             if getattr(self, dst_option) is None:
                 setattr(self, dst_option, getattr(src_cmd_obj, src_option))
 
@@ -325,7 +325,7 @@ class Command:
         run for the current distribution.  Return a list of command names.
         """
         commands = []
-        for (cmd_name, method) in self.sub_commands:
+        for cmd_name, method in self.sub_commands:
             if method is None or method(self):
                 commands.append(cmd_name)
         return commands
index bf0baab0d2697a07d76decf7a922f848d0316858..6329039ce466e0adb786324c7b98140271fe2fe9 100644 (file)
@@ -33,7 +33,6 @@ class ListCompat(dict):
 
 
 class bdist(Command):
-
     description = "create a built (binary) distribution"
 
     user_options = [
index 071da77e18ce510879ecfc36739984e58f1ebd74..01dd79079b04b6743295ef224592b49e6d9d2cb8 100644 (file)
@@ -14,7 +14,6 @@ from distutils._log import log
 
 
 class bdist_dumb(Command):
-
     description = "create a \"dumb\" built distribution"
 
     user_options = [
index 340527b08a24a4376a828cebc9dadaf02fb76a04..3ed608b479dbbaa4a0fc92e1f7d9b593188bc0b9 100644 (file)
@@ -21,7 +21,6 @@ from distutils._log import log
 
 
 class bdist_rpm(Command):
-
     description = "create an RPM distribution"
 
     user_options = [
@@ -554,7 +553,7 @@ class bdist_rpm(Command):
             ('postun', 'post_uninstall', None),
         ]
 
-        for (rpm_opt, attr, default) in script_options:
+        for rpm_opt, attr, default in script_options:
             # Insert contents of file referred to, if no file is referred to
             # use 'default' as contents of script
             val = getattr(self, attr)
index c3ab410f29a196d9292965e732947653415362a4..cc9b367ef922e94fa6db2b7fb9fbbd23fa0c8963 100644 (file)
@@ -16,7 +16,6 @@ def show_compilers():
 
 
 class build(Command):
-
     description = "build everything needed to install"
 
     user_options = [
index f90c56643236bebc49ae3004fff650d58ecd95d2..b3f679b67da7c997478bd9ee8546682106b8be62 100644 (file)
@@ -28,7 +28,6 @@ def show_compilers():
 
 
 class build_clib(Command):
-
     description = "build C/C++ libraries used by Python extensions"
 
     user_options = [
@@ -103,7 +102,7 @@ class build_clib(Command):
             self.compiler.set_include_dirs(self.include_dirs)
         if self.define is not None:
             # 'define' option is a list of (name,value) tuples
-            for (name, value) in self.define:
+            for name, value in self.define:
                 self.compiler.define_macro(name, value)
         if self.undef is not None:
             for macro in self.undef:
@@ -155,14 +154,14 @@ class build_clib(Command):
             return None
 
         lib_names = []
-        for (lib_name, build_info) in self.libraries:
+        for lib_name, build_info in self.libraries:
             lib_names.append(lib_name)
         return lib_names
 
     def get_source_files(self):
         self.check_library_list(self.libraries)
         filenames = []
-        for (lib_name, build_info) in self.libraries:
+        for lib_name, build_info in self.libraries:
             sources = build_info.get('sources')
             if sources is None or not isinstance(sources, (list, tuple)):
                 raise DistutilsSetupError(
@@ -175,7 +174,7 @@ class build_clib(Command):
         return filenames
 
     def build_libraries(self, libraries):
-        for (lib_name, build_info) in libraries:
+        for lib_name, build_info in libraries:
             sources = build_info.get('sources')
             if sources is None or not isinstance(sources, (list, tuple)):
                 raise DistutilsSetupError(
index f4c0eccd4ff57000cd93c1263b605d5837caf3fb..fbeec342c06e60d8a8893acb30744b58027e6334 100644 (file)
@@ -39,7 +39,6 @@ def show_compilers():
 
 
 class build_ext(Command):
-
     description = "build C/C++ extensions (compile/link to build directory)"
 
     # XXX thoughts on how to deal with complex command-line options like
@@ -328,7 +327,7 @@ class build_ext(Command):
             self.compiler.set_include_dirs(self.include_dirs)
         if self.define is not None:
             # 'define' option is a list of (name,value) tuples
-            for (name, value) in self.define:
+            for name, value in self.define:
                 self.compiler.define_macro(name, value)
         if self.undef is not None:
             for macro in self.undef:
@@ -721,7 +720,7 @@ class build_ext(Command):
         name = ext.name.split('.')[-1]
         try:
             # Unicode module name support as defined in PEP-489
-            # https://www.python.org/dev/peps/pep-0489/#export-hook-name
+            # https://peps.python.org/pep-0489/#export-hook-name
             name.encode('ascii')
         except UnicodeEncodeError:
             suffix = 'U_' + name.encode('punycode').replace(b'-', b'_').decode('ascii')
index 9f78324452c6726e01d2958d23b802be94a44120..d9df95922f3e388ef62da386334549d7d07310ff 100644 (file)
@@ -14,7 +14,6 @@ from distutils._log import log
 
 
 class build_py(Command):
-
     description = "\"build\" pure Python modules (copy to build directory)"
 
     user_options = [
@@ -310,7 +309,7 @@ class build_py(Command):
     def get_outputs(self, include_bytecode=1):
         modules = self.find_all_modules()
         outputs = []
-        for (package, module, module_file) in modules:
+        for package, module, module_file in modules:
             package = package.split('.')
             filename = self.get_module_outfile(self.build_lib, package, module)
             outputs.append(filename)
@@ -352,7 +351,7 @@ class build_py(Command):
 
     def build_modules(self):
         modules = self.find_modules()
-        for (package, module, module_file) in modules:
+        for package, module, module_file in modules:
             # Now "build" the module -- ie. copy the source file to
             # self.build_lib (the build directory for Python source).
             # (Actually, it gets copied to the directory for this package
@@ -375,7 +374,7 @@ class build_py(Command):
 
             # Now loop over the modules we found, "building" each one (just
             # copy it to self.build_lib).
-            for (package_, module, module_file) in modules:
+            for package_, module, module_file in modules:
                 assert package == package_
                 self.build_module(module, module_file, package)
 
index 87174f6bb15b6b8119c019682da312df9389c131..ce222f1e52d3e46840602cb9a8b09574a8b07cd8 100644 (file)
@@ -22,7 +22,6 @@ first_line_re = shebang_pattern
 
 
 class build_scripts(Command):
-
     description = "\"build\" scripts (copy and fixup #! line)"
 
     user_options = [
index d6eb3ebad6bea5034b48517a92f04cab1bc65ecf..9413f7cfcb40a0eed0af78347f7d60ed367c2738 100644 (file)
@@ -11,7 +11,6 @@ from distutils._log import log
 
 
 class clean(Command):
-
     description = "clean up temporary files from 'build' command"
     user_options = [
         ('build-base=', 'b', "base build directory (default: 'build.build-base')"),
index 8bf0e4893be9463b23cc13b38edd6344951e4e8c..494d97d16f622346de60669b9bc93f2d6c181b67 100644 (file)
@@ -21,7 +21,6 @@ LANG_EXT = {"c": ".c", "c++": ".cxx"}
 
 
 class config(Command):
-
     description = "prepare to build"
 
     user_options = [
index 08d2f8812fe3fb3ed43d4ad31acc236041dd9f97..a7ac4e6077b065fe11015bb8c9b11547bf5e7798 100644 (file)
@@ -180,7 +180,6 @@ def _pypy_hack(name):
 
 
 class install(Command):
-
     description = "install everything from build directory"
 
     user_options = [
@@ -609,7 +608,7 @@ class install(Command):
         for attr in attrs:
             val = getattr(self, attr)
             if val is not None:
-                if os.name == 'posix' or os.name == 'nt':
+                if os.name in ('posix', 'nt'):
                     val = os.path.expanduser(val)
                 val = subst_vars(val, self.config_vars)
                 setattr(self, attr, val)
index d92ed87a64bb02dc194dfc4b66c6ec4339081b40..7ba35eef8270c34f183090bfa189358565526899 100644 (file)
@@ -11,7 +11,6 @@ from ..util import change_root, convert_path
 
 
 class install_data(Command):
-
     description = "install data files"
 
     user_options = [
index 1cdee823dc27e67e8a4dc2c75c9235276b5d1d40..085272c1a2274471d6cdc9022b8a273966086bcf 100644 (file)
@@ -8,7 +8,6 @@ from ..core import Command
 
 # XXX force is never used
 class install_headers(Command):
-
     description = "install C/C++ header files"
 
     user_options = [
index 840d3403c4158f9c7298ca31d298f0322ec0f73e..be4c2433212854dd0f5f8cce22b88f74226f4f87 100644 (file)
@@ -16,7 +16,6 @@ PYTHON_SOURCE_EXTENSION = ".py"
 
 
 class install_lib(Command):
-
     description = "install all Python modules (extensions and pure Python)"
 
     # The byte-compilation options are a tad confusing.  Here are the
index ec6ec5acaa40ceea9ac34db647bdcc5bb2f28c4e..20f07aaa2730477b580036214059291d7ad6d06f 100644 (file)
@@ -12,7 +12,6 @@ from stat import ST_MODE
 
 
 class install_scripts(Command):
-
     description = "install scripts (Python or otherwise)"
 
     user_options = [
index 55c1045ec6d2fb931da66b72b973c574e955b05a..c19aabb91ff4595bc7e20e9d6f80a16a9be5d42b 100644 (file)
@@ -17,7 +17,6 @@ from distutils._log import log
 
 
 class register(PyPIRCCommand):
-
     description = "register the distribution with the Python package index"
     user_options = PyPIRCCommand.user_options + [
         ('list-classifiers', None, 'list the valid Trove classifiers'),
index 5cfd4c1456ee099c85e0186603a32afd2b52a182..ac489726caef968e7b8d82d44c171862e1af1182 100644 (file)
@@ -33,7 +33,6 @@ def show_formats():
 
 
 class sdist(Command):
-
     description = "create a source distribution (tarball, zip file, etc.)"
 
     def checking_metadata(self):
@@ -235,7 +234,7 @@ class sdist(Command):
         """Add all the default files to self.filelist:
           - README or README.txt
           - setup.py
-          - test/test*.py
+          - tests/test*.py and test/test*.py
           - all pure Python modules mentioned in setup script
           - all files pointed by package_data (build_py)
           - all files defined in data_files.
@@ -293,7 +292,7 @@ class sdist(Command):
                     self.warn("standard file '%s' not found" % fn)
 
     def _add_defaults_optional(self):
-        optional = ['test/test*.py', 'setup.cfg']
+        optional = ['tests/test*.py', 'test/test*.py', 'setup.cfg']
         for pattern in optional:
             files = filter(os.path.isfile, glob(pattern))
             self.filelist.extend(files)
index 16e15d8b6050dc89cfab8583a74c8ce2d222825f..caf15f04a603a4d95a52fe0e004a57958054b332 100644 (file)
@@ -27,7 +27,6 @@ _FILE_CONTENT_DIGESTS = {
 
 
 class upload(PyPIRCCommand):
-
     description = "upload binary package to PyPI"
 
     user_options = PyPIRCCommand.user_options + [
index 34cafbceec026b75ef9e76f1b152984abe8e7f24..05d2971994d36b29c6532e0c99115c1906b8e275 100644 (file)
@@ -132,7 +132,7 @@ def setup(**attrs):  # noqa: C901
     # our Distribution (see below).
     klass = attrs.get('distclass')
     if klass:
-        del attrs['distclass']
+        attrs.pop('distclass')
     else:
         klass = Distribution
 
index f15b8eee26b51dddbd8ede357c8fcc337ee690ff..47efa377c5be57510abe5c36bb35402f199b1782 100644 (file)
@@ -43,7 +43,7 @@ _msvcr_lookup = RangeMap.left(
         # VS2013 / MSVC 12.0
         1800: ['msvcr120'],
         # VS2015 / MSVC 14.0
-        1900: ['ucrt', 'vcruntime140'],
+        1900: ['vcruntime140'],
         2000: RangeMap.undefined_value,
     },
 )
@@ -84,7 +84,6 @@ class CygwinCCompiler(UnixCCompiler):
     exe_extension = ".exe"
 
     def __init__(self, verbose=0, dry_run=0, force=0):
-
         super().__init__(verbose, dry_run, force)
 
         status, details = check_config_h()
@@ -118,7 +117,7 @@ class CygwinCCompiler(UnixCCompiler):
 
     @property
     def gcc_version(self):
-        # Older numpy dependend on this existing to check for ancient
+        # Older numpy depended on this existing to check for ancient
         # gcc versions. This doesn't make much sense with clang etc so
         # just hardcode to something recent.
         # https://github.com/numpy/numpy/pull/20333
@@ -133,7 +132,7 @@ class CygwinCCompiler(UnixCCompiler):
 
     def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
         """Compiles the source by spawning GCC and windres if needed."""
-        if ext == '.rc' or ext == '.res':
+        if ext in ('.rc', '.res'):
             # gcc needs '.res' and '.rc' compiled to object files !!!
             try:
                 self.spawn(["windres", "-i", src, "-o", obj])
@@ -269,7 +268,6 @@ class Mingw32CCompiler(CygwinCCompiler):
     compiler_type = 'mingw32'
 
     def __init__(self, verbose=0, dry_run=0, force=0):
-
         super().__init__(verbose, dry_run, force)
 
         shared_option = "-shared"
index 80f7764902d194f54f1f07bac1178c263771d85b..23dc3392a2c9b11f93bc8d9e1381848b7c8fd7b3 100644 (file)
@@ -227,7 +227,7 @@ def remove_tree(directory, verbose=1, dry_run=0):
             # remove dir from cache if it's already there
             abspath = os.path.abspath(cmd[1])
             if abspath in _path_created:
-                del _path_created[abspath]
+                _path_created.pop(abspath)
         except OSError as exc:
             log.warning("error removing %s: %s", directory, exc)
 
index d7458a052fe1e83e47b77a2ba4ec9123071f26ea..7c0f0e5b78c0451711d7225481e1d3c9160e37fe 100644 (file)
@@ -237,9 +237,9 @@ Common commands: (see '--help-commands' for more)
             options = attrs.get('options')
             if options is not None:
                 del attrs['options']
-                for (command, cmd_options) in options.items():
+                for command, cmd_options in options.items():
                     opt_dict = self.get_option_dict(command)
-                    for (opt, val) in cmd_options.items():
+                    for opt, val in cmd_options.items():
                         opt_dict[opt] = ("setup script", val)
 
             if 'licence' in attrs:
@@ -253,7 +253,7 @@ Common commands: (see '--help-commands' for more)
 
             # Now work on the rest of the attributes.  Any attribute that's
             # not already defined is invalid!
-            for (key, val) in attrs.items():
+            for key, val in attrs.items():
                 if hasattr(self.metadata, "set_" + key):
                     getattr(self.metadata, "set_" + key)(val)
                 elif hasattr(self.metadata, key):
@@ -414,7 +414,7 @@ Common commands: (see '--help-commands' for more)
         # to set Distribution options.
 
         if 'global' in self.command_options:
-            for (opt, (src, val)) in self.command_options['global'].items():
+            for opt, (src, val) in self.command_options['global'].items():
                 alias = self.negative_opt.get(opt)
                 try:
                     if alias:
@@ -585,7 +585,7 @@ Common commands: (see '--help-commands' for more)
             cmd_class.help_options, list
         ):
             help_option_found = 0
-            for (help_option, short, desc, func) in cmd_class.help_options:
+            for help_option, short, desc, func in cmd_class.help_options:
                 if hasattr(opts, parser.get_attr_name(help_option)):
                     help_option_found = 1
                     if callable(func):
@@ -603,7 +603,7 @@ Common commands: (see '--help-commands' for more)
         # Put the options from the command-line into their official
         # holding pen, the 'command_options' dictionary.
         opt_dict = self.get_option_dict(command)
-        for (name, value) in vars(opts).items():
+        for name, value in vars(opts).items():
             opt_dict[name] = ("command line", value)
 
         return args
@@ -696,11 +696,11 @@ Common commands: (see '--help-commands' for more)
         for option in self.display_options:
             is_display_option[option[0]] = 1
 
-        for (opt, val) in option_order:
+        for opt, val in option_order:
             if val and is_display_option.get(opt):
                 opt = translate_longopt(opt)
                 value = getattr(self.metadata, "get_" + opt)()
-                if opt in ['keywords', 'platforms']:
+                if opt in ('keywords', 'platforms'):
                     print(','.join(value))
                 elif opt in ('classifiers', 'provides', 'requires', 'obsoletes'):
                     print('\n'.join(value))
@@ -887,7 +887,7 @@ Common commands: (see '--help-commands' for more)
 
         if DEBUG:
             self.announce("  setting options for '%s' command:" % command_name)
-        for (option, (source, value)) in option_dict.items():
+        for option, (source, value) in option_dict.items():
             if DEBUG:
                 self.announce("    {} = {} (from {})".format(option, value, source))
             try:
index 6abb884d36c9b9e4cfcd2186c4b5cc6795a05232..3b887dc5a41e550047477a66a3b4838d9ef2f515 100644 (file)
@@ -113,7 +113,7 @@ class FancyGetopt:
 
     def _check_alias_dict(self, aliases, what):
         assert isinstance(aliases, dict)
-        for (alias, opt) in aliases.items():
+        for alias, opt in aliases.items():
             if alias not in self.option_index:
                 raise DistutilsGetoptError(
                     ("invalid %s '%s': " "option '%s' not defined")
index 1b7cd53bd99a1b3f199a7309da961306fb58ca0a..7c69906646d667f82109e88b96316210e88fd02f 100644 (file)
@@ -176,7 +176,6 @@ def copy_file(  # noqa: C901
 
 # XXX I suspect this is Unix-specific -- need porting help!
 def move_file(src, dst, verbose=1, dry_run=0):  # noqa: C901
-
     """Move a file 'src' to 'dst'.  If 'dst' is a directory, the file will
     be moved into it with the same name; otherwise, 'src' is just renamed
     to 'dst'.  Return the new full name of the file.
index a4714a559dcb695c996cadbac8be71ec9ccb40da..f9f9f2d844e3208b9133d9e775ac0775d8ff47ab 100644 (file)
@@ -391,7 +391,7 @@ class MSVCCompiler(CCompiler):
             # to cross compile, you use 'x86_amd64'.
             # On AMD64, 'vcvars32.bat amd64' is a native build env; to cross
             # compile use 'x86' (ie, it runs the x86 compiler directly)
-            if plat_name == get_platform() or plat_name == 'win32':
+            if plat_name in (get_platform(), 'win32'):
                 # native build or cross-compile to win32
                 plat_spec = PLAT_TO_VCVARS[plat_name]
             else:
@@ -499,7 +499,6 @@ class MSVCCompiler(CCompiler):
         extra_postargs=None,
         depends=None,
     ):
-
         if not self.initialized:
             self.initialize()
         compile_info = self._setup_compile(
@@ -586,7 +585,6 @@ class MSVCCompiler(CCompiler):
     def create_static_lib(
         self, objects, output_libname, output_dir=None, debug=0, target_lang=None
     ):
-
         if not self.initialized:
             self.initialize()
         (objects, output_dir) = self._fix_object_args(objects, output_dir)
@@ -619,7 +617,6 @@ class MSVCCompiler(CCompiler):
         build_temp=None,
         target_lang=None,
     ):
-
         if not self.initialized:
             self.initialize()
         (objects, output_dir) = self._fix_object_args(objects, output_dir)
index 59ebe99caaa5fbee52b4780238a8749448c69686..c3823e257ef1de3a79d7f297f38f3bf0bf06f24b 100644 (file)
@@ -389,7 +389,6 @@ class MSVCCompiler(CCompiler):
         extra_postargs=None,
         depends=None,
     ):
-
         if not self.initialized:
             self.initialize()
         compile_info = self._setup_compile(
@@ -476,7 +475,6 @@ class MSVCCompiler(CCompiler):
     def create_static_lib(
         self, objects, output_libname, output_dir=None, debug=0, target_lang=None
     ):
-
         if not self.initialized:
             self.initialize()
         (objects, output_dir) = self._fix_object_args(objects, output_dir)
@@ -509,7 +507,6 @@ class MSVCCompiler(CCompiler):
         build_temp=None,
         target_lang=None,
     ):
-
         if not self.initialized:
             self.initialize()
         (objects, output_dir) = self._fix_object_args(objects, output_dir)
index 0ec69366fd4d8db7ab9f76a958d035cbb891bf6b..a40a7231b3003afe17c275c0ad9334335a020ba2 100644 (file)
@@ -130,12 +130,20 @@ def get_python_inc(plat_specific=0, prefix=None):
     return getter(resolved_prefix, prefix, plat_specific)
 
 
+@pass_none
+def _extant(path):
+    """
+    Replace path with None if it doesn't exist.
+    """
+    return path if os.path.exists(path) else None
+
+
 def _get_python_inc_posix(prefix, spec_prefix, plat_specific):
     if IS_PYPY and sys.version_info < (3, 8):
         return os.path.join(prefix, 'include')
     return (
         _get_python_inc_posix_python(plat_specific)
-        or _get_python_inc_from_config(plat_specific, spec_prefix)
+        or _extant(_get_python_inc_from_config(plat_specific, spec_prefix))
         or _get_python_inc_posix_prefix(prefix)
     )
 
@@ -474,7 +482,6 @@ def parse_makefile(fn, g=None):  # noqa: C901
                         del notdone[name]
 
                         if name.startswith('PY_') and name[3:] in renamed_variables:
-
                             name = name[3:]
                             if name not in done:
                                 done[name] = value
index 7778c3ad363fd61657cbb63f328a29e76a046876..89c415d7616b15f347c04f298f79d370a066e8a5 100644 (file)
@@ -289,7 +289,7 @@ class ArchiveUtilTestCase(support.TempdirManager):
                 pass
             assert os.getcwd() == current_dir
         finally:
-            del ARCHIVE_FORMATS['xxx']
+            ARCHIVE_FORMATS.pop('xxx')
 
     def test_make_archive_tar(self):
         base_dir = self._create_files()
index b9bec05137d5a55761788c93b87d176598d725da..6fb50c4b8efa6eee2768a0f81519f0c6801366d5 100644 (file)
@@ -29,7 +29,6 @@ class TestBuildDumb(
 ):
     @pytest.mark.usefixtures('needs_zlib')
     def test_simple_built(self):
-
         # let's create a simple package
         tmp_dir = self.mkdtemp()
         pkg_dir = os.path.join(tmp_dir, 'foo')
index 709d0b7d66ad1612a749e0637307ef916a3952c7..b5a392a85f1fbde5315500c2225c0eaaaf0f2944 100644 (file)
@@ -71,7 +71,6 @@ class TestBuildCLib(support.TempdirManager):
         assert cmd.get_source_files() == ['a', 'b', 'c', 'd']
 
     def test_build_libraries(self):
-
         pkg_dir, dist = self.create_dist()
         cmd = build_clib(dist)
 
index f5058487a5f1e7fe9a6680bbf979c243161caf2c..cb61ad74552cbd29b8218e359aa73553680e0542 100644 (file)
@@ -158,7 +158,7 @@ class TestBuildExt(TempdirManager):
         cmd = self.build_ext(dist)
 
         # making sure the user option is there
-        options = [name for name, short, lable in cmd.user_options]
+        options = [name for name, short, label in cmd.user_options]
         assert 'user' in options
 
         # setting a value
@@ -180,7 +180,6 @@ class TestBuildExt(TempdirManager):
         assert incl in cmd.include_dirs
 
     def test_optional_extension(self):
-
         # this extension will fail, but let's ignore this failure
         # with the optional argument.
         modules = [Extension('foo', ['xxx'], optional=False)]
index da1879f237ff3ab61c8b6f75108adeacc2cc59ac..88497d252bc366c8470e0a237bbcfb809cfe79e7 100644 (file)
@@ -53,3 +53,40 @@ def test_set_include_dirs(c_file):
     # do it again, setting include dirs after any initialization
     compiler.set_include_dirs([python])
     compiler.compile(_make_strs([c_file]))
+
+
+def test_has_function_prototype():
+    # Issue https://github.com/pypa/setuptools/issues/3648
+    # Test prototype-generating behavior.
+
+    compiler = ccompiler.new_compiler()
+
+    # Every C implementation should have these.
+    assert compiler.has_function('abort')
+    assert compiler.has_function('exit')
+    with pytest.deprecated_call(match='includes is deprecated'):
+        # abort() is a valid expression with the <stdlib.h> prototype.
+        assert compiler.has_function('abort', includes=['<stdlib.h>'])
+    with pytest.deprecated_call(match='includes is deprecated'):
+        # But exit() is not valid with the actual prototype in scope.
+        assert not compiler.has_function('exit', includes=['<stdlib.h>'])
+    # And setuptools_does_not_exist is not declared or defined at all.
+    assert not compiler.has_function('setuptools_does_not_exist')
+    with pytest.deprecated_call(match='includes is deprecated'):
+        assert not compiler.has_function(
+            'setuptools_does_not_exist', includes=['<stdio.h>']
+        )
+
+
+def test_include_dirs_after_multiple_compile_calls(c_file):
+    """
+    Calling compile multiple times should not change the include dirs
+    (regression test for setuptools issue #3591).
+    """
+    compiler = ccompiler.new_compiler()
+    python = sysconfig.get_paths()['include']
+    compiler.set_include_dirs([python])
+    compiler.compile(_make_strs([c_file]))
+    assert compiler.include_dirs == [python]
+    compiler.compile(_make_strs([c_file]))
+    assert compiler.include_dirs == [python]
index 546540679a1d45eae8856625141cbc453b7a0f13..6d240b8b2bb2c7dc413a9495995f49d30cdf6103 100644 (file)
@@ -152,8 +152,7 @@ class TestCheck(support.TempdirManager):
         pytest.importorskip('docutils')
         # Don't fail if there is a `code` or `code-block` directive
 
-        example_rst_docs = []
-        example_rst_docs.append(
+        example_rst_docs = [
             textwrap.dedent(
                 """\
             Here's some code:
@@ -163,9 +162,7 @@ class TestCheck(support.TempdirManager):
                 def foo():
                     pass
             """
-            )
-        )
-        example_rst_docs.append(
+            ),
             textwrap.dedent(
                 """\
             Here's some code:
@@ -175,8 +172,8 @@ class TestCheck(support.TempdirManager):
                 def foo():
                     pass
             """
-            )
-        )
+            ),
+        ]
 
         for rest_with_code in example_rst_docs:
             pkg_info, dist = self.create_dist(long_description=rest_with_code)
index 3aac448d5ecc0ee886c80adf1cb1cbcfb91ed781..cc740d1a8b1a36455cf29d1d16130dd12bd0eff0 100644 (file)
@@ -58,7 +58,6 @@ class TestCommand:
         cmd.make_file(infiles='in', outfile='out', func='func', args=())
 
     def test_dump_options(self, cmd):
-
         msgs = []
 
         def _announce(msg, level):
index ef01ae219901bf0f0f4c8d3578cbb06bf1a91c4a..6fb449a6c20efc2925fb1a3d0fb6e9978e473f5f 100644 (file)
@@ -47,7 +47,6 @@ class TestCygwinCCompiler(support.TempdirManager):
         assert compiler.runtime_library_dir_option('/foo') == []
 
     def test_check_config_h(self):
-
         # check_config_h looks for "GCC" in sys.version first
         # returns CONFIG_H_OK if found
         sys.version = (
@@ -72,7 +71,6 @@ class TestCygwinCCompiler(support.TempdirManager):
         assert check_config_h()[0] == CONFIG_H_OK
 
     def test_get_msvcr(self):
-
         # none
         sys.version = (
             '2.6.1 (r261:67515, Dec  6 2008, 16:42:21) '
@@ -108,7 +106,7 @@ class TestCygwinCCompiler(support.TempdirManager):
             '3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 18:46:30) '
             '[MSC v.1929 32 bit (Intel)]'
         )
-        assert get_msvcr() == ['ucrt', 'vcruntime140']
+        assert get_msvcr() == ['vcruntime140']
 
         # unknown
         sys.version = (
index 2dcce1dd02a33548a583b0f27294fb121afa1952..e5dcad94642a0a322f571325d0886ea958556648 100644 (file)
@@ -9,7 +9,6 @@ import pytest
 
 class TestDepUtil(support.TempdirManager):
     def test_newer(self):
-
         tmpdir = self.mkdtemp()
         new_file = os.path.join(tmpdir, 'new')
         old_file = os.path.abspath(__file__)
index 0c6db4afaebaac27bb3fd3a811f16b8c74cc7713..72aca4ee5584c2294d8ba8617aee0c9fd7693eb9 100644 (file)
@@ -51,7 +51,6 @@ class TestDirUtil(support.TempdirManager):
         assert stat.S_IMODE(os.stat(self.target2).st_mode) == 0o555 & ~umask
 
     def test_create_tree_verbosity(self, caplog):
-
         create_tree(self.root_target, ['one', 'two', 'three'], verbose=0)
         assert caplog.messages == []
         remove_tree(self.root_target, verbose=0)
@@ -63,7 +62,6 @@ class TestDirUtil(support.TempdirManager):
         remove_tree(self.root_target, verbose=0)
 
     def test_copy_tree_verbosity(self, caplog):
-
         mkpath(self.target, verbose=0)
 
         copy_tree(self.target, self.target2, verbose=0)
index b5e81d0356317c11cca0deba97f14571bbf5c69d..30a6f9ff2ec5b8b8fc413f9bda1813ecb8478901 100644 (file)
@@ -142,7 +142,7 @@ class TestDistributionBehavior(support.TempdirManager):
             result_dict.keys()
         )
 
-        for (key, value) in d.command_options.get('install').items():
+        for key, value in d.command_options.get('install').items():
             assert value == result_dict[key]
 
         # Test case: In a Virtual Environment
index 102218bc0070d84164dc4765124035c34675c413..3f525db42a601659a55c2a5e1b67cab5222a9746 100644 (file)
@@ -100,7 +100,7 @@ class TestInstall(
         cmd = install(dist)
 
         # making sure the user option is there
-        options = [name for name, short, lable in cmd.user_options]
+        options = [name for name, short, label in cmd.user_options]
         assert 'user' in options
 
         # setting a value
index a10393b5e6065e5ce4db59d2965c9fbf59abc8f8..34e593244e0f4238ebf18008fcf115fa3379959d 100644 (file)
@@ -158,7 +158,6 @@ class TestRegister(BasePyPIRCCommandTestCase):
         assert b'xxx' in self.conn.reqs[1].data
 
     def test_password_not_in_file(self):
-
         self.write_file(self.rc, PYPIRC_NOPASSWORD)
         cmd = self._get_cmd()
         cmd._set_config()
index 97504722acc79320f271e1efa2e7a6d0c9bc25a8..fdb768e73f2b0bb4fead6bff7be987837bc4bccf 100644 (file)
@@ -162,7 +162,6 @@ class TestSDist(BasePyPIRCCommandTestCase):
 
     @pytest.mark.usefixtures('needs_zlib')
     def test_add_defaults(self):
-
         # http://bugs.python.org/issue2279
 
         # add_default should also include
index 66f92c2ae00e855deea818411334b99b077bc84e..bfeaf9a6b9350ca1f701b424a9ebcd9b9aa0d014 100644 (file)
@@ -297,3 +297,22 @@ class TestSysconfig:
             cmd, env={**os.environ, "PYTHONPATH": distutils_path}
         )
         assert out == "True"
+
+    def test_get_python_inc_missing_config_dir(self, monkeypatch):
+        """
+        In portable Python installations, the sysconfig will be broken,
+        pointing to the directories where the installation was built and
+        not where it currently is. In this case, ensure that the missing
+        directory isn't used for get_python_inc.
+
+        See pypa/distutils#178.
+        """
+
+        def override(name):
+            if name == 'INCLUDEPY':
+                return '/does-not-exist'
+            return sysconfig.get_config_var(name)
+
+        monkeypatch.setattr(sysconfig, 'get_config_var', override)
+
+        assert os.path.exists(sysconfig.get_python_inc())
index 3978c23952e9c2c4d0848426a8b5745f636b6a1a..a0184424595a5a3984df57ced2c97a77796fe240 100644 (file)
@@ -303,4 +303,4 @@ class TestUnixCCompiler(support.TempdirManager):
         # FileNotFoundError: [Errno 2] No such file or directory: 'a.out'
         self.cc.output_dir = 'scratch'
         os.chdir(self.mkdtemp())
-        self.cc.has_function('abort', includes=['stdlib.h'])
+        self.cc.has_function('abort')
index 9685c065f5e8f74a30028e7a0733355674113ca8..af113b8b6eac86dd08b1ee79783316e001eddd00 100644 (file)
@@ -77,7 +77,6 @@ class TestUpload(BasePyPIRCCommandTestCase):
         return self.last_open
 
     def test_finalize_options(self):
-
         # new format
         self.write_file(self.rc, PYPIRC)
         dist = Distribution()
index 7274d4b16e1bee16751515f42793ebefdd769b96..36f947e51c8a5436b636097a3e9e2626f66bcabd 100644 (file)
@@ -180,7 +180,6 @@ class TextFile:
                 line = None
 
             if self.strip_comments and line:
-
                 # Look for the first "#" in the line.  If none, never
                 # mind.  If we find one and it's the first character, or
                 # is not preceded by "\", then it starts a comment --
@@ -255,7 +254,7 @@ class TextFile:
 
             # blank line (whether we rstrip'ed or not)? skip to next line
             # if appropriate
-            if (line == '' or line == '\n') and self.skip_blanks:
+            if line in ('', '\n') and self.skip_blanks:
                 continue
 
             if self.join_lines:
index 4bf2e6a681d74b618b86c12af3f436eca80aec36..6ca2332ae16a575a850fe97e5bc1e42d33b7b2f2 100644 (file)
@@ -103,7 +103,6 @@ def _linker_params(linker_cmd, compiler_cmd):
 
 
 class UnixCCompiler(CCompiler):
-
     compiler_type = 'unix'
 
     # These are used by CCompiler in two places: the constructor sets
index 8668b43699168b6358cc1d8d022f96ba3b63144b..7ef47176e2782518043e25b8b305aa94bc30edd5 100644 (file)
@@ -228,7 +228,7 @@ def _subst_compat(s):
         import warnings
 
         warnings.warn(
-            "shell/Perl-style substitions are deprecated",
+            "shell/Perl-style substitutions are deprecated",
             DeprecationWarning,
         )
     return repl
index e29e265750fbccfbd072d1541e376aa150724be2..74c40d7bfd5fc63826864345837f1ce66ac613c7 100644 (file)
@@ -169,7 +169,6 @@ class StrictVersion(Version):
             self.prerelease = None
 
     def __str__(self):
-
         if self.version[2] == 0:
             vstring = '.'.join(map(str, self.version[0:2]))
         else: