Skip to content

Commit fdaf7a6

Browse files
committed
test using cibuildwheels for platform dependent libs
1 parent 44412a1 commit fdaf7a6

File tree

1 file changed

+126
-44
lines changed

1 file changed

+126
-44
lines changed

.github/workflows/build-package.yml

Lines changed: 126 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -75,71 +75,153 @@ jobs:
7575
pip install pytest scipy
7676
pytest -v
7777
78-
commit_shared_libs:
78+
build_wheels:
79+
name: Build wheels (${{ matrix.os }})
7980
needs: test
80-
runs-on: ubuntu-latest
81-
permissions:
82-
id-token: write
81+
runs-on: ${{ matrix.os }}
82+
83+
strategy:
84+
matrix:
85+
os: [windows-latest, ubuntu-latest]
8386

8487
steps:
85-
- name: checkout repo
86-
uses: actions/checkout@v4
88+
- uses: actions/checkout@v4
89+
90+
- name: Set up Python
91+
uses: actions/setup-python@v5
8792
with:
88-
token: ${{ secrets.GITHUB_TOKEN }}
93+
python-version: "3.11"
8994

90-
- name: download deterministicGaussianSampling libs artifact
95+
- name: Download deterministicGaussianSampling libs
9196
uses: actions/download-artifact@v4
9297
with:
9398
name: deterministicGaussianSampling-libs
9499
path: external_libs
95100

96-
- name: extract and place shared libraries
101+
- name: Extract shared libraries (Linux)
102+
if: runner.os == 'Linux'
103+
run: |
104+
unzip external_libs/linux.zip -d external_libs_unpacked
105+
mkdir -p src/deterministic_gaussian_sampling/lib/linux/bin
106+
cp -r external_libs_unpacked/lib/* \
107+
src/deterministic_gaussian_sampling/lib/linux/bin/
108+
109+
- name: Extract shared libraries (Windows)
110+
if: runner.os == 'Windows'
111+
shell: pwsh
97112
run: |
98-
set -e
113+
Expand-Archive external_libs/windows.zip external_libs_unpacked -Force
114+
New-Item -ItemType Directory `
115+
-Path src\deterministic_gaussian_sampling\lib\windows\bin -Force
116+
Copy-Item external_libs_unpacked\bin\* `
117+
src\deterministic_gaussian_sampling\lib\windows\bin -Recurse -Force
99118
100-
# Linux libs
101-
if [ -f external_libs/linux.zip ]; then
102-
mkdir -p external_libs_unpacked/linux
103-
unzip -o external_libs/linux.zip -d external_libs_unpacked/linux
119+
- name: Install cibuildwheel
120+
run: pip install cibuildwheel
104121

105-
mkdir -p src/deterministic_gaussian_sampling/lib/linux/bin
106-
cp -r external_libs_unpacked/linux/lib/* \
107-
src/deterministic_gaussian_sampling/lib/linux/bin/
108-
fi
122+
- name: Build wheels
123+
run: cibuildwheel --output-dir dist
124+
env:
125+
# python versions to build
126+
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-* cp313-*"
109127

110-
# Windows libs
111-
if [ -f external_libs/windows.zip ]; then
112-
mkdir -p external_libs_unpacked/windows
113-
unzip -o external_libs/windows.zip -d external_libs_unpacked/windows
128+
# skip musllinux
129+
CIBW_SKIP: "*-musllinux_*"
114130

115-
mkdir -p src/deterministic_gaussian_sampling/lib/windows/bin
116-
cp -r external_libs_unpacked/windows/bin/* \
117-
src/deterministic_gaussian_sampling/lib/windows/bin/
118-
fi
131+
# manylinux for Linux
132+
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64
119133

120-
- name: install build tools
121-
run: |
122-
python -m pip install --upgrade pip
123-
pip install build
134+
- name: Upload wheels
135+
uses: actions/upload-artifact@v4
136+
with:
137+
name: wheels-${{ runner.os }}
138+
path: dist/*.whl
139+
140+
publish_testpypi:
141+
needs: build_wheels
142+
runs-on: ubuntu-latest
143+
permissions:
144+
id-token: write
124145

125-
- name: build package
126-
run: python -m build
146+
steps:
147+
- name: download all wheels
148+
uses: actions/download-artifact@v4
149+
with:
150+
pattern: wheels-*
151+
merge-multiple: true
152+
path: dist
127153

128154
- name: Publish to TestPyPI
129155
uses: pypa/gh-action-pypi-publish@release/v1
130156
with:
131157
repository-url: https://test.pypi.org/legacy/
132158

133-
- name: commit shared libraries
134-
run: |
135-
git config user.name "github-actions[bot]"
136-
git config user.email "github-actions[bot]@[email protected]"
137-
138-
git add -f src/deterministic_gaussian_sampling/lib
139159

140-
if git diff --cached --quiet; then
141-
echo "No changes to commit"
142-
else
143-
git commit -m "Update deterministicGaussianSampling shared libraries"
144-
git push
145-
fi
160+
# commit_shared_libs:
161+
# needs: test
162+
# runs-on: ubuntu-latest
163+
# permissions:
164+
# id-token: write
165+
166+
# steps:
167+
# - name: checkout repo
168+
# uses: actions/checkout@v4
169+
# with:
170+
# token: ${{ secrets.GITHUB_TOKEN }}
171+
172+
# - name: download deterministicGaussianSampling libs artifact
173+
# uses: actions/download-artifact@v4
174+
# with:
175+
# name: deterministicGaussianSampling-libs
176+
# path: external_libs
177+
178+
# - name: extract and place shared libraries
179+
# run: |
180+
# set -e
181+
182+
# # Linux libs
183+
# if [ -f external_libs/linux.zip ]; then
184+
# mkdir -p external_libs_unpacked/linux
185+
# unzip -o external_libs/linux.zip -d external_libs_unpacked/linux
186+
187+
# mkdir -p src/deterministic_gaussian_sampling/lib/linux/bin
188+
# cp -r external_libs_unpacked/linux/lib/* \
189+
# src/deterministic_gaussian_sampling/lib/linux/bin/
190+
# fi
191+
192+
# # Windows libs
193+
# if [ -f external_libs/windows.zip ]; then
194+
# mkdir -p external_libs_unpacked/windows
195+
# unzip -o external_libs/windows.zip -d external_libs_unpacked/windows
196+
197+
# mkdir -p src/deterministic_gaussian_sampling/lib/windows/bin
198+
# cp -r external_libs_unpacked/windows/bin/* \
199+
# src/deterministic_gaussian_sampling/lib/windows/bin/
200+
# fi
201+
202+
# - name: install build tools
203+
# run: |
204+
# python -m pip install --upgrade pip
205+
# pip install build
206+
207+
# - name: build package
208+
# run: python -m build
209+
210+
# - name: Publish to TestPyPI
211+
# uses: pypa/gh-action-pypi-publish@release/v1
212+
# with:
213+
# repository-url: https://test.pypi.org/legacy/
214+
215+
# - name: commit shared libraries
216+
# run: |
217+
# git config user.name "github-actions[bot]"
218+
# git config user.email "github-actions[bot]@[email protected]"
219+
220+
# git add -f src/deterministic_gaussian_sampling/lib
221+
222+
# if git diff --cached --quiet; then
223+
# echo "No changes to commit"
224+
# else
225+
# git commit -m "Update deterministicGaussianSampling shared libraries"
226+
# git push
227+
# fi

0 commit comments

Comments
 (0)