-
Notifications
You must be signed in to change notification settings - Fork 18
167 lines (145 loc) · 5.89 KB
/
pypi.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
162
163
164
165
166
167
name: Publish to PyPI
on:
workflow_dispatch:
inputs:
tag:
description: Git tag to publish (default to current commit)
default: ''
jobs:
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- run: pip install platformdirs
# Step credit: https://github.com/Cryptex-github/ril-py/blob/main/.github/workflows/py-binding.yml
- name: Display cibuildwheel cache dir
id: cibuildwheel-cache
run: |
from platformdirs import user_cache_path
import os
with open(os.getenv('GITHUB_OUTPUT'), 'w') as f:
f.write(f"dir={str(user_cache_path(appname='cibuildwheel', appauthor='pypa'))}")
shell: python
- name: Cache cibuildwheel
id: cache-cibuildwheel
uses: actions/cache@v4
with:
path: ${{ steps.cibuildwheel-cache.outputs.dir }}
key: cibuildwheel-cache-${{ matrix.os }}
- name: Cache test files
id: cache-test-files
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/bpcells-pytest-data-cache
key: test-files-cache-${{ matrix.os }}
- name: Cache dependency libs
id: cache-libs
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/lib-cache
key: lib-cache-v2-${{ matrix.os }}
- name: Install dependency libs (Windows)
if: steps.cache-libs.outputs.cache-hit != 'true' && runner.os == 'Windows'
run: |
vcpkg install hdf5 eigen3 highway[contrib] zlib
vcpkg export --raw hdf5 eigen3 highway zlib --output-dir=${{ github.workspace }} --name=vcpkg-export
XCOPY /I /E ${{ github.workspace }}\vcpkg-export\installed\x64-windows ${{ github.workspace }}/lib-cache
- name: Install dependency libs (Linux / Mac)
if: steps.cache-libs.outputs.cache-hit != 'true' && runner.os != 'Windows'
run: |
python python/scripts/install_deps.py ${{ github.workspace }}/lib-cache
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.1
with:
package-dir: python
env:
CIBW_ENVIRONMENT_LINUX: >-
CXX="ccache g++"
CIBW_BEFORE_ALL_LINUX: >
LIB_CACHE=/host/$LIB_CACHE bash {package}/scripts/install_ccache_linux.sh &&
cp -r /host/${{ github.workspace }}/lib-cache/* /usr/local
# We need to set MACOSX_DEPLOYMENT_TARGET="10.15" on macos-13 because otherwise
# it tries to target a MacOS verision before std::filesystem is available (10.9 currently)
CIBW_ENVIRONMENT_MACOS: >-
CXX="ccache g++"
CPATH="${{ github.workspace }}/lib-cache/include"
LIBRARY_PATH="${{ github.workspace }}/lib-cache/lib:${{ github.workspace }}/lib-cache/lib64"
${{ matrix.os == 'macos-13' && 'MACOSX_DEPLOYMENT_TARGET="10.15"' || '' }}
CIBW_BEFORE_ALL_MACOS: >
brew install ccache
# VCPKG_BINARY_SOURCES from: https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-actions-cache
CIBW_ENVIRONMENT_WINDOWS: >-
LIBRARY_PATH="${{ github.workspace }}/lib-cache\\lib"
CPATH="${{ github.workspace }}/lib-cache\\include"
BPCELLS_PYTEST_DATA_CACHE="${{ github.workspace }}/bpcells-pytest-data-cache"
# As of 8/26/2024, a delvewheel dependency version bump (pefile) broke delvewheel, so pin these
CIBW_BEFORE_ALL_WINDOWS: >-
pip install delvewheel==1.8.0 pefile==2023.2.7
# See https://github.com/adang1345/delvewheel/issues/54 for explanation of `--add-path C:/Windows/System32`
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
delvewheel repair --add-path C:/vcpkg/installed/x64-windows/bin --add-path C:/Windows/System32 --wheel-dir {dest_dir} {wheel}
CIBW_TEST_REQUIRES: pytest h5py anndata
CIBW_TEST_COMMAND: BPCELLS_PYTEST_DATA_CACHE="${{ github.workspace }}/bpcells-pytest-data-cache" pytest {package}/tests
# Data cache folder is already set
CIBW_TEST_COMMAND_WINDOWS: pytest {package}/tests
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build-sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a source tarball
run: python3 -m build --sdist python
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: sdist
path: python/dist/
publish-to-testpypi:
name: Publish Python package to TestPyPI
needs:
- build-wheels
- build-sdist
runs-on: ubuntu-latest
environment:
name: pypi
url: https://test.pypi.org/p/bpcells
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# Our .whl files are nested two-layers deep, so this will do
# twine upload dist/*/*.whl
packages-dir: dist/*
repository-url: https://test.pypi.org/legacy/