Skip to content

Commit

Permalink
feat(build): split Linux builds into x86_64 and aarch64 jobs
Browse files Browse the repository at this point in the history
This commit improves Linux wheel building by separating architectures:

- Split Linux builds into separate jobs for x86_64 and aarch64
- Simplify maturin configuration to handle platform tags automatically
- Add static linking for aarch64 builds
- Update artifact naming to distinguish between architectures
- Keep manylinux2014 compatibility for all builds

These changes provide a more robust approach to cross-compilation by:
1. Using separate build jobs to avoid platform conflicts
2. Letting maturin handle platform-specific details
3. Ensuring proper static linking for ARM64 builds
4. Maintaining compatibility with pip's platform tags
  • Loading branch information
dirvine committed Nov 28, 2024
1 parent 6213b0c commit bf02794
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
50 changes: 41 additions & 9 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,30 @@ jobs:
path: dist/*.whl
if-no-files-found: error

linux:
linux-x86:
runs-on: ubuntu-latest
# Add permissions to job
permissions:
id-token: write
contents: read
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
target: [x86_64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --user cffi
python -m pip install --user patchelf
python -m pip install --upgrade pip
python -m pip install cffi
python -m pip install patchelf
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist
target: x86_64
manylinux: "2014"
args: --release --out dist --compatibility manylinux2014
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
Expand All @@ -100,6 +99,39 @@ jobs:
path: dist/*.whl
if-no-files-found: error

linux-aarch64:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install cffi
python -m pip install patchelf
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: aarch64
manylinux: "2014"
args: --release --out dist --compatibility manylinux2014
target-features: +crt-static
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels-aarch64
path: dist/*.whl
if-no-files-found: error

sdist:
runs-on: ubuntu-latest
# Add permissions to job
Expand All @@ -123,7 +155,7 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
needs: [macos, windows, linux, sdist]
needs: [macos, windows, linux-x86, linux-aarch64, sdist]
# Keep existing permissions
permissions:
id-token: write
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ bindings = "pyo3"
develop = true
strip = true
compatibility = "manylinux2014"
platform-tags = ["manylinux2014_x86_64", "manylinux2014_aarch64"]

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down

0 comments on commit bf02794

Please sign in to comment.