Skip to content

Commit 8ae866b

Browse files
committed
[DEV-4306] Build wheels for multiple platforms and Python versions
1 parent a8ae123 commit 8ae866b

File tree

4 files changed

+104
-25
lines changed

4 files changed

+104
-25
lines changed

.github/workflows/push.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,21 @@ jobs:
3838
test:
3939
name: Unit tests
4040
if: "!contains(github.event.head_commit.message, 'Bump version')"
41-
runs-on: ubuntu-20.04
41+
runs-on: ${{ matrix.os }}
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
os: [ ubuntu-latest, macos-latest, windows-latest ]
46+
cibw_python: [ "cp38-*", "cp39-*", "cp310-*" ]
47+
cibw_arch: [ "auto64" ]
48+
49+
defaults:
50+
run:
51+
shell: bash
52+
4253
steps:
4354
- name: actions/checkout
44-
uses: actions/checkout@v2
55+
uses: actions/checkout@v3
4556
- name: actions/cache pip
4657
uses: actions/cache@v2
4758
with:
@@ -58,6 +69,9 @@ jobs:
5869
- name: test
5970
run: |
6071
set -x
72+
if [ "${{ matrix.os }}" == "macos-latest" ]; then
73+
(sysctl -a | grep machdep.cpu.leaf7_features | grep AVX2) || exit
74+
fi
6175
python3 -m unittest discover .
6276
bump_version:
6377
name: Bump the version

.github/workflows/release.yml

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,80 @@
1-
name: Release
1+
name: Publish Python 🐍 packages 📦 to PyPI
22

33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- 'v?[0-9]+.[0-9]+.[0-9]+'
77

88
jobs:
9-
release-package:
10-
if: "contains(github.event.head_commit.message, 'Bump version')"
11-
name: Release package on PyPI
12-
runs-on: ubuntu-20.04
9+
build-sdist:
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
PIP_DISABLE_PIP_VERSION_CHECK: 1
14+
1315
steps:
14-
- uses: actions/checkout@v2
15-
- name: Install dependencies
16-
run: |
17-
pip3 install -U setuptools twine wheel auditwheel
18-
echo "$HOME/.local/bin" >> $GITHUB_PATH
19-
- name: Build package
16+
- uses: actions/checkout@v3
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
21+
- name: Build source distribution
2022
run: |
21-
python3 setup.py bdist_wheel sdist --format=gztar
22-
mv dist/*.whl .
23-
auditwheel repair --plat manylinux_2_24_x86_64 -w dist *.whl
24-
rm *.whl
25-
ls
26-
ls dist
27-
twine check dist/*
28-
- name: Publish package to PyPI
23+
pip install -U setuptools pip
24+
python setup.py sdist
25+
26+
- uses: actions/upload-artifact@v2
27+
with:
28+
name: dist
29+
path: dist/*.tar.*
30+
31+
build-wheels:
32+
runs-on: ${{ matrix.os }}
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
os: [ ubuntu-latest, macos-latest, windows-latest ]
37+
cibw_python: [ "cp38-*", "cp39-*", "cp310-*" ]
38+
cibw_arch: [ "auto64" ]
39+
40+
defaults:
41+
run:
42+
shell: bash
43+
44+
env:
45+
PIP_DISABLE_PIP_VERSION_CHECK: 1
46+
47+
steps:
48+
- uses: actions/checkout@v3
49+
50+
- uses: pypa/cibuildwheel@v2.2.2
51+
env:
52+
CIBW_BUILD_VERBOSITY: 1
53+
CIBW_BUILD: ${{ matrix.cibw_python }}
54+
CIBW_ARCHS: ${{ matrix.cibw_arch }}
55+
56+
- uses: actions/upload-artifact@v2
57+
with:
58+
name: dist
59+
path: wheelhouse/*.whl
60+
61+
publish:
62+
needs: [build-sdist, build-wheels]
63+
runs-on: ubuntu-latest
64+
65+
steps:
66+
- uses: actions/checkout@v3
67+
68+
- uses: actions/download-artifact@v2
69+
with:
70+
name: dist
71+
path: dist/
72+
73+
- run: |
74+
ls -al dist/
75+
76+
- name: Upload to PyPI
2977
uses: pypa/gh-action-pypi-publish@master
3078
with:
3179
user: __token__
32-
password: "${{ secrets.PYPI_API_TOKEN }}"
80+
password: ${{ secrets.PYPI_API_TOKEN }}

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel", "numpy>=1.21.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.cibuildwheel]
6+
build-frontend = "build"

setup.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@
33

44
from setuptools import Extension, setup
55

6+
# GCP N2
7+
GCC_OPT = [
8+
"-march=haswell",
9+
"-maes",
10+
"-mno-pku",
11+
"-mno-sgx",
12+
"--param", "l1-cache-line-size=64",
13+
"--param", "l1-cache-size=32",
14+
"--param", "l2-cache-size=33792",
15+
]
16+
617
CXX_ARGS = {
7-
"Darwin": ["-std=c++17", "-march=native", "-ftree-vectorize"],
8-
"Linux": ["-fopenmp", "-std=c++17", "-march=native", "-ftree-vectorize"],
18+
"Darwin": ["-std=c++17", *GCC_OPT, "-mavx2", "-ftree-vectorize"],
19+
"Linux": ["-fopenmp", "-std=c++17", *GCC_OPT, "-mabm", "-mavx2", "-ftree-vectorize"],
920
"Windows": ["/openmp", "/std:c++latest", "/arch:AVX2"],
1021
}
1122

0 commit comments

Comments
 (0)