From 676e669a317d6a4804f8f8bf438fd1e31afbd306 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 26 Dec 2021 16:38:52 +0100 Subject: sysconfig: use get_config_h_filename() from the stdlib distutils.sysconfig provides various functions already present in the stdlib sysconfig module. Reusing the stdlib versions has the advantage that it is in control of the Python distributor/packager and distutils doesn't have to deal with platform details. This tries to start the transition using the simple get_config_h_filename() for starters by forwarding calls to the stdlib in case Python is considered to be installed. --- distutils/sysconfig.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/distutils/sysconfig.py b/distutils/sysconfig.py index d36d94f7..2300014d 100644 --- a/distutils/sysconfig.py +++ b/distutils/sysconfig.py @@ -13,6 +13,7 @@ import _imp import os import re import sys +import sysconfig from .errors import DistutilsPlatformError @@ -274,10 +275,10 @@ def get_config_h_filename(): inc_dir = os.path.join(_sys_home or project_base, "PC") else: inc_dir = _sys_home or project_base + return os.path.join(inc_dir, 'pyconfig.h') else: - inc_dir = get_python_inc(plat_specific=1) + return sysconfig.get_config_h_filename() - return os.path.join(inc_dir, 'pyconfig.h') # Allow this value to be patched by pkgsrc. Ref pypa/distutils#16. -- cgit v1.2.1 From b17dad6615d9b2f4fe255ec6750b2765d9b281f1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 26 Dec 2021 14:47:29 -0500 Subject: =?UTF-8?q?=F0=9F=91=B9=20Feed=20the=20hobgoblins=20(delint).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- distutils/log.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/distutils/log.py b/distutils/log.py index 8ef6b28e..a68b156b 100644 --- a/distutils/log.py +++ b/distutils/log.py @@ -3,13 +3,14 @@ # The class here is styled after PEP 282 so that it could later be # replaced with a standard Python logging implementation. +import sys + DEBUG = 1 INFO = 2 WARN = 3 ERROR = 4 FATAL = 5 -import sys class Log: @@ -54,6 +55,7 @@ class Log: def fatal(self, msg, *args): self._log(FATAL, msg, args) + _global_log = Log() log = _global_log.log debug = _global_log.debug @@ -62,12 +64,14 @@ warn = _global_log.warn error = _global_log.error fatal = _global_log.fatal + def set_threshold(level): # return the old threshold for use from tests old = _global_log.threshold _global_log.threshold = level return old + def set_verbosity(v): if v <= 0: set_threshold(WARN) -- cgit v1.2.1 From 9d0b8cda4075e1f654b8e633957f76b921c608cd Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 26 Dec 2021 19:40:43 +0100 Subject: sysconfig: use parse_config_h() from stdlib sysconfig The only difference is the argument name change --- distutils/sysconfig.py | 22 ++-------------------- distutils/tests/test_sysconfig.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/distutils/sysconfig.py b/distutils/sysconfig.py index d36d94f7..94993cc5 100644 --- a/distutils/sysconfig.py +++ b/distutils/sysconfig.py @@ -13,6 +13,7 @@ import _imp import os import re import sys +import sysconfig from .errors import DistutilsPlatformError @@ -308,26 +309,7 @@ def parse_config_h(fp, g=None): optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ - if g is None: - g = {} - define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n") - undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n") - # - while True: - line = fp.readline() - if not line: - break - m = define_rx.match(line) - if m: - n, v = m.group(1, 2) - try: v = int(v) - except ValueError: pass - g[n] = v - else: - m = undef_rx.match(line) - if m: - g[m.group(1)] = 0 - return g + return sysconfig.parse_config_h(fp, vars=g) # Regexes needed for parsing Makefile (and similar syntaxes, diff --git a/distutils/tests/test_sysconfig.py b/distutils/tests/test_sysconfig.py index 80cd1599..d28f4712 100644 --- a/distutils/tests/test_sysconfig.py +++ b/distutils/tests/test_sysconfig.py @@ -283,6 +283,16 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): outs, errs = p.communicate() self.assertEqual(0, p.returncode, "Subprocess failed: " + outs) + def test_parse_config_h(self): + config_h = sysconfig.get_config_h_filename() + input = {} + with open(config_h, encoding="utf-8") as f: + result = sysconfig.parse_config_h(f, g=input) + self.assertTrue(input) + self.assertTrue(input is result) + with open(config_h, encoding="utf-8") as f: + result = sysconfig.parse_config_h(f) + self.assertTrue(result) def test_suite(): suite = unittest.TestSuite() -- cgit v1.2.1 From 79f6a3fa77407405259242cbdd85d4ff78ed7193 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 28 Dec 2021 15:24:39 -0500 Subject: Use line-based matrix values for nicer diffs. Remove Python 3.6 and bump to Python 3.10, matching jaraco/skeleton and pypa/setuptools approaches. --- .github/workflows/main.yml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd0e1992..bd2dc8f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,8 +6,14 @@ jobs: test: strategy: matrix: - python: [3.6, 3.8, 3.9] - platform: [ubuntu-latest, macos-latest, windows-latest] + python: + - 3.7 + - 3.9 + - "3.10" + platform: + - ubuntu-latest + - macos-latest + - windows-latest runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v2 @@ -24,8 +30,10 @@ jobs: test_cygwin: strategy: matrix: - python: [39] - platform: [windows-latest] + python: + - "3.10" + platform: + - windows-latest runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v2 @@ -49,8 +57,10 @@ jobs: # Integration testing with setuptools strategy: matrix: - python: [3.9] - platform: [ubuntu-latest] + python: + - "3.10" + platform: + - ubuntu-latest runs-on: ${{ matrix.platform }} env: SETUPTOOLS_USE_DISTUTILS: local @@ -89,7 +99,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Install tox run: | python -m pip install tox -- cgit v1.2.1 From 8c160a96931520044688471c8d1ea6148aacb719 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 29 Dec 2021 11:51:20 -0500 Subject: Restore 'get_versions' attribute, allowing older mpi4py to monkeypatch it. Fixes pypa/setuptools#2969. --- distutils/cygwinccompiler.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index 4a38dfda..fd082f6d 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -354,3 +354,9 @@ def is_cygwincc(cc): out_string = check_output(shlex.split(cc) + ['-dumpmachine']) return out_string.strip().endswith(b'cygwin') + +get_versions = None +""" +A stand-in for the previous get_versions() function to prevent failures +when monkeypatched. See pypa/setuptools#2969. +""" -- cgit v1.2.1