-
Notifications
You must be signed in to change notification settings - Fork 6
366 lines (358 loc) · 14 KB
/
python_package.yml
File metadata and controls
366 lines (358 loc) · 14 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
jobs:
conda_build:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
os: ["ubuntu-latest", "windows-2022"]
python-version: ["3.10", "3.11", "3.12"]
numpy-version: [1.26]
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Miniconda
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: "conda_build"
miniforge-version: latest
use-mamba: true
auto-update-conda: false
channels: conda-forge
channel-priority: flexible
show-channel-urls: true
- name: Install dependencies (Windows)
if: ${{ matrix.os == 'windows-2022' }}
run: |
set -ex
conda config --set unsatisfiable_hints_check_depth 0 # setting unsatisfiable_hints=False is broken
python dev_tools/gen_requirements.py --out conda_reqs.txt conda
# boa-0.15 broken for Windows (see https://github.com/conda-forge/conda-forge.github.io/issues/1960)
mamba install -q -y --override-channels -c conda-forge -c defaults "boa>0.15" --file conda_reqs.txt
mamba list
- name: Install dependencies (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
set -ex
conda config --set unsatisfiable_hints_check_depth 0 # setting unsatisfiable_hints=False is broken
python dev_tools/gen_requirements.py --out conda_reqs.txt conda
mamba install -q -y --override-channels -c conda-forge -c defaults --file conda_reqs.txt
mamba list
- name: Build package
id: build_package
run: |
set -ex
conda config --set conda_build.pkg_format 2 # create .conda package format
conda config --set conda_build.zstd_compression_level 19 # set .conda package format compression level
export BUILD_VERSION=$(python -c "from setuptools_scm import get_version; print(get_version(version_scheme='post-release'))")
echo "BUILD_VERSION=${BUILD_VERSION}" >> "$GITHUB_OUTPUT"
mkdir conda_pkgs_output
echo "python: " ${{ matrix.python-version }} > ./conda_variant.yaml
echo "numpy: " ${{ matrix.numpy-version }} >> ./conda_variant.yaml
conda mambabuild conda_recipe --override-channels -c conda-forge -c defaults --output-folder ./conda_pkgs_output --variant-config-files ./conda_variant.yaml
- name: Publish artifacts
uses: actions/upload-artifact@v4
with:
name: conda-build-artifacts-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.numpy-version }}
path: conda_pkgs_output/*/riptide_cpp-*.conda
if-no-files-found: "error"
outputs:
build_version: ${{steps.build_package.outputs.BUILD_VERSION}}
pypi_build:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
os: [windows-2022]
python-version: ["3.10", "3.11", "3.12"]
numpy-version: [1.26]
include:
# only one python/numpy combo needed for sdist
- os: ubuntu-latest
python-version: "3.12"
numpy-version: 1.26
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
# Set fetch-depth to 0 so all history is retrieved; this is needed so we get the git tags
# which we use for setting the package version (via setuptools-scm).
fetch-depth: 0
- name: Setup Miniconda
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: "pypi_build"
python-version: ${{ matrix.python-version }}
miniforge-version: latest
use-mamba: true
auto-update-conda: false
channels: conda-forge
channel-priority: flexible
show-channel-urls: true
- name: Configure Conda
run: |
conda config --set unsatisfiable_hints_check_depth 0 # setting unsatisfiable_hints=False is broken
- name: Install PyPI dependencies
run: |
python dev_tools/gen_requirements.py --out pypi_reqs.txt pypi
mamba create -q -y -n pypi_build python=${{ matrix.python-version }} --file pypi_reqs.txt
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools-scm wheel
python -m pip install numpy==${{ matrix.numpy-version }}.*
- name: Package wheel
if: ${{ matrix.os == 'windows-2022' }}
run: |
python -m build --wheel
- name: Package sources
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
python -m build --sdist
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.numpy-version }}
path: dist/
if-no-files-found: error
conda_test:
needs: [conda_build]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
os: ["ubuntu-latest", "windows-2022"]
python-version: ["3.10", "3.11"]
numpy-version: [1.23, 1.24, 1.25, 1.26]
include:
- os: "ubuntu-latest"
python-version: "3.12"
numpy-version: "1.26"
- os: "windows-2022"
python-version: "3.12"
numpy-version: "1.26"
env:
ANACONDA_USER: rtosholdings
BUILD_VERSION: ${{needs.conda_build.outputs.build_version}}
steps:
- name: Checkout repo (sparse)
uses: actions/checkout@v4
with:
sparse-checkout: dev_tools
sparse-checkout-cone-mode: false
- name: Setup Miniconda
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: "conda_test"
miniforge-version: latest
use-mamba: true
auto-update-conda: false
channels: conda-forge
channel-priority: flexible
show-channel-urls: true
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: conda-build-artifacts-*
merge-multiple: true
path: conda_pkgs_output/
- name: Install dependencies
run: |
set -ex
ls -lF
mamba install -q -y --override-channels -c conda-forge -c defaults conda-index
mamba list
- name: Init testing package
run: |
set -ex
python -m conda_index ./conda_pkgs_output
mamba create -q -y -n conda_test --override-channels -c ./conda_pkgs_output -c ${ANACONDA_USER} -c conda-forge -c defaults python=${{ matrix.python-version }} numpy=${{ matrix.numpy-version }} riptable "riptide_cpp==${BUILD_VERSION}"
mamba list
python -c 'import riptable; print(riptable, riptable.__version__); print(riptable.rc, riptable.rc.__version__)'
python dev_tools/gen_requirements.py --out tests_reqs.txt tests
mamba install -q -y --override-channels -c conda-forge -c defaults --file tests_reqs.txt
conda list
- name: Test riptable
run: |
set -ex
python -m pytest --pyargs riptable.tests
# disable tooling integration tests until they work
# ipython -m pytest riptable/test_tooling_integration
# disable hypothesis tests until they run faster, are more consistent, and are easier to investigate
# pytest --hypothesis-show-statistics -k test_ -m 'not xfail' riptable/hypothesis_tests
pypi_test:
needs: [pypi_build]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
os: [ubuntu-latest, windows-2022]
python-version: ["3.10", "3.11"]
numpy-version: [1.23, 1.24, 1.25, 1.26]
include:
- os: "ubuntu-latest"
python-version: "3.12"
numpy-version: "1.26"
- os: "windows-2022"
python-version: "3.12"
numpy-version: "1.26"
steps:
- name: Checkout repo (sparse)
uses: actions/checkout@v4
with:
sparse-checkout: dev_tools
sparse-checkout-cone-mode: false
- name: Setup Miniconda
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: "pypi_test"
python-version: ${{ matrix.python-version }}
miniforge-version: latest
use-mamba: true
auto-update-conda: false
channels: conda-forge
channel-priority: flexible
show-channel-urls: true
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: build-artifacts-*
merge-multiple: true
path: dist/
- name: Configure Conda
run: |
conda config --set unsatisfiable_hints_check_depth 0 # setting unsatisfiable_hints=False is broken
- name: Install PyPI dependencies
run: |
python dev_tools/gen_requirements.py --out pypi_reqs.txt pypi
mamba create -q -y -n pypi_test python=${{ matrix.python-version }} --file pypi_reqs.txt
- name: Configure Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
echo "PYPI_TEST_PACKAGE=riptide_cpp*.gz" >> $GITHUB_ENV
- name: Configure Windows
if: ${{ matrix.os == 'windows-2022' }}
run: |
PYPI_ABI_VER=$(echo ${{ matrix.python-version }} | tr -d '.')
PYPI_TEST_PACKAGE="riptide_cpp*-cp${PYPI_ABI_VER}-*.whl"
echo "PYPI_TEST_PACKAGE=${PYPI_TEST_PACKAGE}" >> $GITHUB_ENV
- name: Install built riptide_cpp
run: |
# Pip install the locally built package, along with all dependencies.
ls ./dist/${PYPI_TEST_PACKAGE}
# Pin build-constraints for numpy (see https://github.com/pypa/pip/issues/9542#issuecomment-1242347397)
echo "numpy==${{ matrix.numpy-version }}.*" > constraints.txt
PIP_CONSTRAINT=constraints.txt pip install -v riptable ./dist/${PYPI_TEST_PACKAGE}
python -c 'import riptable; print(riptable, riptable.__version__); print(riptable.rc, riptable.rc.__version__)'
- name: Setting up riptable tests
# Get just the latest riptable package (first explicitly install its deps)
run: |
python dev_tools/gen_requirements.py --out runtime_reqs.txt runtime
python dev_tools/gen_requirements.py --out tests_reqs.txt tests
pip install -r runtime_reqs.txt -r tests_reqs.txt
conda list
- name: Riptable test with pytest
run: |
python -m pytest --pyargs riptable.tests
#- name: Riptable tooling integration tests
# run: |
# ipython -m pytest riptable/test_tooling_integration
# disable hypothesis tests until they run faster, are more consistent, and are easier to investigate
#- name: Riptable property based hypothesis tests
# run: |
# pytest --hypothesis-show-statistics -k test_ -m 'not xfail' riptable/hypothesis_tests
conda_deploy:
if: ${{ github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' }}
needs: [conda_build, conda_test, pypi_test]
runs-on: ubuntu-latest
env:
# pin to py3.11, as anaconda-client broken on py3.12 (see https://github.com/Anaconda-Platform/anaconda-client/issues/689)
python_version: 3.11
ANACONDA_USER: rtosholdings
ANACONDA_TOKEN: ${{ secrets.anaconda_token }}
steps:
- name: Setup Miniconda
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: "conda_deploy"
python-version: ${{ env.python_version }}
miniforge-version: latest
use-mamba: true
auto-update-conda: false
channels: conda-forge
channel-priority: flexible
show-channel-urls: true
- name: Install dependencies
shell: bash -l {0}
run: |
mamba install anaconda-client -q -y
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: conda-build-artifacts-*
merge-multiple: true
path: conda_pkgs_output/
- name: Upload to Anaconda
shell: bash -l {0}
run: |
set -ex
anaconda --token "${ANACONDA_TOKEN}" upload --label main --user ${ANACONDA_USER} ./conda_pkgs_output/*/riptide_cpp-*.conda
pypi_deploy:
# deploys build artifacts to PyPI
if: ${{ github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' }}
needs: [pypi_build, pypi_test, conda_test]
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: build-artifacts-*
merge-multiple: true
path: dist/
- name: Publish artifacts to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
set -ex
twine upload dist/* --verbose