-
-
Notifications
You must be signed in to change notification settings - Fork 35
132 lines (110 loc) · 3.73 KB
/
build-python-wheels.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
name: Python Packages
on:
push:
branches: [ develop ]
tags: [ "v*" ]
# following two lines must be commented out before merging, we don't want to run this on PRs
# but for testing this we run this on PRs
# pull_request:
# branches: [ develop ]
jobs:
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools setuptools-rust build
- name: Build sdist
working-directory: ./python
run: bash build-sdist.sh
- uses: actions/upload-artifact@v4
with:
name: artifact-sdist
path: python/dist/*
build-linux-wheels:
name: Build Linux Python Wheels (+PGO)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download dictionary
run: bash fetch_dictionary.sh "20220519" "core"
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: eiennohito/gha-manylinux-build@master
with:
script: python/build-wheels-manylinux-pgo.sh
- uses: actions/upload-artifact@v4
with:
name: artifact-manylinux
path: python/dist/*manylinux*
build-non-linux-wheels:
name: Build wheels on ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macOS-latest]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools setuptools_rust build
- name: Add aarch64/x86 target for Rust
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
if: startsWith(matrix.os, 'macOS')
- name: Build wheel
working-directory: ./python
run: python -m build --wheel
env:
ARCHFLAGS: -arch x86_64 -arch arm64
MACOSX_DEPLOYMENT_TARGET: 10.12
- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}-${{ matrix.python-version }}
path: python/dist/*.whl
upload-to-pypi: # run only if all have succeeded
needs: [ build-sdist, build-non-linux-wheels, build-linux-wheels ]
# https://stackoverflow.com/questions/58475748/github-actions-how-to-check-if-current-push-has-new-tag-is-new-release
if: startsWith(github.ref, 'refs/tags/v') # only for tags
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
path: dist/
merge-multiple: true
- name: List files to upload
run: ls -R dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
verbose: true