Skip to content

Commit

Permalink
cibuildwheel: move configuration to pyproject.toml
Browse files Browse the repository at this point in the history
move the configuration to pyproject.toml, that it would
be easier to use from multiple workflow and for local usage

for example:
```
uv pip install cibuildwheel
CIBW_FREE_THREADED_SUPPORT=True  cibuildwheel --only cp313-manylinux_x86_64
```
  • Loading branch information
fruch committed Jan 23, 2025
1 parent 4a069aa commit 1967715
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 51 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/build-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ name: Build pre release python versions
on: [push, pull_request]

env:
CIBW_TEST_COMMAND_LINUX: "pytest {project}/tests/unit"
CIBW_BEFORE_TEST: "pip install -r {project}/test-requirements.txt"
CIBW_BEFORE_BUILD_LINUX: "rm -rf ~/.pyxbld && rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && yum install -y libffi-devel libev libev-devel openssl openssl-devel"
CIBW_ENVIRONMENT: "CASS_DRIVER_BUILD_CONCURRENCY=2 CFLAGS='-g0 -O3'"
CIBW_PRERELEASE_PYTHONS: True
CIBW_SKIP: cp35* cp36* *musllinux*
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_ENABLE: cpython-prerelease

jobs:
build_wheels:
Expand All @@ -32,12 +26,12 @@ jobs:

- name: Install cibuildwheel
run: |
python3 -m pip install cibuildwheel==2.22.0
python3 -m pip install cibuildwheel==2.22.0 uv==0.5.23
- name: Overwrite for Linux 64
if: runner.os == 'Linux' && matrix.platform == 'x86_64'
run: |
echo "CIBW_BUILD=cp313*_x86_64" >> $GITHUB_ENV
echo "CIBW_BUILD=cp314*_x86_64" >> $GITHUB_ENV
- name: Build wheels
run: |
Expand Down
43 changes: 2 additions & 41 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@ name: Build and upload to PyPi

on: [push, pull_request]


env:
CIBW_TEST_COMMAND_LINUX: >
pytest {project}/tests/unit &&
EVENT_LOOP_MANAGER=gevent pytest {project}/tests/unit/io/test_geventreactor.py
CIBW_TEST_COMMAND_MACOS: "pytest {project}/tests/unit -k 'not (test_multi_timer_validation or test_empty_connections or test_timer_cancellation)' "
CIBW_TEST_COMMAND_WINDOWS: "pytest {project}/tests/unit -k \"not (test_deserialize_date_range_year or test_datetype or test_libevreactor)\" "
CIBW_BEFORE_TEST: "pip install -r {project}/test-requirements.txt"
CIBW_BEFORE_BUILD_LINUX: "rm -rf ~/.pyxbld && rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && yum install -y libffi-devel libev libev-devel openssl openssl-devel"
CIBW_ENVIRONMENT: "CASS_DRIVER_BUILD_CONCURRENCY=2 CASS_DRIVER_BUILD_EXTENSIONS_ARE_MUST=yes CFLAGS='-g0 -O3'"
CIBW_SKIP: cp36* cp37* pp*i686 *musllinux*
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_PYPY_AARCH64_IMAGE: manylinux_2_28
CIBW_BUILD_FRONTEND: "build[uv]"

jobs:
build_wheels:
name: Build wheels ${{ matrix.os }} (${{ matrix.platform }})
Expand Down Expand Up @@ -64,7 +46,7 @@ jobs:
- name: Install cibuildwheel
run: |
python3 -m pip install cibuildwheel==2.22.0
python3 -m pip install cibuildwheel==2.22.0 uv==0.5.23
- name: Install OpenSSL for Windows
if: runner.os == 'Windows'
Expand All @@ -86,41 +68,20 @@ jobs:
run: |
brew install libev
- name: Overwrite for Linux 64
if: runner.os == 'Linux' && matrix.platform == 'x86_64'
run: |
echo "CIBW_BUILD=cp3*_x86_64" >> $GITHUB_ENV
- name: Overwrite for Linux PyPy
if: runner.os == 'Linux' && matrix.platform == 'PyPy'
run: |
echo "CIBW_BUILD=pp*" >> $GITHUB_ENV
echo "CIBW_TEST_COMMAND_LINUX=" >> $GITHUB_ENV
- name: Overwrite for Windows 64
if: runner.os == 'Windows' && matrix.platform == 'win64'
run: |
echo "CIBW_BUILD=cp*win_amd64" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Overwrite for Windows PyPY
if: runner.os == 'Windows' && matrix.platform == 'PyPy'
run: |
echo "CIBW_BUILD=pp*" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
echo "CIBW_TEST_COMMAND_WINDOWS=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Overwrite for MacOs
if: runner.os == 'MacOs' && matrix.platform == 'all'
run: |
echo "CIBW_BUILD=cp39* cp310* cp311* cp312* cp313*" >> $GITHUB_ENV
echo "CIBW_BEFORE_TEST_MACOS=pip install -r {project}/test-requirements.txt pytest" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV
- name: Overwrite for MacOs PyPy
if: runner.os == 'MacOs' && matrix.platform == 'PyPy'
run: |
echo "CIBW_BUILD=pp*" >> $GITHUB_ENV
echo "CIBW_BEFORE_TEST_MACOS=pip install -r {project}/test-requirements.txt pytest" >> $GITHUB_ENV
echo "CIBW_TEST_COMMAND_MACOS=" >> $GITHUB_ENV
- name: Build wheels
run: |
Expand Down Expand Up @@ -178,7 +139,7 @@ jobs:

- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==2.22.0
python -m pip install cibuildwheel==2.22.0 uv==0.5.23
- name: Build wheels
env:
Expand Down
45 changes: 44 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,47 @@ requires = [
"Cython",
]

build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

#### CI BUILDWHEEL CONFIG ####

[tool.cibuildwheel]

build-frontend = "build[uv]"
environment = { CASS_DRIVER_BUILD_CONCURRENCY = "2", CASS_DRIVER_BUILD_EXTENSIONS_ARE_MUST = "yes", CFLAGS = "-g0 -O3" }
skip = ["cp36*", "cp37*", "pp*i686", "*musllinux*"]

before-test = "pip install -r {project}/test-requirements.txt"

[tool.cibuildwheel.linux]
build = ["cp3*_x86_64"]

before-build = "rm -rf ~/.pyxbld && rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && yum install -y libffi-devel libev libev-devel openssl openssl-devel"
test-command = [
"pytest {package}/tests/unit",
"EVENT_LOOP_MANAGER=gevent pytest {package}/tests/unit/io/test_geventreactor.py",
]
manylinux-x86_64-image = "manylinux_2_28"
manylinux-aarch64-image = "manylinux_2_28"

[tool.cibuildwheel.macos]
build = ["cp39*", "cp310*", "cp311*", "cp312*", "cp313*"]

[tool.cibuildwheel.windows]
build = ["cp3*_amd64"]
build-frontend = "build" # build[uv] seems to be broken on Windows

[[tool.cibuildwheel.overrides]]
select = "*-macosx_*"
inherit.environment = "append"
environment = { MACOSX_DEPLOYMENT_TARGET = "13.0" }

[[tool.cibuildwheel.overrides]]
select = "pp*-manylinux*"
test-command = []
manylinux-pypy_x86_64-image = "manylinux_2_28"
manylinux-pypy_aarch64-image = "manylinux_2_28"

[[tool.cibuildwheel.overrides]]
select = 'pp*win_amd64'
test-command = []

0 comments on commit 1967715

Please sign in to comment.