Skip to content

Commit

Permalink
Update CI, drop Python <3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
mborgerson committed May 2, 2024
1 parent 26959c7 commit 16ab6a8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 80 deletions.
100 changes: 27 additions & 73 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4.1.4
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.8'
python-version: '3.10'
- run: |
python -m pip install pylint
python -m pip install -e .
- uses: pre-commit/[email protected].0
- uses: pre-commit/[email protected].1
with:
extra_args: pylint --all-files

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4.1.4
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.8'
python-version: '3.10'
- name: Build sdist
run: |
python -m pip install --user build
python -m build --sdist
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4.3.3
with:
name: source
path: dist/*.tar.gz
Expand All @@ -45,92 +45,46 @@ jobs:
strategy:
matrix:
include:
- { wheel: cp38-macosx_arm64, os: macos-latest }
- { wheel: cp38-macosx_x86_64, os: macos-latest }
- { wheel: cp38-manylinux_x86_64, os: ubuntu-latest }
- { wheel: cp38-win_amd64, os: windows-latest }
- { wheel: cp39-macosx_arm64, os: macos-latest }
- { wheel: cp39-macosx_x86_64, os: macos-latest }
- { wheel: cp39-manylinux_x86_64, os: ubuntu-latest }
- { wheel: cp39-win_amd64, os: windows-latest }
- { wheel: cp310-macosx_arm64, os: macos-latest }
- { wheel: cp310-macosx_x86_64, os: macos-latest }
- { wheel: cp310-manylinux_x86_64, os: ubuntu-latest }
- { wheel: cp310-win_amd64, os: windows-latest }
- { wheel: cp311-macosx_arm64, os: macos-latest }
- { wheel: cp311-macosx_x86_64, os: macos-latest }
- { wheel: cp311-manylinux_x86_64, os: ubuntu-latest }
- { wheel: cp311-win_amd64, os: windows-latest }
- { wheel: cp312-macosx_arm64, os: macos-latest }
- { wheel: cp312-macosx_x86_64, os: macos-latest }
- { wheel: cp312-manylinux_x86_64, os: ubuntu-latest }
- { wheel: cp312-win_amd64, os: windows-latest }
- { wheel: pp39-manylinux_x86_64, os: ubuntu-latest }
# Currently broken with PyPy 7.3? See https://foss.heptapod.net/pypy/pypy/-/issues/4013.
# - { wheel: pp39-macosx_x86_64, os: macos-latest }
# - { wheel: pp39-win_amd64, os: windows-latest }
- { arch: arm64, wheel: cp310-macosx_arm64, os: macos-latest }
- { arch: x86_64, wheel: cp310-macosx_x86_64, os: macos-13 }
- { arch: x86_64, wheel: cp310-manylinux_x86_64, os: ubuntu-latest }
- { arch: x86_64, wheel: cp310-win_amd64, os: windows-latest }
- { arch: arm64, wheel: cp311-macosx_arm64, os: macos-latest }
- { arch: x86_64, wheel: cp311-macosx_x86_64, os: macos-13 }
- { arch: x86_64, wheel: cp311-manylinux_x86_64, os: ubuntu-latest }
- { arch: x86_64, wheel: cp311-win_amd64, os: windows-latest }
- { arch: arm64, wheel: cp312-macosx_arm64, os: macos-latest }
- { arch: x86_64, wheel: cp312-macosx_x86_64, os: macos-13 }
- { arch: x86_64, wheel: cp312-manylinux_x86_64, os: ubuntu-latest }
- { arch: x86_64, wheel: cp312-win_amd64, os: windows-latest }
steps:
- name: Download source distribution
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.7
with:
name: source
- name: Unpack source distribution
shell: bash
run: tar --strip-components 1 -xvf *.tar.gz
- name: Build wheel
uses: pypa/cibuildwheel@v2.16.2
uses: pypa/cibuildwheel@v2.17.0
with:
output-dir: wheelhouse
env:
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.wheel }}
CIBW_TEST_COMMAND: python -m unittest discover -v -s {package}/tests
CIBW_TEST_SKIP: "*_arm64"
CIBW_BUILD_VERBOSITY: 1
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4.3.3
with:
name: ${{ matrix.wheel }}
path: ./wheelhouse/*.whl

test_macos_arm64_wheels:
needs: build_wheels
name: Test ${{ matrix.wheel }} macOS ARM64 wheel
runs-on: [macOS, ARM64]
strategy:
matrix:
include:
- { wheel: cp310-macosx_arm64, python: '3.10' }
- { wheel: cp311-macosx_arm64, python: '3.11' }
- { wheel: cp312-macosx_arm64, python: '3.12' }
# Not supported by setup-python for the self-hosted runner:
# Error: The version '3.9' with architecture 'arm64' was not found for macOS 13.6.
# - { wheel: cp38-macosx_arm64, python: '3.8' }
# - { wheel: cp39-macosx_arm64, python: '3.9' }
steps:
- run: rm -rf dist
- uses: actions/download-artifact@v3
with:
name: source
path: dist
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.wheel }}
path: dist
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- run: |
pip install --force-reinstall ./dist/*.whl
tar xvf ./dist/pypcode-*.tar.gz
cd pypcode-*/tests
python -m unittest discover -v -s .
build_docs:
name: Build docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4.1.4
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.12'
- run: |
Expand All @@ -139,7 +93,7 @@ jobs:
upload_pypi:
name: Upload wheels to PyPI
needs: [lint, build_docs, build_sdist, build_wheels, test_macos_arm64_wheels]
needs: [lint, build_docs, build_sdist, build_wheels]
runs-on: ubuntu-latest
# Upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
Expand Down
4 changes: 1 addition & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
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

[options]
packages =
pypcode
python_requires = >=3.8
python_requires = >=3.10

[options.extras_require]
docs =
Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ def run(self):
except OSError as exc:
raise RuntimeError("Please install CMake to build") from exc

# When building pypcode wheels on GitHub Actions using cibuildwheel, ARCHFLAGS will be set
cross_compiling_for_macos_arm64 = (
platform.system() == "Darwin" and platform.machine() == "x86_64" and "arm64" in os.getenv("ARCHFLAGS", "")
)
cross_compiling = cross_compiling_for_macos_arm64
cross_compiling_for_macos_amd64 = (
platform.system() == "Darwin" and platform.machine() != "x86_64" and "x86_64" in os.getenv("ARCHFLAGS", "")
)
cross_compiling = cross_compiling_for_macos_arm64 or cross_compiling_for_macos_amd64

root_dir = Path(__file__).parent.absolute()
target_build_dir = root_dir / "build" / "native"
Expand All @@ -49,10 +51,10 @@ def run(self):
cmake_build_args += ["--config", "Release"]

target_cmake_config_args = cmake_config_args[::]
if cross_compiling_for_macos_arm64:
if cross_compiling:
target_cmake_config_args += [
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14",
"-DCMAKE_OSX_ARCHITECTURES=arm64",
"-DCMAKE_OSX_ARCHITECTURES=" + os.getenv("ARCHFLAGS"),
]
subprocess.check_call(["cmake", "-S", ".", "-B", target_build_dir] + target_cmake_config_args, cwd=root_dir)
subprocess.check_call(
Expand Down

0 comments on commit 16ab6a8

Please sign in to comment.