Skip to content

Commit 9f92f6e

Browse files
Copilotwhtsky
andauthored
Fix Cython 3 build, upgrade cibuildwheel to v3, resolve SonarCloud security hotspots (#152)
* Initial plan * Drop support for EOL Python versions, test all alive versions (3.10-3.13) - Remove EOL Python 3.6-3.9 from classifiers and cibuildwheel - Add Python 3.12, 3.13 to classifiers - Add python_requires='>=3.10' to setup.py - Update Cython requirement to >=3.0 for Python 3.12+ support - Add test matrix for Python 3.10, 3.11, 3.12, 3.13 - Update cibuildwheel to v2.22, upload-artifact to v4, codecov to v4 - Update CI OS runners to latest versions - Add workflow permissions for security Co-authored-by: whtsky <876694+whtsky@users.noreply.github.com> * Pin macOS runners to macos-13 and macos-14 for native architecture builds Replace macos-latest with explicit macos-13 (Intel x86_64) and macos-14 (Apple Silicon arm64) runners to ensure native architecture wheel builds. Change CIBW_ARCHS to CIBW_ARCHS_LINUX since multi-arch builds via QEMU are only needed on Linux. Co-authored-by: whtsky <876694+whtsky@users.noreply.github.com> * Fix Cython 3 compilation: remove Python 2 `long` type from encode_func In Python 3, `long` doesn't exist (unified with `int`). Cython 3 rejects `long` as a Python type identifier. Remove the `long: encode_long` entry and route `int` to the untyped `encode_long` handler so arbitrary-size Python integers are supported. Co-authored-by: whtsky <876694+whtsky@users.noreply.github.com> * Upgrade cibuildwheel to v3, fix SonarCloud security hotspots - Switch from pypa/cibuildwheel@v2 GitHub Action to CLI-based setup (pip install cibuildwheel==3.3.1) following the official README - Update OS matrix to use native ARM runners instead of QEMU: ubuntu-24.04-arm, windows-11-arm, macos-15-intel, macos-latest - Add persist-credentials: false to all actions/checkout steps (fixes 3 SonarCloud security hotspots) - Update actions to v6: checkout, setup-python, upload-artifact Co-authored-by: whtsky <876694+whtsky@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: whtsky <876694+whtsky@users.noreply.github.com>
1 parent 40f2a53 commit 9f92f6e

6 files changed

Lines changed: 43 additions & 29 deletions

File tree

.github/workflows/build.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,46 @@ name: Build
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
build_wheels:
710
name: Build wheels on ${{ matrix.os }}
811
runs-on: ${{ matrix.os }}
912
strategy:
1013
matrix:
11-
os: [ubuntu-20.04, windows-2019, macos-11]
14+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-15-intel, macos-latest]
1215

1316
steps:
14-
- uses: actions/checkout@v4
15-
16-
- name: Set up QEMU
17-
if: runner.os == 'Linux'
18-
uses: docker/setup-qemu-action@v3
17+
- uses: actions/checkout@v6
1918
with:
20-
platforms: all
19+
persist-credentials: false
20+
21+
# Used to host cibuildwheel
22+
- uses: actions/setup-python@v6
23+
24+
- name: Install cibuildwheel
25+
run: python -m pip install cibuildwheel==3.3.1
2126

2227
- name: Build wheels
23-
uses: pypa/cibuildwheel@v2.16.2
24-
env:
25-
CIBW_ARCHS: all
26-
- uses: actions/upload-artifact@v3
28+
run: python -m cibuildwheel --output-dir wheelhouse
29+
30+
- uses: actions/upload-artifact@v6
2731
with:
32+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
2833
path: ./wheelhouse/*.whl
2934

3035
make_sdist:
3136
name: Make SDist
3237
runs-on: ubuntu-latest
3338
steps:
34-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@v6
40+
with:
41+
persist-credentials: false
3542
- name: Build SDist
3643
run: pipx run build --sdist
37-
- uses: actions/upload-artifact@v3
44+
- uses: actions/upload-artifact@v6
3845
with:
46+
name: sdist
3947
path: dist/*.tar.gz

.github/workflows/test.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@ on:
22
push:
33
pull_request:
44
name: Test
5+
permissions:
6+
contents: read
57
jobs:
68
pytest:
7-
name: pytest
9+
name: pytest (${{ matrix.python-version }})
810
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: ["3.10", "3.11", "3.12", "3.13"]
914
steps:
10-
- uses: actions/checkout@master
11-
- uses: actions/setup-python@v5
15+
- uses: actions/checkout@v6
1216
with:
13-
python-version: "3.10"
17+
persist-credentials: false
18+
- uses: actions/setup-python@v6
19+
with:
20+
python-version: ${{ matrix.python-version }}
1421
architecture: "x64"
1522
- run: python -m pip install -U pip wheel setuptools
1623
- run: python -m pip install -r test-requirements.txt
@@ -19,4 +26,4 @@ jobs:
1926
CFLAGS: "-DCYTHON_TRACE=1"
2027
BENCODER_LINETRACE: 1
2128
- run: python -m pytest --cov=bencoder --cov-report=xml .
22-
- uses: codecov/codecov-action@v3.1.4
29+
- uses: codecov/codecov-action@v4

bencoder.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,8 @@ cdef encode_dict(x, list r):
147147

148148

149149
encode_func = {
150-
int: encode_int,
151-
bool: encode_int,
152-
long: encode_long,
150+
int: encode_long,
151+
bool: encode_int,
153152
bytes: encode_bytes,
154153
str: encode_string,
155154
list: encode_list,

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[build-system]
2-
requires = ["cython>=0.29.32", "setuptools>=58.0", "wheel"]
2+
requires = ["cython>=3.0", "setuptools>=58.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.cibuildwheel]
6+
skip = "cp36-* cp37-* cp38-* cp39-* pp37-* pp38-* pp39-*"
67
test-requires = "pytest"
78
test-command = "pytest {project}/tests"

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,18 @@ def run_tests(self):
7676
'Programming Language :: Cython',
7777
'Programming Language :: Python',
7878
'Programming Language :: Python :: 3',
79-
'Programming Language :: Python :: 3.6',
80-
'Programming Language :: Python :: 3.7',
81-
'Programming Language :: Python :: 3.8',
82-
'Programming Language :: Python :: 3.9',
8379
'Programming Language :: Python :: 3.10',
8480
'Programming Language :: Python :: 3.11',
81+
'Programming Language :: Python :: 3.12',
82+
'Programming Language :: Python :: 3.13',
8583
'Programming Language :: Python :: Implementation :: CPython',
8684
'Programming Language :: Python :: Implementation :: PyPy',
8785
'Intended Audience :: Developers',
8886
'Topic :: Software Development :: Libraries',
8987
'Topic :: Software Development :: Libraries :: Python Modules',
9088
'Topic :: Utilities',
9189
],
90+
python_requires='>=3.10',
9291
ext_modules=ext_modules,
9392
install_requires=[],
9493
tests_require=['cython', 'pytest', 'coverage'],

test-requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Cython==0.29.32
2-
pytest==7.2.0
3-
pytest-cov==4.0.0
1+
Cython>=3.0
2+
pytest>=7.2.0
3+
pytest-cov>=4.0.0

0 commit comments

Comments
 (0)