From 433038627b625ca948796333f4a4f8cde03d68a5 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 20 Nov 2022 14:11:02 +0100 Subject: Add `tests/test*.py` to source distributions Because most Python packages maintain tests in top-level directory `tests/` instead of `test/`, add both to source distributions for consistency. --- distutils/command/sdist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distutils/command/sdist.py b/distutils/command/sdist.py index 5cfd4c14..76d0d865 100644 --- a/distutils/command/sdist.py +++ b/distutils/command/sdist.py @@ -235,7 +235,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 +293,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) -- cgit v1.2.1 From 56a5b333b2a8064c000d18ac0629385100957db0 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 14 Dec 2022 16:42:36 +0100 Subject: distutils.ccompiler: Make has_function work with more C99 compilers C99 removed support for implicit function declarations. This means that just calling a function, without declaring the function first, can result in a compilation error. Today, has_function works with most compilers because they issue just a warning, create an object file, and attempt a link, which then detects available of the symbol at link time, as intended. With future compilers, compilation will already fail, and no link test is performed. The has_function interface provides the caller with a way to supply a list of header files to include. However, even with today's compilers, this only works if the function does not expect any parameters. Otherwise, the function call in the C fragment created by has_function will not supply the correct argument list and fail compilation. Therefore, this change supplies and incorrect prototype without arguments. This is what autoconf does today in a very similar situation, so it is quite likely that compilers will support this construct in this context in the future. The includes and include_dirs arguments are deprecated because of the parameter list mismatch issue. Fixes pypa/setuptools#3648. --- distutils/ccompiler.py | 40 +++++++++++++++++++++++++++++++---- distutils/tests/test_ccompiler.py | 23 ++++++++++++++++++++ distutils/tests/test_unixccompiler.py | 2 +- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index 64635311..16147167 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -6,6 +6,7 @@ for the Distutils compiler abstraction model.""" import sys import os import re +import warnings from .errors import ( CompileError, @@ -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) { diff --git a/distutils/tests/test_ccompiler.py b/distutils/tests/test_ccompiler.py index da1879f2..c868a56b 100644 --- a/distutils/tests/test_ccompiler.py +++ b/distutils/tests/test_ccompiler.py @@ -53,3 +53,26 @@ 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 prototype. + assert compiler.has_function('abort', includes=['']) + 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=['']) + # 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=[''] + ) diff --git a/distutils/tests/test_unixccompiler.py b/distutils/tests/test_unixccompiler.py index 3978c239..a0184424 100644 --- a/distutils/tests/test_unixccompiler.py +++ b/distutils/tests/test_unixccompiler.py @@ -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') -- cgit v1.2.1 From 3e804f4d98ec83aa62c35d0b9323b2c3c2ca41fd Mon Sep 17 00:00:00 2001 From: GalaxySnail Date: Sat, 24 Dec 2022 16:28:15 +0800 Subject: Fix MinGW-w64 segmentation fault --- distutils/cygwinccompiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index f15b8eee..4c9ac0ca 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -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, }, ) -- cgit v1.2.1 From 459f1448604bf0cd59f2a4132aee84f9be6f9b12 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 20 Nov 2022 19:59:31 +0100 Subject: Apply refurb suggestions [FURB123]: Replace `str(x)` with `x` --- distutils/_collections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distutils/_collections.py b/distutils/_collections.py index 02556614..5ad21cc7 100644 --- a/distutils/_collections.py +++ b/distutils/_collections.py @@ -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" -- cgit v1.2.1 From f7ff2d062c4f8ae543f0cd207c51c7b9f7e2e715 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 20 Nov 2022 20:05:52 +0100 Subject: Apply refurb suggestions [FURB113]: Use `x.extend(...)` instead of repeatedly calling `x.append()` --- distutils/_msvccompiler.py | 3 +-- distutils/bcppcompiler.py | 3 +-- distutils/tests/test_check.py | 11 ++++------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/distutils/_msvccompiler.py b/distutils/_msvccompiler.py index 8b4023c4..ff2fb0cf 100644 --- a/distutils/_msvccompiler.py +++ b/distutils/_msvccompiler.py @@ -413,8 +413,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: diff --git a/distutils/bcppcompiler.py b/distutils/bcppcompiler.py index 5d6b8653..c38d57c6 100644 --- a/distutils/bcppcompiler.py +++ b/distutils/bcppcompiler.py @@ -294,8 +294,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]) diff --git a/distutils/tests/test_check.py b/distutils/tests/test_check.py index 54654067..6d240b8b 100644 --- a/distutils/tests/test_check.py +++ b/distutils/tests/test_check.py @@ -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) -- cgit v1.2.1 From b289d7456d21a0a1c5c66dd4ee654e1ee4a0e027 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 20 Nov 2022 20:09:25 +0100 Subject: Apply refurb suggestions [FURB108]: Use `x in (y, z)` instead of `x == y or x == z` --- distutils/command/install.py | 2 +- distutils/cygwinccompiler.py | 2 +- distutils/msvc9compiler.py | 2 +- distutils/text_file.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/distutils/command/install.py b/distutils/command/install.py index 08d2f881..a1f8209a 100644 --- a/distutils/command/install.py +++ b/distutils/command/install.py @@ -609,7 +609,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) diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index f15b8eee..4c5c6a36 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -133,7 +133,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]) diff --git a/distutils/msvc9compiler.py b/distutils/msvc9compiler.py index a4714a55..49d83b50 100644 --- a/distutils/msvc9compiler.py +++ b/distutils/msvc9compiler.py @@ -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: diff --git a/distutils/text_file.py b/distutils/text_file.py index 7274d4b1..164c0ea2 100644 --- a/distutils/text_file.py +++ b/distutils/text_file.py @@ -255,7 +255,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: -- cgit v1.2.1 From 32e9b27a372fa2b3da372e4b4dbf66202f09f215 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 20 Nov 2022 20:16:07 +0100 Subject: Apply refurb suggestions [FURB131]: Replace `del x[y]` with `x.pop(y)` --- distutils/core.py | 2 +- distutils/dir_util.py | 2 +- distutils/tests/test_archive_util.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/distutils/core.py b/distutils/core.py index 34cafbce..05d29719 100644 --- a/distutils/core.py +++ b/distutils/core.py @@ -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 diff --git a/distutils/dir_util.py b/distutils/dir_util.py index 80f77649..23dc3392 100644 --- a/distutils/dir_util.py +++ b/distutils/dir_util.py @@ -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) diff --git a/distutils/tests/test_archive_util.py b/distutils/tests/test_archive_util.py index 7778c3ad..89c415d7 100644 --- a/distutils/tests/test_archive_util.py +++ b/distutils/tests/test_archive_util.py @@ -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() -- cgit v1.2.1 From 1713e720352fc6797d07dd7b61e9bafaed7b8e20 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 20 Nov 2022 20:19:29 +0100 Subject: Apply refurb suggestions [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)` --- distutils/dist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distutils/dist.py b/distutils/dist.py index d7458a05..970abda0 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -700,7 +700,7 @@ Common commands: (see '--help-commands' for more) 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)) -- cgit v1.2.1 From fa9352947bae5f1ca3ef6045410c04463dda7916 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 20 Nov 2022 19:55:33 +0100 Subject: Update outdated GitHub Actions --- .github/workflows/main.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e244014d..b3db721c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,9 +22,9 @@ jobs: - windows-latest runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} - name: Install tox @@ -42,9 +42,9 @@ jobs: - windows-latest runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install Cygwin - uses: cygwin/cygwin-install-action@v1 + uses: cygwin/cygwin-install-action@v2 with: platform: x86_64 packages: >- @@ -71,16 +71,16 @@ jobs: env: SETUPTOOLS_USE_DISTUTILS: local steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} - name: Install tox run: | python -m pip install tox - name: Check out pypa/setuptools - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: pypa/setuptools ref: main @@ -103,9 +103,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: "3.10" - name: Install tox -- cgit v1.2.1 From 69a832f77d4e5d42cb3c0c86eb7925bc7a4bb373 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 16 Jan 2023 14:04:32 +0200 Subject: Link directly to PEPs --- distutils/command/build_ext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distutils/command/build_ext.py b/distutils/command/build_ext.py index f4c0eccd..68d1698c 100644 --- a/distutils/command/build_ext.py +++ b/distutils/command/build_ext.py @@ -721,7 +721,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') -- cgit v1.2.1 From f448b958264eaf2a44373b43d2531f37575ba787 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 6 Feb 2023 10:41:30 -0500 Subject: Add xfail test capturing missed expectation. Ref pypa/distutils#178. --- distutils/tests/test_sysconfig.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/distutils/tests/test_sysconfig.py b/distutils/tests/test_sysconfig.py index 66f92c2a..e1ae398c 100644 --- a/distutils/tests/test_sysconfig.py +++ b/distutils/tests/test_sysconfig.py @@ -297,3 +297,23 @@ class TestSysconfig: cmd, env={**os.environ, "PYTHONPATH": distutils_path} ) assert out == "True" + + @pytest.mark.xfail(reason="#178") + 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()) -- cgit v1.2.1 From ff9b6d17bf00f00e4a784ac4d6d33ffcc9dcbd3d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 6 Feb 2023 10:06:19 -0500 Subject: In _get_python_inc_posix, only return an extant path from the sysconfig. Fixes pypa/distutils#178. --- distutils/sysconfig.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/distutils/sysconfig.py b/distutils/sysconfig.py index 0ec69366..277f2ea8 100644 --- a/distutils/sysconfig.py +++ b/distutils/sysconfig.py @@ -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) ) -- cgit v1.2.1 From 67bb76c36a421e3df27dfdc1dbdaf0821aa19f8e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 6 Feb 2023 12:30:58 -0500 Subject: =?UTF-8?q?=E2=9A=AB=20Fade=20to=20black.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- distutils/_msvccompiler.py | 3 --- distutils/bcppcompiler.py | 6 ------ distutils/cmd.py | 6 +++--- distutils/command/bdist.py | 1 - distutils/command/bdist_dumb.py | 1 - distutils/command/bdist_rpm.py | 3 +-- distutils/command/build.py | 1 - distutils/command/build_clib.py | 9 ++++----- distutils/command/build_ext.py | 3 +-- distutils/command/build_py.py | 7 +++---- distutils/command/build_scripts.py | 1 - distutils/command/clean.py | 1 - distutils/command/config.py | 1 - distutils/command/install.py | 1 - distutils/command/install_data.py | 1 - distutils/command/install_headers.py | 1 - distutils/command/install_lib.py | 1 - distutils/command/install_scripts.py | 1 - distutils/command/register.py | 1 - distutils/command/sdist.py | 1 - distutils/command/upload.py | 1 - distutils/cygwinccompiler.py | 2 -- distutils/dist.py | 16 ++++++++-------- distutils/fancy_getopt.py | 2 +- distutils/file_util.py | 1 - distutils/msvc9compiler.py | 3 --- distutils/msvccompiler.py | 3 --- distutils/sysconfig.py | 1 - distutils/tests/test_bdist_dumb.py | 1 - distutils/tests/test_build_clib.py | 1 - distutils/tests/test_build_ext.py | 1 - distutils/tests/test_cmd.py | 1 - distutils/tests/test_cygwinccompiler.py | 2 -- distutils/tests/test_dep_util.py | 1 - distutils/tests/test_dir_util.py | 2 -- distutils/tests/test_dist.py | 2 +- distutils/tests/test_register.py | 1 - distutils/tests/test_sdist.py | 1 - distutils/tests/test_upload.py | 1 - distutils/text_file.py | 1 - distutils/unixccompiler.py | 1 - distutils/version.py | 1 - 42 files changed, 22 insertions(+), 74 deletions(-) diff --git a/distutils/_msvccompiler.py b/distutils/_msvccompiler.py index 8b4023c4..484a2e77 100644 --- a/distutils/_msvccompiler.py +++ b/distutils/_msvccompiler.py @@ -339,7 +339,6 @@ class MSVCCompiler(CCompiler): extra_postargs=None, depends=None, ): - if not self.initialized: self.initialize() compile_info = self._setup_compile( @@ -427,7 +426,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 +459,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) diff --git a/distutils/bcppcompiler.py b/distutils/bcppcompiler.py index 5d6b8653..5c07294a 100644 --- a/distutils/bcppcompiler.py +++ b/distutils/bcppcompiler.py @@ -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' @@ -381,7 +376,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 diff --git a/distutils/cmd.py b/distutils/cmd.py index 918db853..3860c3ff 100644 --- a/distutils/cmd.py +++ b/distutils/cmd.py @@ -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 diff --git a/distutils/command/bdist.py b/distutils/command/bdist.py index bf0baab0..6329039c 100644 --- a/distutils/command/bdist.py +++ b/distutils/command/bdist.py @@ -33,7 +33,6 @@ class ListCompat(dict): class bdist(Command): - description = "create a built (binary) distribution" user_options = [ diff --git a/distutils/command/bdist_dumb.py b/distutils/command/bdist_dumb.py index 071da77e..01dd7907 100644 --- a/distutils/command/bdist_dumb.py +++ b/distutils/command/bdist_dumb.py @@ -14,7 +14,6 @@ from distutils._log import log class bdist_dumb(Command): - description = "create a \"dumb\" built distribution" user_options = [ diff --git a/distutils/command/bdist_rpm.py b/distutils/command/bdist_rpm.py index 340527b0..3ed608b4 100644 --- a/distutils/command/bdist_rpm.py +++ b/distutils/command/bdist_rpm.py @@ -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) diff --git a/distutils/command/build.py b/distutils/command/build.py index c3ab410f..cc9b367e 100644 --- a/distutils/command/build.py +++ b/distutils/command/build.py @@ -16,7 +16,6 @@ def show_compilers(): class build(Command): - description = "build everything needed to install" user_options = [ diff --git a/distutils/command/build_clib.py b/distutils/command/build_clib.py index f90c5664..b3f679b6 100644 --- a/distutils/command/build_clib.py +++ b/distutils/command/build_clib.py @@ -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( diff --git a/distutils/command/build_ext.py b/distutils/command/build_ext.py index f4c0eccd..18dc877d 100644 --- a/distutils/command/build_ext.py +++ b/distutils/command/build_ext.py @@ -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: diff --git a/distutils/command/build_py.py b/distutils/command/build_py.py index 9f783244..d9df9592 100644 --- a/distutils/command/build_py.py +++ b/distutils/command/build_py.py @@ -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) diff --git a/distutils/command/build_scripts.py b/distutils/command/build_scripts.py index 87174f6b..ce222f1e 100644 --- a/distutils/command/build_scripts.py +++ b/distutils/command/build_scripts.py @@ -22,7 +22,6 @@ first_line_re = shebang_pattern class build_scripts(Command): - description = "\"build\" scripts (copy and fixup #! line)" user_options = [ diff --git a/distutils/command/clean.py b/distutils/command/clean.py index d6eb3eba..9413f7cf 100644 --- a/distutils/command/clean.py +++ b/distutils/command/clean.py @@ -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')"), diff --git a/distutils/command/config.py b/distutils/command/config.py index 8bf0e489..494d97d1 100644 --- a/distutils/command/config.py +++ b/distutils/command/config.py @@ -21,7 +21,6 @@ LANG_EXT = {"c": ".c", "c++": ".cxx"} class config(Command): - description = "prepare to build" user_options = [ diff --git a/distutils/command/install.py b/distutils/command/install.py index 08d2f881..f6777a90 100644 --- a/distutils/command/install.py +++ b/distutils/command/install.py @@ -180,7 +180,6 @@ def _pypy_hack(name): class install(Command): - description = "install everything from build directory" user_options = [ diff --git a/distutils/command/install_data.py b/distutils/command/install_data.py index d92ed87a..7ba35eef 100644 --- a/distutils/command/install_data.py +++ b/distutils/command/install_data.py @@ -11,7 +11,6 @@ from ..util import change_root, convert_path class install_data(Command): - description = "install data files" user_options = [ diff --git a/distutils/command/install_headers.py b/distutils/command/install_headers.py index 1cdee823..085272c1 100644 --- a/distutils/command/install_headers.py +++ b/distutils/command/install_headers.py @@ -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 = [ diff --git a/distutils/command/install_lib.py b/distutils/command/install_lib.py index 840d3403..be4c2433 100644 --- a/distutils/command/install_lib.py +++ b/distutils/command/install_lib.py @@ -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 diff --git a/distutils/command/install_scripts.py b/distutils/command/install_scripts.py index ec6ec5ac..20f07aaa 100644 --- a/distutils/command/install_scripts.py +++ b/distutils/command/install_scripts.py @@ -12,7 +12,6 @@ from stat import ST_MODE class install_scripts(Command): - description = "install scripts (Python or otherwise)" user_options = [ diff --git a/distutils/command/register.py b/distutils/command/register.py index 55c1045e..c19aabb9 100644 --- a/distutils/command/register.py +++ b/distutils/command/register.py @@ -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'), diff --git a/distutils/command/sdist.py b/distutils/command/sdist.py index 5cfd4c14..d7fdf937 100644 --- a/distutils/command/sdist.py +++ b/distutils/command/sdist.py @@ -33,7 +33,6 @@ def show_formats(): class sdist(Command): - description = "create a source distribution (tarball, zip file, etc.)" def checking_metadata(self): diff --git a/distutils/command/upload.py b/distutils/command/upload.py index 16e15d8b..caf15f04 100644 --- a/distutils/command/upload.py +++ b/distutils/command/upload.py @@ -27,7 +27,6 @@ _FILE_CONTENT_DIGESTS = { class upload(PyPIRCCommand): - description = "upload binary package to PyPI" user_options = PyPIRCCommand.user_options + [ diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index f15b8eee..41054a78 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -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() @@ -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" diff --git a/distutils/dist.py b/distutils/dist.py index d7458a05..5050f737 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -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,7 +696,7 @@ 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)() @@ -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: diff --git a/distutils/fancy_getopt.py b/distutils/fancy_getopt.py index 6abb884d..3b887dc5 100644 --- a/distutils/fancy_getopt.py +++ b/distutils/fancy_getopt.py @@ -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") diff --git a/distutils/file_util.py b/distutils/file_util.py index 1b7cd53b..7c699066 100644 --- a/distutils/file_util.py +++ b/distutils/file_util.py @@ -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. diff --git a/distutils/msvc9compiler.py b/distutils/msvc9compiler.py index a4714a55..ce0bad7d 100644 --- a/distutils/msvc9compiler.py +++ b/distutils/msvc9compiler.py @@ -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) diff --git a/distutils/msvccompiler.py b/distutils/msvccompiler.py index 59ebe99c..c3823e25 100644 --- a/distutils/msvccompiler.py +++ b/distutils/msvccompiler.py @@ -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) diff --git a/distutils/sysconfig.py b/distutils/sysconfig.py index 277f2ea8..a40a7231 100644 --- a/distutils/sysconfig.py +++ b/distutils/sysconfig.py @@ -482,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 diff --git a/distutils/tests/test_bdist_dumb.py b/distutils/tests/test_bdist_dumb.py index b9bec051..6fb50c4b 100644 --- a/distutils/tests/test_bdist_dumb.py +++ b/distutils/tests/test_bdist_dumb.py @@ -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') diff --git a/distutils/tests/test_build_clib.py b/distutils/tests/test_build_clib.py index 709d0b7d..b5a392a8 100644 --- a/distutils/tests/test_build_clib.py +++ b/distutils/tests/test_build_clib.py @@ -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) diff --git a/distutils/tests/test_build_ext.py b/distutils/tests/test_build_ext.py index f5058487..9084d2e2 100644 --- a/distutils/tests/test_build_ext.py +++ b/distutils/tests/test_build_ext.py @@ -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)] diff --git a/distutils/tests/test_cmd.py b/distutils/tests/test_cmd.py index 3aac448d..cc740d1a 100644 --- a/distutils/tests/test_cmd.py +++ b/distutils/tests/test_cmd.py @@ -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): diff --git a/distutils/tests/test_cygwinccompiler.py b/distutils/tests/test_cygwinccompiler.py index ef01ae21..6c29b743 100644 --- a/distutils/tests/test_cygwinccompiler.py +++ b/distutils/tests/test_cygwinccompiler.py @@ -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) ' diff --git a/distutils/tests/test_dep_util.py b/distutils/tests/test_dep_util.py index 2dcce1dd..e5dcad94 100644 --- a/distutils/tests/test_dep_util.py +++ b/distutils/tests/test_dep_util.py @@ -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__) diff --git a/distutils/tests/test_dir_util.py b/distutils/tests/test_dir_util.py index 0c6db4af..72aca4ee 100644 --- a/distutils/tests/test_dir_util.py +++ b/distutils/tests/test_dir_util.py @@ -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) diff --git a/distutils/tests/test_dist.py b/distutils/tests/test_dist.py index b5e81d03..30a6f9ff 100644 --- a/distutils/tests/test_dist.py +++ b/distutils/tests/test_dist.py @@ -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 diff --git a/distutils/tests/test_register.py b/distutils/tests/test_register.py index a10393b5..34e59324 100644 --- a/distutils/tests/test_register.py +++ b/distutils/tests/test_register.py @@ -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() diff --git a/distutils/tests/test_sdist.py b/distutils/tests/test_sdist.py index 97504722..fdb768e7 100644 --- a/distutils/tests/test_sdist.py +++ b/distutils/tests/test_sdist.py @@ -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 diff --git a/distutils/tests/test_upload.py b/distutils/tests/test_upload.py index 9685c065..af113b8b 100644 --- a/distutils/tests/test_upload.py +++ b/distutils/tests/test_upload.py @@ -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() diff --git a/distutils/text_file.py b/distutils/text_file.py index 7274d4b1..2b42eee4 100644 --- a/distutils/text_file.py +++ b/distutils/text_file.py @@ -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 -- diff --git a/distutils/unixccompiler.py b/distutils/unixccompiler.py index 4bf2e6a6..6ca2332a 100644 --- a/distutils/unixccompiler.py +++ b/distutils/unixccompiler.py @@ -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 diff --git a/distutils/version.py b/distutils/version.py index e29e2657..74c40d7b 100644 --- a/distutils/version.py +++ b/distutils/version.py @@ -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: -- cgit v1.2.1 From e32c71f38d6faf95c8241f4bfe4b6abf06a2ded9 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 20 Nov 2022 14:02:50 +0100 Subject: Fix typos found by codespell --- distutils/cygwinccompiler.py | 2 +- distutils/tests/test_build_ext.py | 2 +- distutils/tests/test_install.py | 2 +- distutils/util.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index 6230bdc4..3125d9dc 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -117,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 diff --git a/distutils/tests/test_build_ext.py b/distutils/tests/test_build_ext.py index 9084d2e2..cb61ad74 100644 --- a/distutils/tests/test_build_ext.py +++ b/distutils/tests/test_build_ext.py @@ -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 diff --git a/distutils/tests/test_install.py b/distutils/tests/test_install.py index 102218bc..3f525db4 100644 --- a/distutils/tests/test_install.py +++ b/distutils/tests/test_install.py @@ -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 diff --git a/distutils/util.py b/distutils/util.py index 8668b436..7ef47176 100644 --- a/distutils/util.py +++ b/distutils/util.py @@ -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 -- cgit v1.2.1 From 53f297ddfd0086f0b954f4342bd4c7fa8a7554fa Mon Sep 17 00:00:00 2001 From: mattip Date: Mon, 6 Feb 2023 19:40:28 +0200 Subject: add a pypy CI run --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3db721c..60801ace 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,9 @@ jobs: - ubuntu-latest - macos-latest - windows-latest + include: + - platform: ubuntu-latest + python: 'pypy3.9' runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v3 -- cgit v1.2.1 From c2bc8135db186a007d02770af3419dc012404e6f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 6 Feb 2023 13:36:39 -0500 Subject: Revert "Merge pull request #197 from GalaxySnail/fix-mingw-w64" This reverts commit 0171aee1bc0e5811d710e6d9253ec80556817095, reversing changes made to fb2a173bcd783040a36ca20c41b967f0673c56a3. --- distutils/cygwinccompiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index 47efa377..3125d9dc 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -43,7 +43,7 @@ _msvcr_lookup = RangeMap.left( # VS2013 / MSVC 12.0 1800: ['msvcr120'], # VS2015 / MSVC 14.0 - 1900: ['vcruntime140'], + 1900: ['ucrt', 'vcruntime140'], 2000: RangeMap.undefined_value, }, ) -- cgit v1.2.1 From e2264e5d74e6bfea75005fe8c67a31ff670b2bb9 Mon Sep 17 00:00:00 2001 From: GalaxySnail Date: Tue, 7 Feb 2023 02:47:07 +0800 Subject: Fix MinGW-w64 segmentation fault --- distutils/cygwinccompiler.py | 2 +- distutils/tests/test_cygwinccompiler.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index 3125d9dc..47efa377 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -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, }, ) diff --git a/distutils/tests/test_cygwinccompiler.py b/distutils/tests/test_cygwinccompiler.py index 6c29b743..6fb449a6 100644 --- a/distutils/tests/test_cygwinccompiler.py +++ b/distutils/tests/test_cygwinccompiler.py @@ -106,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 = ( -- cgit v1.2.1 From 6324549ea823d067e7fe4de9aee5865c107ee42f Mon Sep 17 00:00:00 2001 From: mrbean-bremen Date: Wed, 18 Jan 2023 16:14:23 +0100 Subject: Fixed accumulating include dirs after compile - fixes https://github.com/pypa/setuptools/issues/3591 --- distutils/ccompiler.py | 2 +- distutils/tests/test_ccompiler.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index 16147167..4a5aeb7c 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -389,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: diff --git a/distutils/tests/test_ccompiler.py b/distutils/tests/test_ccompiler.py index c868a56b..88497d25 100644 --- a/distutils/tests/test_ccompiler.py +++ b/distutils/tests/test_ccompiler.py @@ -76,3 +76,17 @@ def test_has_function_prototype(): assert not compiler.has_function( 'setuptools_does_not_exist', includes=[''] ) + + +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] -- cgit v1.2.1 From 2f16327060394b21fadb6342ea83eec324512aaa Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 6 Feb 2023 17:03:43 -0500 Subject: Mark test as xfail on Windows. Ref pypa/distutils#195. --- distutils/tests/test_ccompiler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/distutils/tests/test_ccompiler.py b/distutils/tests/test_ccompiler.py index c868a56b..aa4c7b35 100644 --- a/distutils/tests/test_ccompiler.py +++ b/distutils/tests/test_ccompiler.py @@ -55,6 +55,7 @@ def test_set_include_dirs(c_file): compiler.compile(_make_strs([c_file])) +@pytest.mark.xfail('platform.system() == "Windows"') def test_has_function_prototype(): # Issue https://github.com/pypa/setuptools/issues/3648 # Test prototype-generating behavior. -- cgit v1.2.1 From 7e751d33d42de2ce9bdb08dcd0a1bd5d5b85eed9 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 6 Feb 2023 23:52:13 +0100 Subject: distutils.ccompiler: Remove correct executable file on Windows The previous code did not take into account the .exe file extension on Windows. --- distutils/ccompiler.py | 4 +++- distutils/tests/test_ccompiler.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index 16147167..55f8a9ee 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -903,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) diff --git a/distutils/tests/test_ccompiler.py b/distutils/tests/test_ccompiler.py index aa4c7b35..c868a56b 100644 --- a/distutils/tests/test_ccompiler.py +++ b/distutils/tests/test_ccompiler.py @@ -55,7 +55,6 @@ def test_set_include_dirs(c_file): compiler.compile(_make_strs([c_file])) -@pytest.mark.xfail('platform.system() == "Windows"') def test_has_function_prototype(): # Issue https://github.com/pypa/setuptools/issues/3648 # Test prototype-generating behavior. -- cgit v1.2.1