-
Notifications
You must be signed in to change notification settings - Fork 2
161 lines (145 loc) · 5.58 KB
/
python.yml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Python CI
on:
push:
paths:
- crates/algo_models_ffi/**
- crates/algo_models/**
- "!*.md"
branches:
- main
- master
tags:
- "*"
pull_request:
paths:
- crates/algo_models_ffi/**
- creates/algo_models/**
- packages/python/**
- "!*.md"
workflow_dispatch:
permissions:
contents: read
env:
CRATE: algo_models
# Python >= 3.8 is needed to support manylinux_x_y tags (unless you want to manually update pip)
# Python 3.10 was chosen because it is currently the most popular according to https://mayeut.github.io/manylinux-timeline/
PYTHON_VERSION: "3.10"
jobs:
build_and_test:
defaults:
run:
shell: bash
runs-on: ${{ matrix.target.runner }}
strategy:
matrix:
target:
# name: The name of the target passed to cargo build
# runner: The GitHub runner to use
- name: x86_64-pc-windows-msvc
runner: windows-latest
- name: aarch64-pc-windows-msvc
runner: windows-latest
- name: x86_64-apple-darwin
runner: macos-13
- name: aarch64-apple-darwin
runner: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target.name }}
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip" # caching pip dependencies
- run: pip install maturin
- name: Install python dependencies
run: pip install -r crates/${{ env.CRATE }}_ffi/tests/py/requirements.txt
- name: maturin build
run: |
cd crates/${{ env.CRATE }}_ffi
maturin build --release --target ${{ matrix.target.name }}
- name: pytest
# Until GitHub makes windows arm64 runners publicly available, there is not a simple way to test aarch64-pc-windows-msvc
# GitHub is currently working on making them available but no ETA: https://github.com/actions/runner-images/issues/10820
if: matrix.target.name != 'aarch64-pc-windows-msvc'
run: |
set -e
pip install target/wheels/*.whl
cd crates/${{ env.CRATE }}_ffi
pytest
linux_build_and_test:
defaults:
run:
shell: bash
runs-on: ubuntu-22.04${{ matrix.arch == 'aarch64' && '-arm' || '' }}
strategy:
matrix:
# i686, ppc64le, s390x are also supported but not running them for now to reduce CI time
# We might not ever need to support them, but we can make that decision later
# As a useful datapoint, PyNaCl only builds x86_64 and aarch64 wheels
# https://github.com/pyca/pynacl/blob/9ffa598e47242bf783aae23c20c31e876c438f1a/.github/workflows/wheel-builder.yml#L32-L41
arch: [aarch64, x86_64]
libc: [gnu, musl]
exclude:
- arch: s390x
libc: musl
- arch: i686
libc: musl
- arch: ppc64le
libc: musl
env:
# See https://github.com/pypa/manylinux for more information on manylinux
# Generally it's good to try to support the glibc version from two RHEL releases ago (roughly within EOM period)
# The current RHEL release (as of 2/7/2025) is 9 and the glibc version from RHEL 7 was 2.17 (aka manylinux2014)
MANYLINUX: ${{ matrix.libc == 'musl' && 'musllinux_1_2' || 'manylinux2014' }}
TARGET: ${{ matrix.arch == 'ppc64le' && 'powerpc64le' || matrix.arch }}-unknown-linux-${{ matrix.libc }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.arch != 'aarch64' && matrix.arch != 'x86_64'
uses: docker/setup-qemu-action@v3
- name: Start Container
env:
container: quay.io/pypa/${{ env.MANYLINUX }}_${{ matrix.arch }}
run: |
set -e
docker pull ${{ env.container }}
docker run --name build-container \
-d \
-v ${{ github.workspace }}:/workspace \
-e CARGO_HOME="/usr/local" \
${{ env.container }} \
tail -f /dev/null
- name: Install Rustup
env:
RUN: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-host ${{ env.TARGET }}
run: docker exec build-container bash -c "$RUN"
- name: rustup target add
env:
RUN: rustup target add ${{ env.TARGET }}
run: docker exec build-container bash -c "$RUN"
- name: pip install maturin[patchelf]
env:
RUN: python${{ env.PYTHON_VERSION }} -m pip install maturin[patchelf]
run: docker exec build-container bash -c "$RUN"
- name: maturin build
env:
RUN: |
cd /workspace/crates/${{ env.CRATE }}_ffi
python${{ env.PYTHON_VERSION }} -m maturin build --release --target ${{ env.TARGET }} --compatibility ${{ env.MANYLINUX }}
run: docker exec build-container bash -c "$RUN"
- name: pip install wheel
env:
RUN: python${{ env.PYTHON_VERSION }} -m pip install /workspace/target/wheels/*.whl
run: docker exec build-container bash -c "$RUN"
- name: pip install test requirements
env:
RUN: python${{ env.PYTHON_VERSION }} -m pip install -r /workspace/crates/${{ env.CRATE }}_ffi/tests/py/requirements.txt
run: docker exec build-container bash -c "$RUN"
- name: pytest
env:
RUN: |
cd /workspace/crates/${{ env.CRATE }}_ffi
python${{ env.PYTHON_VERSION }} -m pytest
run: docker exec build-container bash -c "$RUN"