-
Notifications
You must be signed in to change notification settings - Fork 78
129 lines (106 loc) · 4.27 KB
/
build_deploy_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
name: Upload Python Package
on:
push:
branches:
- main
- develop
tags:
- "**"
jobs:
build_wheels:
runs-on: ${{ matrix.buildplat[0] }}
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
# Github Actions doesn't support pairing matrix values together, let's improvise
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
buildplat:
# should also be able to do multi-archs on a single entry, e.g.
# [windows-2019, win*, "AMD64 x86"]. However, those two require a different compiler setup
# so easier to separate out here.
- [ ubuntu-latest, manylinux, x86_64]
- [ ubuntu-latest, manylinux, i686]
- [ macos-latest, macosx, x86_64 ]
- [ macos-11, macosx, arm64] # cross compiled
- [ windows-2019, win, AMD64 ]
python: [[ "cp37", "3.7" ], [ "cp38", "3.8" ], [ "cp39", "3.9" ],
[ "cp310", "3.10" ], [ "cp311", "3.11" ], ["cp312", "3.12"]]
name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: install-rtools needed for windows
if: ${{ runner.os == 'Windows' }}
run: |
choco install rtools --version=4.0.0.20220206 --no-progress --force
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2
- name: Build Solcore
if: >-
( ! contains(matrix.buildplat[2], 'arm64' ) )
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}*
CIBW_ARCHS: ${{ matrix.buildplat[2] }}
CIBW_ENVIRONMENT_PASS_LINUX: RUNNER_OS
CIBW_BEFORE_BUILD_MACOS: brew reinstall gfortran
CIBW_BEFORE_BUILD_LINUX: python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true"
- name: Set extra env for arm64
if: >-
( contains(matrix.buildplat[2], 'arm64' ) )
run: |
echo "LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" >> $GITHUB_ENV;
echo "LIBRARY_PATH=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" >> $GITHUB_ENV;
- name: Cross-build Solcore for arm64
if: ${{ (matrix.python[0] != 'cp37') && ( contains(matrix.buildplat[2], 'arm64') )}} # image not present for python3.7
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}*
CIBW_ARCHS: ${{ matrix.buildplat[2] }}
CIBW_ENVIRONMENT: CFLAGS='-target arm64-apple-macos'
CIBW_BEFORE_BUILD_MACOS: bash {project}/build_tools/cibw_before_build_macos_arm.sh && meson setup --cross-file={project}/build_tools/x86_64-w64-arm64.ini build
CIBW_CONFIG_SETTINGS_MACOS: builddir=build
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
upload_wheels:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- name: Download sdist artifact
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Download wheel artifacts
uses: actions/download-artifact@v3
with:
path: wheelhouse
- name: Move wheels to dist directory
run: |
cp wheelhouse/**/*.whl dist
ls dist/
- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: dist/
skip_existing: true