-
Notifications
You must be signed in to change notification settings - Fork 22
92 lines (86 loc) · 3.41 KB
/
python.yml
File metadata and controls
92 lines (86 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Build and publish Python package
on:
push:
tags:
- 'v*'
workflow_dispatch:
# How cross compilation works with PyO3/maturin-action:
# - For Linux targets, it uses Docker.
# - For other targets, it runs on the host (Docker mostly only supports Linux containers).
# - On Windows, the action appears to just use the host binary. Cross compilation to a different arch doesn't seem to be yet supported.
# - On macOS, the action appears to be able to target aarch64 just fine despite running on an Intel Mac.
# - We don't need to set up Rust, the action will do so itself.
# - We don't need to set up Python:
# - On macOS, the action auto finds all versions: https://github.com/PyO3/maturin-action/blob/a3013db91b2ef2e51420cfe99ee619c8e72a17e6/src/index.ts#L732
# - On Linux, a Docker container is used which has its own Rust, Python, etc.
# - On Windows, we use the "generate-import-lib" feature on pyo3: https://www.maturin.rs/distribution#cross-compile-to-windows
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-15, windows-2022]
target: [x86_64, aarch64]
python:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
exclude:
# Building for Windows aarch64 isn't ready yet.
- os: windows-2022
target: aarch64
# TODO For now, disable aarch64 Linux cross compilation, due to issues around Clang, rust-rocksdb, and the manylinux container.
- os: ubuntu-latest
target: aarch64
- os: macos-15
target: x86_64
steps:
- uses: actions/checkout@v1
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
# https://github.com/PyO3/maturin-action/issues/49#issuecomment-1166242843
args: --release --sdist --strip -m ./corenn-py/Cargo.toml -i ${{ matrix.python }}
sccache: true
# Use more modern baseline.
manylinux: 2_28
rust-toolchain: nightly
rustup-components: rustfmt
before-script-linux: |
# Install clang for both Debian/Ubuntu and RHEL/CentOS
if command -v apt-get &>/dev/null; then
apt-get update
apt-get -yq install clang
elif command -v dnf &>/dev/null; then
dnf -y install clang
elif command -v yum &>/dev/null; then
yum -y install clang
else
echo "No supported package manager found for installing clang." >&2
exit 1
fi
- name: Install Python build tools (macOS)
if: runner.os == 'macOS'
run: sudo pip install --upgrade twine
- name: Install Python build tools (Linux, Windows)
if: runner.os != 'macOS'
run: pip install --upgrade twine
- name: Pack and publish package
shell: bash
working-directory: ./corenn-py
run: |
cat << 'EOF' > "$HOME/.pypirc"
[pypi]
username = __token__
password = ${{ secrets.PYPI_API_TOKEN }}
EOF
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
# For idempotency, ignore any existing built wheels that have already been successfully uploaded.
twine upload --skip-existing ../target/wheels/*
else
ls -al ../target/wheels/*
fi