From 5e40c029e295fac32c9e54ec07d73021754f727a Mon Sep 17 00:00:00 2001 From: Timon Wong Date: Tue, 24 Sep 2024 22:02:29 +0800 Subject: [PATCH] feat: add support to python 3.12 Signed-off-by: Timon Wong --- .circleci/config.yml | 5 +- .github/workflows/test.yml | 77 ++++++++++++++++---------- .github/workflows/wheels.yml | 103 ++++++++++++++++++++--------------- pyproject.toml | 35 ++++-------- setup.py | 47 ++-------------- test-requirements.txt | 2 +- tools/wheel-requirements.txt | 6 +- 7 files changed, 132 insertions(+), 143 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6660788..d2237b6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,12 +44,13 @@ jobs: default: "" machine: - image: ubuntu-2004:2022.04.1 + image: ubuntu-2204:2023.07.1 resource_class: arm.medium environment: - CIBW_SKIP: "<< parameters.skip >>" + CIBW_SKIP: "<< parameters.skip >> pp*" # skip building pypy wheels since broken (pypa/cibuildwheel#2015) CIBW_BUILD: "<< parameters.build >>" + CIBW_PRERELEASE_PYTHONS: "1" steps: - checkout diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e953cce..e747aaa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,72 +7,93 @@ on: pull_request: {} workflow_dispatch: {} +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: +env: + FORCE_COLOR: "1" + # only affects Windows, but easiest to set here for now + SETUPTOOLS_ENABLE_FEATURES: "legacy-editable" + jobs: test: runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: - fail-fast: false + fail-fast: true matrix: include: - - os: macos-11 + - os: macos-13 python: "3.7" - - os: macos-11 - python: "3.10" - - - os: macos-11 - python: pypy-3.8 + - os: macos-14 + python: "3.12" - - os: ubuntu-18.04 - python: "3.7" + - os: macos-14 + python: "3.13" - - os: ubuntu-20.04 - python: pypy-3.8 + #- os: macos-13 + # python: pypy-3.9 - os: ubuntu-20.04 - python: pypy-3.7 + python: "3.7" - # - os: ubuntu-20.04 - # python: "3.7" + #- os: ubuntu-22.04 + # python: pypy-3.9 - # - os: ubuntu-20.04 - # python: "3.8" + #- os: ubuntu-22.04 + # python: pypy-3.7 - # - os: ubuntu-20.04 - # python: "3.9" + - os: ubuntu-22.04 + python: "3.9" - # - os: ubuntu-20.04 - # python: "3.10" + - os: ubuntu-22.04 + python: "3.10" - - os: ubuntu-20.04 + - os: ubuntu-22.04 python: "3.11" - - os: windows-2019 + - os: ubuntu-22.04 + python: "3.8" + + - os: ubuntu-22.04 + python: "3.12" + + - os: ubuntu-22.04 + python: "3.13" + + - os: ubuntu-22.04 + python: "3.13" + + - os: windows-2022 python: "3.7" arch: x86 - - os: windows-2019 + - os: windows-2022 python: "3.9" arch: x64 - - os: windows-2019 - python: "3.10" + - os: windows-2022 + python: "3.13" arch: x64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: ${{ matrix.arch || 'x64' }} + allow-prereleases: true + cache: pip - name: install dependencies run: | - pip install --upgrade pip wheel + pip install --upgrade pip wheel setuptools pip install -r test-requirements.txt - name: show environment diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5a7de2f..d503f7e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -46,24 +46,30 @@ on: - .github/workflows/wheels.yml workflow_dispatch: {} +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + env: + PYTHONUNBUFFERED: "1" TWINE_NONINTERACTIVE: "1" jobs: sdist: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.11" + cache: pip - name: install dependencies run: | - pip install --upgrade pip build + pip install --upgrade pip build pytest setuptools pip install -r tools/wheel-requirements.txt - name: build sdist @@ -71,7 +77,7 @@ jobs: python setup.py build --with-cython python -m build --sdist . - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: sdist path: "dist/*.tar.gz" @@ -87,81 +93,92 @@ jobs: twine upload --skip-existing dist/*.tar.gz wheel: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os || 'ubuntu-22.04' }} env: MACOSX_DEPLOYMENT_TARGET: "10.9" CIBW_TEST_REQUIRES: "pytest" CIBW_TEST_COMMAND: "pytest -v {package}/tests" CIBW_BUILD: "${{ matrix.cibw.build || '*' }}" - # Skip building on CPython 3.6 on all platforms - CIBW_SKIP: "cp36-* *-manylinux_i686 *-musllinux_i686 ${{ matrix.cibw.skip || '' }}" - CIBW_ARCHS_LINUX: "${{ matrix.cibw.arch || 'auto' }}" - CIBW_ARCHS_MACOS: "${{ matrix.cibw.arch || 'auto' }}" + CIBW_SKIP: "${{ matrix.cibw.skip || '' }} pp*" # skip building pypy wheels since broken (pypa/cibuildwheel#2015) + CIBW_ARCHS: "${{ matrix.cibw.arch || 'auto' }}" + CIBW_MANYLINUX_X86_64_IMAGE: "${{ matrix.cibw.manylinux_x86_64_image || '' }}" strategy: fail-fast: false matrix: include: - - os: macos-11 + - os: macos-12 name: mac-cpython cibw: build: "cp*" - - os: macos-11 - name: mac-pypy - cibw: - build: "pp*" + # - os: macos-12 + # name: mac-pypy + # cibw: + # build: "pp*" - - os: macos-11 + - os: macos-14 name: mac-arm cibw: arch: universal2 build: "cp*" - - os: ubuntu-20.04 - name: manylinux-x86_64 + - name: manylinux-x86_64 cibw: arch: x86_64 build: "*manylinux*" - # - os: ubuntu-20.04 - # name: manylinux-aarch64 - # cibw: - # arch: aarch64 - # build: "*manylinux*" + - name: manylinux-i686 + cibw: + arch: i686 + build: "*manylinux*" - - os: ubuntu-20.04 - name: musllinux + # additional manylinux variants, not specified in pyproject.toml: + # build with newer 2_28 for cpython >= 3.10, pypy 3.9 + - name: manylinux-x86_64-2_28 cibw: - build: "*musllinux*" + arch: x86_64 + build: "cp31*-manylinux* pp39-manylinux*" + manylinux_x86_64_image: manylinux_2_28 - # - os: ubuntu-20.04 - # name: musllinux-arrch64 - # cibw: - # arch: aarch64 - # build: "*musllinux*" + - name: musllinux + cibw: + build: "*musllinux*" - - os: windows-2019 - name: win32 + - name: win32 + os: windows-2019 architecture: x86 cibw: build: "cp*win32" + # free-threaded doesn't seem to work on Windows + skip: "*t-win*" - - os: windows-2019 - name: win-pypy - architecture: x64 - cibw: - build: "pp*win_amd64" + # - os: windows-2019 + # name: win-pypy + # architecture: x64 + # cibw: + # build: "pp*win_amd64" - os: windows-2019 name: win_amd64 architecture: x64 cibw: build: "cp*win_amd64" + # free-threaded doesn't seem to work on Windows + skip: "*t-win*" + + - os: windows-2022 + name: win_arm64 + architecture: x64 + cibw: + arch: ARM64 + # free-threaded doesn't seem to work on Windows + skip: "cp37* *t-win*" + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # - name: Set up qemu # id: qemu @@ -171,9 +188,9 @@ jobs: # platforms: arm64 - name: setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.11" architecture: ${{ matrix.architecture }} - name: customize mac-arm-64 @@ -207,7 +224,7 @@ jobs: run: | python -m cibuildwheel . - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: wheels-${{ matrix.name }} path: "wheelhouse/*" diff --git a/pyproject.toml b/pyproject.toml index 16e9be9..5ed9fe8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,42 +37,31 @@ build-backend = "setuptools.build_meta" build-verbosity = "1" [tool.cibuildwheel.linux] -environment.CFLAGS = "-Wl,-strip-all" -environment.CXXFLAGS = "-Wl,-strip-all" - +manylinux-x86_64-image = "manylinux2014" +manylinux-i686-image = "manylinux2014" manylinux-aarch64-image = "manylinux2014" musllinux-aarch64-image = "musllinux_1_1" musllinux-i686-image = "musllinux_1_1" musllinux-x86_64-image = "musllinux_1_1" +[tool.cibuildwheel.linux.environment] +CFLAGS = "-Wl,-strip-all" +CXXFLAGS = "-Wl,-strip-all" -[tool.cibuildwheel.macos] -environment.MACOSX_DEPLOYMENT_TARGET = "10.9" +[tool.cibuildwheel.macos.environment] +# note: everything here needs to also be duplicated in overrides below +MACOSX_DEPLOYMENT_TARGET = "10.9" # mac-arm target is 10.15 [[tool.cibuildwheel.overrides]] select = "*macos*{universal2,arm64}*" -environment.MACOSX_DEPLOYMENT_TARGET = "10.15" - -# manylinux1 for old Python -[[tool.cibuildwheel.overrides]] -select = "cp3{67}-*" -manylinux-x86_64-image = "manylinux1" -manylinux-i686-image = "manylinux1" +environment = { MACOSX_DEPLOYMENT_TARGET = "10.15" } -# manylinux2010 for cp38-9, pp37-8 +# manylinux2010 for (less) old cp37-9, pp37-8 [[tool.cibuildwheel.overrides]] select = "cp3{8,9}-* pp3{7,8}-*" manylinux-x86_64-image = "manylinux2010" manylinux-i686-image = "manylinux2010" -# manylinux2014 for cp310, pp39 -[[tool.cibuildwheel.overrides]] -select = "cp310-* pp39-*" -manylinux-x86_64-image = "manylinux2014" -manylinux-i686-image = "manylinux2014" - -# manylinux_2_28 for cp311 -[[tool.cibuildwheel.overrides]] -select = "cp311-*" -manylinux-x86_64-image = "manylinux_2_28" +# note: manylinux_2_28 builds are added +# in .github/workflows/wheels.yml diff --git a/setup.py b/setup.py index 90fd37c..22cb062 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,12 @@ import os import os.path -import re import subprocess import sys -import sysconfig import warnings -from distutils import util -from distutils.command import build_ext from typing import Any, Dict, List, Optional, Tuple, Union, cast -import pkg_resources from setuptools import Extension, setup +from distutils.command import build_ext IS_DEBUG = os.getenv("CYKSUID_DEBUG", "") == "1" @@ -120,9 +116,6 @@ def finalize_options(self) -> None: def build_extensions(self) -> None: is_msvc = self.compiler.compiler_type == "msvc" - is_clang = hasattr(self.compiler, "compiler_cxx") and ( # noqa: F841 - "clang++" in self.compiler.compiler_cxx - ) is_windows = sys.platform[:3] == "win" is_mingw = is_windows and ( self.compiler.compiler_type.lower() @@ -135,21 +128,6 @@ def build_extensions(self) -> None: "-Wno-deprecated-register", ] - # https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes - # C++ projects must now migrate to libc++ and are recommended to set a - # deployment target of macOS 10.9 or later, or iOS 7 or later. - mac_target = str(sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET")) - if mac_target and ( - pkg_resources.parse_version(mac_target) - < pkg_resources.parse_version("10.9.0") - ): - os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.9" - os.environ["_PYTHON_HOST_PLATFORM"] = re.sub( - r"macosx-[0-9]+\.[0-9]+-(.+)", - r"macosx-10.9-\1", - util.get_platform(), - ) - if is_msvc: self.extra_compile_args += [ "/MT", @@ -265,26 +243,9 @@ def test_supports_compile_arg(self, comm: Union[str, List[str]]) -> bool: print(" ... %s" % ("yes" if is_supported else "no")) return is_supported - -version = "2.0.2" -parsed_version = pkg_resources.parse_version(version) -release_status = "Development Status :: 5 - Production/Stable" -try: - if parsed_version.is_prerelease: - if "a" in version: - release_status = "Development Status :: 3 - Alpha" - else: - release_status = "Development Status :: 4 - Beta" -except Exception: - if "a" in version: - release_status = "Development Status :: 3 - Alpha" - elif "b" in version: - release_status = "Development Status :: 4 - Beta" - - setup( name="cyksuid", - version=version, + version="2.0.2", description="Cython implementation of ksuid", ext_modules=ext_modules, cmdclass={"build_ext": BuildExt}, @@ -301,7 +262,7 @@ def test_supports_compile_arg(self, comm: Union[str, List[str]]) -> bool: keywords=["ksuid"], python_requires=">=3.7", classifiers=[ - release_status, + "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", @@ -309,11 +270,11 @@ def test_supports_compile_arg(self, comm: Union[str, List[str]]) -> bool: "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering", "Topic :: Software Development", "Topic :: Software Development :: Libraries", diff --git a/test-requirements.txt b/test-requirements.txt index d8e1a6b..cc6757b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ black; platform_python_implementation != "PyPy" codecov # coverage 5 has issues with Cython: https://github.com/cython/cython/issues/3515 coverage<5 -cython==3.0.0a11 +cython==3.0.10 flake8 mypy; platform_python_implementation != "PyPy" pytest diff --git a/tools/wheel-requirements.txt b/tools/wheel-requirements.txt index ea8ff64..0b5023c 100644 --- a/tools/wheel-requirements.txt +++ b/tools/wheel-requirements.txt @@ -1,3 +1,3 @@ -cibuildwheel==2.9.0 -cython==0.29.32 -delvewheel==0.0.22; sys_platform == 'win32' +cibuildwheel==2.16.5 +cython==3.0.10 +delvewheel==1.5.2; sys_platform == 'win32'