From bd783e0986b2018587b7c01224b1da78e49110d3 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam <3275593+pradyunsg@users.noreply.github.com> Date: Mon, 26 Oct 2020 15:39:18 +0530 Subject: [PATCH 1/7] Convert blockquotes into literal blocks --- README.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 4d9dea513c..76dd0791f2 100644 --- a/README.rst +++ b/README.rst @@ -12,12 +12,16 @@ The original history and attribution of all changes contributed to CPython can b First, create a clone of CPython that only includes the distutils changes. Due to the large size of the CPython repository, this operation is fairly expensive. +:: + git clone https://github.com/python/cpython python-distutils cd python-distutils git filter-branch --prune-empty --subdirectory-filter Lib/distutils master Then, pull those changes into the repository at the cpython branch. +:: + cd $distutils git checkout cpython git fetch $python_distutils @@ -32,6 +36,8 @@ Merging changes from this repository is easier. From the CPython repo, cherry-pick the changes from this project. +:: + git -C $distutils format-patch HEAD~2 --stdout | git am --directory Lib To Setuptools From 35e1c9d4d788094c254485dfdefa0c24cd5820ee Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 6 Nov 2020 15:31:19 -0500 Subject: [PATCH 2/7] In spawn, when logging a command, use list2cmdline to render the command as it would be used, restoring expectation lost in python/cpython#18743. Ref pypa/setuptools#2417 where this change was a red-herring for another issue. --- distutils/spawn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distutils/spawn.py b/distutils/spawn.py index fc592d4a91..a73b8b9bc1 100644 --- a/distutils/spawn.py +++ b/distutils/spawn.py @@ -40,7 +40,7 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0, env=None): # in, protect our %-formatting code against horrible death cmd = list(cmd) - log.info(' '.join(cmd)) + log.info(subprocess.list2cmdline(cmd)) if dry_run: return From 0c9f41d6c2a0224c032db4c9f6d53202796f9241 Mon Sep 17 00:00:00 2001 From: Mikhail Terekhov Date: Sun, 7 Mar 2021 17:00:59 -0500 Subject: [PATCH 3/7] bpo-41882: Clean up after CCompiler.has_function() Closes #31 --- distutils/ccompiler.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index 57bb94e8bb..b38cf261f9 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -792,6 +792,8 @@ def has_function(self, funcname, includes=None, include_dirs=None, objects = self.compile([fname], include_dirs=include_dirs) except CompileError: return False + finally: + os.remove(fname) try: self.link_executable(objects, "a.out", @@ -799,6 +801,11 @@ def has_function(self, funcname, includes=None, include_dirs=None, library_dirs=library_dirs) except (LinkError, TypeError): return False + else: + os.remove("a.out") + finally: + for fn in objects: + os.remove(fn) return True def find_library_file (self, dirs, lib, debug=0): From b04b03ff065a85c7c635feb719e0a203dad68283 Mon Sep 17 00:00:00 2001 From: animalize Date: Mon, 8 Mar 2021 11:22:31 +0800 Subject: [PATCH 4/7] Use /O2 compiler option instead of /Ox for MSVC Compared to /Ox, /O2 has two additional options: /GF: Eliminate Duplicate Strings /Gy: Enable Function-Level Linking Co-Authored-By: Nikita Kniazev <2743474+Kojoley@users.noreply.github.com> --- distutils/_msvccompiler.py | 2 +- distutils/msvc9compiler.py | 4 ++-- distutils/msvccompiler.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/distutils/_msvccompiler.py b/distutils/_msvccompiler.py index e9af4cf52b..b7a06082ae 100644 --- a/distutils/_msvccompiler.py +++ b/distutils/_msvccompiler.py @@ -248,7 +248,7 @@ def initialize(self, plat_name=None): # Future releases of Python 3.x will include all past # versions of vcruntime*.dll for compatibility. self.compile_options = [ - '/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG', '/MD' + '/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD' ] self.compile_options_debug = [ diff --git a/distutils/msvc9compiler.py b/distutils/msvc9compiler.py index 6934e964ab..a1b3b02ff0 100644 --- a/distutils/msvc9compiler.py +++ b/distutils/msvc9compiler.py @@ -399,13 +399,13 @@ def initialize(self, plat_name=None): self.preprocess_options = None if self.__arch == "x86": - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', + self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/Z7', '/D_DEBUG'] else: # Win64 - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' , + self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GS-' , '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-', '/Z7', '/D_DEBUG'] diff --git a/distutils/msvccompiler.py b/distutils/msvccompiler.py index d5857cb1ff..2d447b857d 100644 --- a/distutils/msvccompiler.py +++ b/distutils/msvccompiler.py @@ -283,13 +283,13 @@ def initialize(self): self.preprocess_options = None if self.__arch == "Intel": - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' , + self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GX' , '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX', '/Z7', '/D_DEBUG'] else: # Win64 - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' , + self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GS-' , '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-', '/Z7', '/D_DEBUG'] From 143ebe51b36c0c4723216c08473d6baf31fc6f41 Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Mon, 22 Mar 2021 06:10:20 +1100 Subject: [PATCH 5/7] Relax MACOSX_DEPLOYMENT_TARGET check Only complain if the config target is >= 10.3 and the current target is < 10.3. The check was originally added to ensure that incompatible LDSHARED flags are not used, because '-undefined dynamic_lookup' is used when building for 10.3 and later, and is not supported on older OS versions[1]. Apart from that, there should be no problem in general with using an older target. [1] https://github.com/python/cpython/commit/6b08a40442ca500c8e2073e012b51af66cab9c5a --- distutils/spawn.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/distutils/spawn.py b/distutils/spawn.py index a73b8b9bc1..b012d00d4e 100644 --- a/distutils/spawn.py +++ b/distutils/spawn.py @@ -60,13 +60,17 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0, env=None): if _cfg_target: _cfg_target_split = [int(x) for x in _cfg_target.split('.')] if _cfg_target: - # ensure that the deployment target of build process is not less - # than that used when the interpreter was built. This ensures - # extension modules are built with correct compatibility values + # Ensure that the deployment target of the build process is not + # less than 10.3 if the interpreter was built for 10.3 or later. + # This ensures extension modules are built with correct + # compatibility values, specifically LDSHARED which can use + # '-undefined dynamic_lookup' which only works on >= 10.3. cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target) - if _cfg_target_split > [int(x) for x in cur_target.split('.')]: + cur_target_split = [int(x) for x in cur_target.split('.')] + if _cfg_target_split[:2] >= [10, 3] and cur_target_split[:2] < [10, 3]: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: ' - 'now "%s" but "%s" during configure' + 'now "%s" but "%s" during configure;' + 'must use 10.3 or later' % (cur_target, _cfg_target)) raise DistutilsPlatformError(my_msg) env.update(MACOSX_DEPLOYMENT_TARGET=cur_target) From 64e6d14f7ef38bb99b0f13a9e3814ce16243a474 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 24 Apr 2021 12:13:01 -0400 Subject: [PATCH 6/7] Copy workflows from jaraco/skeleton. Enables CI. --- .github/workflows/automerge.yml | 27 +++++++++++++++++++++ .github/workflows/main.yml | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000000..4f70acfbcb --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,27 @@ +name: automerge +on: + pull_request: + types: + - labeled + - unlabeled + - synchronize + - opened + - edited + - ready_for_review + - reopened + - unlocked + pull_request_review: + types: + - submitted + check_suite: + types: + - completed + status: {} +jobs: + automerge: + runs-on: ubuntu-latest + steps: + - name: automerge + uses: "pascalgn/automerge-action@v0.12.0" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..6a8ff006f4 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,42 @@ +name: tests + +on: [push, pull_request] + +jobs: + test: + strategy: + matrix: + python: [3.6, 3.8, 3.9] + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install tox + run: | + python -m pip install tox + - name: Run tests + run: tox + + release: + needs: test + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install tox + run: | + python -m pip install tox + - name: Release + run: tox -e release + env: + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From be2d1387d92315a337d1ca7bcd96e88f1814c8ff Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 25 Apr 2021 20:23:28 -0400 Subject: [PATCH 7/7] Add changelog. --- changelog.d/2653.change.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/2653.change.rst diff --git a/changelog.d/2653.change.rst b/changelog.d/2653.change.rst new file mode 100644 index 0000000000..f658aa52d2 --- /dev/null +++ b/changelog.d/2653.change.rst @@ -0,0 +1 @@ +Incorporated assorted changes from pypa/distutils.