From 5a67c680c948454c18218c54f0d949d4b92ebea1 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Tue, 1 Oct 2024 09:25:27 -0700 Subject: [PATCH] Fix Release Pipeline for distutils (#598) --- .github/workflows/ci.yml | 3 --- codebuild/cd/manylinux-x64-build.yml | 2 -- codebuild/cd/manylinux-x86-build.yml | 2 -- .../build-wheels-manylinux2014-aarch64.sh | 7 ++++--- .../build-wheels-manylinux2014-x86_64.sh | 7 ++++--- .../build-wheels-musllinux-1-1-aarch64.sh | 7 ++++--- .../build-wheels-musllinux-1-1-x86_64.sh | 7 ++++--- continuous-delivery/build-wheels-osx.sh | 1 - continuous-delivery/build-wheels-win32.bat | 1 - continuous-delivery/build-wheels-win64.bat | 1 - setup.py | 18 +++++++++++++----- 11 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec7bb0f60..b79ca38fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,6 @@ jobs: - x64 - x86 python: - - cp37-cp37m - cp38-cp38 - cp39-cp39 permissions: @@ -52,7 +51,6 @@ jobs: - x86 - aarch64 python: - - cp37-cp37m - cp38-cp38 - cp39-cp39 - cp310-cp310 @@ -85,7 +83,6 @@ jobs: - x64 - aarch64 python: - - cp37-cp37m - cp38-cp38 - cp39-cp39 - cp310-cp310 diff --git a/codebuild/cd/manylinux-x64-build.yml b/codebuild/cd/manylinux-x64-build.yml index eefd0a9b1..146f3a726 100644 --- a/codebuild/cd/manylinux-x64-build.yml +++ b/codebuild/cd/manylinux-x64-build.yml @@ -12,8 +12,6 @@ phases: build: commands: - echo Build started on `date` - - /opt/python/cp37-cp37m/bin/python setup.py sdist bdist_wheel - - auditwheel repair --plat manylinux1_x86_64 dist/awscrt-*cp37-cp37m-linux_x86_64.whl - /opt/python/cp38-cp38/bin/python setup.py sdist bdist_wheel - auditwheel repair --plat manylinux1_x86_64 dist/awscrt-*cp38-cp38-linux_x86_64.whl - /opt/python/cp39-cp39/bin/python setup.py sdist bdist_wheel diff --git a/codebuild/cd/manylinux-x86-build.yml b/codebuild/cd/manylinux-x86-build.yml index c255c8a24..d1bd6e059 100644 --- a/codebuild/cd/manylinux-x86-build.yml +++ b/codebuild/cd/manylinux-x86-build.yml @@ -12,8 +12,6 @@ phases: build: commands: - echo Build started on `date` - - /opt/python/cp37-cp37m/bin/python setup.py sdist bdist_wheel - - auditwheel repair --plat manylinux1_i686 dist/awscrt-*cp37-cp37m-linux_i686.whl - /opt/python/cp38-cp38/bin/python setup.py sdist bdist_wheel - auditwheel repair --plat manylinux1_i686 dist/awscrt-*cp38-cp38-linux_i686.whl - /opt/python/cp39-cp39/bin/python setup.py sdist bdist_wheel diff --git a/continuous-delivery/build-wheels-manylinux2014-aarch64.sh b/continuous-delivery/build-wheels-manylinux2014-aarch64.sh index 62bd8531c..273de1cd7 100755 --- a/continuous-delivery/build-wheels-manylinux2014-aarch64.sh +++ b/continuous-delivery/build-wheels-manylinux2014-aarch64.sh @@ -4,9 +4,6 @@ set -ex /opt/python/cp39-cp39/bin/python ./continuous-delivery/update-version.py -/opt/python/cp37-cp37m/bin/python setup.py sdist bdist_wheel -auditwheel repair --plat manylinux2014_aarch64 dist/awscrt-*cp37*.whl - /opt/python/cp38-cp38/bin/python setup.py sdist bdist_wheel auditwheel repair --plat manylinux2014_aarch64 dist/awscrt-*cp38*.whl @@ -23,6 +20,10 @@ auditwheel repair --plat manylinux2014_aarch64 dist/awscrt-*cp311*.whl # The 3.11 wheel uses the stable ABI, so it works with newer versions too. # We are using the Python 3.13 stable ABI from Python 3.13 onwards because of deprecated functions. +# Manylinux images don't contain setuptools from Python 3.13, so we need to install it. +# Install in a custom location due to access issues. +/opt/python/cp313-cp313/bin/python -m pip install --target ./local -r requirements-dev.txt +export PYTHONPATH=./local:$PYTHONPATH /opt/python/cp313-cp313/bin/python setup.py sdist bdist_wheel auditwheel repair --plat manylinux2014_aarch64 dist/awscrt-*cp313*.whl diff --git a/continuous-delivery/build-wheels-manylinux2014-x86_64.sh b/continuous-delivery/build-wheels-manylinux2014-x86_64.sh index 01ca703d9..cf8d31d61 100755 --- a/continuous-delivery/build-wheels-manylinux2014-x86_64.sh +++ b/continuous-delivery/build-wheels-manylinux2014-x86_64.sh @@ -4,9 +4,6 @@ set -ex /opt/python/cp39-cp39/bin/python ./continuous-delivery/update-version.py -/opt/python/cp37-cp37m/bin/python setup.py sdist bdist_wheel -auditwheel repair --plat manylinux2014_x86_64 dist/awscrt-*cp37*.whl - /opt/python/cp38-cp38/bin/python setup.py sdist bdist_wheel auditwheel repair --plat manylinux2014_x86_64 dist/awscrt-*cp38*.whl @@ -23,6 +20,10 @@ auditwheel repair --plat manylinux2014_x86_64 dist/awscrt-*cp311*.whl # The 3.11 wheel uses the stable ABI, so it works with newer versions too. # We are using the Python 3.13 stable ABI from Python 3.13 onwards because of deprecated functions. +# Manylinux images don't contain setuptools from Python 3.13, so we need to install it. +# Install in a custom location due to access issues. +/opt/python/cp313-cp313/bin/python -m pip install --target ./local -r requirements-dev.txt +export PYTHONPATH=./local:$PYTHONPATH /opt/python/cp313-cp313/bin/python setup.py sdist bdist_wheel auditwheel repair --plat manylinux2014_x86_64 dist/awscrt-*cp313*.whl diff --git a/continuous-delivery/build-wheels-musllinux-1-1-aarch64.sh b/continuous-delivery/build-wheels-musllinux-1-1-aarch64.sh index 6f7f26645..d34d54563 100755 --- a/continuous-delivery/build-wheels-musllinux-1-1-aarch64.sh +++ b/continuous-delivery/build-wheels-musllinux-1-1-aarch64.sh @@ -4,9 +4,6 @@ set -ex /opt/python/cp39-cp39/bin/python ./continuous-delivery/update-version.py -/opt/python/cp37-cp37m/bin/python setup.py sdist bdist_wheel -auditwheel repair --plat musllinux_1_1_aarch64 dist/awscrt-*cp37*.whl - /opt/python/cp38-cp38/bin/python setup.py sdist bdist_wheel auditwheel repair --plat musllinux_1_1_aarch64 dist/awscrt-*cp38*.whl @@ -23,6 +20,10 @@ auditwheel repair --plat musllinux_1_1_aarch64 dist/awscrt-*cp311*.whl # The 3.11 wheel uses the stable ABI, so it works with newer versions too. # We are using the Python 3.13 stable ABI from Python 3.13 onwards because of deprecated functions. +# Manylinux images don't contain setuptools from Python 3.13, so we need to install it. +# Install in a custom location due to access issues. +/opt/python/cp313-cp313/bin/python -m pip install --target ./local -r requirements-dev.txt +export PYTHONPATH=./local:$PYTHONPATH /opt/python/cp313-cp313/bin/python setup.py sdist bdist_wheel auditwheel repair --plat musllinux_1_1_aarch64 dist/awscrt-*cp313*.whl diff --git a/continuous-delivery/build-wheels-musllinux-1-1-x86_64.sh b/continuous-delivery/build-wheels-musllinux-1-1-x86_64.sh index dccf0eef0..503af47b3 100755 --- a/continuous-delivery/build-wheels-musllinux-1-1-x86_64.sh +++ b/continuous-delivery/build-wheels-musllinux-1-1-x86_64.sh @@ -4,9 +4,6 @@ set -ex /opt/python/cp39-cp39/bin/python ./continuous-delivery/update-version.py -/opt/python/cp37-cp37m/bin/python setup.py sdist bdist_wheel -auditwheel repair --plat musllinux_1_1_x86_64 dist/awscrt-*cp37*.whl - /opt/python/cp38-cp38/bin/python setup.py sdist bdist_wheel auditwheel repair --plat musllinux_1_1_x86_64 dist/awscrt-*cp38*.whl @@ -23,6 +20,10 @@ auditwheel repair --plat musllinux_1_1_x86_64 dist/awscrt-*cp311*.whl # The 3.11 wheel uses the stable ABI, so it works with newer versions too. # We are using the Python 3.13 stable ABI from Python 3.13 onwards because of deprecated functions. +# Manylinux images don't contain setuptools from Python 3.13, so we need to install it. +# Install in a custom location due to access issues. +/opt/python/cp313-cp313/bin/python -m pip install --target ./local -r requirements-dev.txt +export PYTHONPATH=./local:$PYTHONPATH /opt/python/cp313-cp313/bin/python setup.py sdist bdist_wheel auditwheel repair --plat musllinux_1_1_x86_64 dist/awscrt-*cp313*.whl diff --git a/continuous-delivery/build-wheels-osx.sh b/continuous-delivery/build-wheels-osx.sh index a9feb731d..6804018a6 100755 --- a/continuous-delivery/build-wheels-osx.sh +++ b/continuous-delivery/build-wheels-osx.sh @@ -5,7 +5,6 @@ set -ex /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 ./continuous-delivery/update-version.py -/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 setup.py sdist bdist_wheel /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 setup.py sdist bdist_wheel /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 setup.py sdist bdist_wheel /Library/Frameworks/Python.framework/Versions/3.10/bin/python3 setup.py sdist bdist_wheel diff --git a/continuous-delivery/build-wheels-win32.bat b/continuous-delivery/build-wheels-win32.bat index d0f2576e3..16df4c870 100644 --- a/continuous-delivery/build-wheels-win32.bat +++ b/continuous-delivery/build-wheels-win32.bat @@ -1,7 +1,6 @@ "C:\Program Files (x86)\Python39-32\python.exe" .\continuous-delivery\update-version.py || goto error -"C:\Program Files (x86)\Python37-32\python.exe" setup.py sdist bdist_wheel || goto error "C:\Program Files (x86)\Python38-32\python.exe" setup.py sdist bdist_wheel || goto error "C:\Program Files (x86)\Python39-32\python.exe" setup.py sdist bdist_wheel || goto error "C:\Program Files (x86)\Python310-32\python.exe" setup.py sdist bdist_wheel || goto error diff --git a/continuous-delivery/build-wheels-win64.bat b/continuous-delivery/build-wheels-win64.bat index fd94419e5..9b4971a2f 100644 --- a/continuous-delivery/build-wheels-win64.bat +++ b/continuous-delivery/build-wheels-win64.bat @@ -1,6 +1,5 @@ "C:\Program Files\Python39\python.exe" continuous-delivery\update-version.py || goto error -"C:\Program Files\Python37\python.exe" setup.py sdist bdist_wheel || goto error "C:\Program Files\Python38\python.exe" setup.py sdist bdist_wheel || goto error "C:\Program Files\Python39\python.exe" setup.py sdist bdist_wheel || goto error "C:\Program Files\Python310\python.exe" setup.py sdist bdist_wheel || goto error diff --git a/setup.py b/setup.py index 50393a8b6..a77b3b1a4 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. - import codecs -import distutils.ccompiler import glob import os import os.path @@ -78,6 +76,7 @@ def determine_generator_args(): if sys.platform == 'win32': try: # See which compiler python picks + import distutils.ccompiler compiler = distutils.ccompiler.new_compiler() compiler.initialize() @@ -305,8 +304,12 @@ def run(self): class bdist_wheel_abi3(bdist_wheel): def get_tag(self): python, abi, plat = super().get_tag() - if python.startswith("cp") and sys.version_info >= (3, 11): - # on CPython, our wheels are abi3 and compatible back to 3.11 + # on CPython, our wheels are abi3 and compatible back to 3.11 + if python.startswith("cp") and sys.version_info >= (3, 13): + # 3.13 deprecates PyWeakref_GetObject(), adds alternative + return "cp313", "abi3", plat + elif python.startswith("cp") and sys.version_info >= (3, 11): + # 3.11 is the first stable ABI that has everything we need return "cp311", "abi3", plat return python, abi, plat @@ -326,6 +329,11 @@ def awscrt_ext(): libraries.reverse() if sys.platform == 'win32': + # distutils is deprecated in Python 3.10 and removed in 3.12. However, it still works because Python defines a compatibility interface as long as setuptools is installed. + # We don't have an official alternative for distutils.ccompiler as of September 2024. See: https://github.com/pypa/setuptools/issues/2806 + # Once that issue is resolved, we can migrate to the official solution. + # For now, restrict distutils to Windows only, where it's needed. + import distutils.ccompiler # the windows apis being used under the hood. Since we're static linking we have to follow the entire chain down libraries += ['Secur32', 'Crypt32', 'Advapi32', 'NCrypt', 'BCrypt', 'Kernel32', 'Ws2_32', 'Shlwapi'] # Ensure that debug info is in the obj files, and that it is linked into the .pyd so that @@ -374,7 +382,7 @@ def awscrt_ext(): # rare cases where that didn't happen, so let's be explicit. extra_link_args += ['-pthread'] - if distutils.ccompiler.get_default_compiler() != 'msvc': + if sys.platform != 'win32' or distutils.ccompiler.get_default_compiler() != 'msvc': extra_compile_args += ['-Wno-strict-aliasing', '-std=gnu99'] # treat warnings as errors in development mode