forked from scipy/scipy
-
Notifications
You must be signed in to change notification settings - Fork 5
437 lines (383 loc) · 17.1 KB
/
linux.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
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
name: Linux tests
on:
push:
branches:
- maintenance/**
- fix-wrong-interpreter
pull_request:
branches:
- main
- maintenance/**
permissions:
contents: read # to fetch code (actions/checkout)
env:
CCACHE_DIR: "${{ github.workspace }}/.ccache"
INSTALLDIR: "build-install"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
get_commit_message:
name: Get commit message
uses: ./.github/workflows/commit_message.yml
test_meson:
name: mypy (py3.10) & dev deps (py3.12), fast, dev.py
needs: get_commit_message
# If using act to run CI locally the github object does not exist and
# the usual skipping should not be enforced
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.10', '3.12'] # this run will use python dev versions when available
maintenance-branch:
- ${{ contains(github.ref, 'maintenance/') || contains(github.base_ref, 'maintenance/') }}
exclude:
- maintenance-branch: true
python-version: '3.12'
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'environment.yml'
- name: Install Ubuntu dependencies
run: |
# NOTE: not the same OpenBLAS version as in upstream CI (I'm being lazy here)
sudo apt-get update
sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev gfortran libgmp-dev libmpfr-dev libsuitesparse-dev ccache libmpc-dev
- name: Install Python packages
if: matrix.python-version == '3.10'
run: |
python -m pip install numpy cython pytest pytest-xdist pytest-timeout pybind11 mpmath gmpy2 pythran ninja meson click rich-click doit pydevtool pooch hypothesis
- name: Install Python packages from repositories
if: matrix.python-version == '3.12' # this run will use python dev versions when available
run: |
python -m pip install git+https://github.com/numpy/numpy.git
python -m pip install ninja cython pytest pybind11 pytest-xdist pytest-timeout click rich-click doit pydevtool pooch hypothesis "setuptools<67.3"
python -m pip install git+https://github.com/serge-sans-paille/pythran.git
python -m pip install git+https://github.com/mesonbuild/meson.git
- name: Prepare compiler cache
id: prep-ccache
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@v3
id: cache-ccache
# Reference: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
# NOTE: The caching strategy is modeled in a way that it will always have a unique cache key for each workflow run
# (even if the same workflow is run multiple times). The restore keys are not unique and for a partial match, they will
# return the most recently created cache entry, according to the GitHub Action Docs.
with:
path: ${{ steps.prep-ccache.outputs.dir }}
# Restores ccache from either a previous build on this branch or on main
key: ${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-${{ steps.prep-ccache.outputs.timestamp }}
# This evaluates to `Linux Tests-3.10-ccache-linux-` which is not unique. As the CI matrix is expanded, this will
# need to be updated to be unique so that the cache is not restored from a different job altogether.
restore-keys: |
${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-
- name: Setup build and install scipy
run: |
python dev.py build --werror
- name: Ccache performance
shell: bash -l {0}
run: ccache -s
- name: Check installation
run: |
pushd tools
python check_installation.py ${{ env.INSTALLDIR }}
./check_pyext_symbol_hiding.sh ../build
popd
- name: Mypy
if: matrix.python-version == '3.10'
run: |
# Packages that are only needed for their annotations
python -m pip install mypy==1.10.0 types-psutil typing_extensions
python -m pip install pybind11 sphinx
python -u dev.py mypy
- name: Test SciPy
run: |
export OMP_NUM_THREADS=2
python dev.py --no-build test -j2 -- --durations 10 --timeout=60
#################################################################################
test_venv_install:
name: Install into venv, cluster only, pyAny/npAny, pip+cluster.test()
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- name: Install Ubuntu dependencies
run: |
# We're not running the full test suite here, only testing the install
# into a venv is working, so leave out optional dependencies. That's
# also why we can get away with an old version of OpenBLAS from Ubuntu
sudo apt-get update
sudo apt-get install -y python3-dev libopenblas-dev pkg-config gfortran
- name: Create venv, install SciPy
run: |
python -m venv ../venvs/scipy-venv
source ../venvs/scipy-venv/bin/activate
# Note that this uses build isolation. That's why we don't need build
# dependencies to be installed in the venv itself.
python -m pip install . -vv
- name: Basic imports and tests
run: |
source ../venvs/scipy-venv/bin/activate
cd ..
python -c "import scipy"
python -c "import scipy.linalg"
python -m pip install pytest hypothesis
python -c "from scipy import cluster; cluster.test()"
- name: Create venv inside source tree
# This is a regression test for gh-16312
run: |
python -m venv .venv
source .venv/bin/activate
# Install build dependencies. Use meson-python from its main branch,
# most convenient to test in this job because we're using pip without
# build isolation here.
python -m pip install numpy pybind11 pythran cython pytest ninja hypothesis
python -m pip install git+https://github.com/mesonbuild/meson-python.git
# Non-isolated build, so we use dependencies installed inside the source tree
python -m pip install -U pip # need pip >=23 for `--config-settings`
python -m pip install . --no-build-isolation --config-settings=compile-args=-j2
# Basic tests
cd ..
python -c "import scipy"
python -c "import scipy.linalg"
python -c "from scipy import cluster; cluster.test()"
#################################################################################
python_debug:
# also uses the vcs->sdist->wheel route.
name: Python-debug & ATLAS & sdist+wheel, fast, py3.10/npMin, pip+pytest
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-22.04 # provides python3.10-dbg
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- name: Configuring Test Environment
run: |
sudo apt-get update
sudo apt install python3-dbg python3-dev libatlas-base-dev liblapack-dev gfortran ccache libgmp-dev libmpfr-dev libmpc-dev
python3-dbg --version # just to check
python3-dbg -c 'import sys; print("Python debug build:", hasattr(sys, "gettotalrefcount"))'
- name: Build SciPy
run: |
python3-dbg -m pip install build
python3-dbg -m build -Csetup-args=-Dbuildtype=debugoptimized -Csetup-args=-Dblas=blas-atlas -Csetup-args=-Dlapack=lapack-atlas -Ccompile-args=-j2
python3-dbg -m pip install dist/scipy*.whl
- name: Testing SciPy
run: |
cd doc
python3-dbg -m pip install pytest pytest-xdist pytest-timeout mpmath gmpy2 threadpoolctl pooch hypothesis
python3-dbg -m pytest --pyargs scipy -n2 --durations=10 -m "not slow"
#################################################################################
gcc9:
# Purpose is to examine builds with oldest-supported gcc and test with pydata/sparse.
name: Oldest GCC & pydata/sparse, fast, py3.10/npMin, pip+pytest
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Setup system dependencies
run: |
sudo apt-get -y update
sudo apt install -y g++-9 gcc-9 gfortran-9
sudo apt install -y libatlas-base-dev liblapack-dev libgmp-dev \
libmpfr-dev libmpc-dev pkg-config libsuitesparse-dev liblapack-dev
- name: Setup Python build deps
run: |
pip install build meson-python ninja pythran pybind11 cython "numpy>=2.0.0b1"
- name: Build wheel and install
run: |
set -euo pipefail
export PYTHONOPTIMIZE=2
# specify which compilers to use using environment variables
CC=gcc-9 CXX=g++-9 FC=gfortran-9 python -m build --wheel --no-isolation -Csetup-args=-Dblas=blas-atlas -Csetup-args=-Dlapack=lapack-atlas -Ccompile-args=-j2
python -m pip install dist/scipy*.whl
- name: Install test dependencies
run: |
# Downgrade numpy to oldest supported version
pip install gmpy2 threadpoolctl mpmath pooch pytest pytest-xdist==2.5.0 pytest-timeout hypothesis sparse "numpy==1.23.5"
- name: Run tests
run: |
# can't be in source directory
pushd $RUNNER_TEMP
export PYTHONOPTIMIZE=2
python -m pytest --pyargs scipy -n2 --durations=10
popd
#################################################################################
prerelease_deps_coverage_64bit_blas:
# TODO: re-enable ILP64 build.
name: Prerelease deps & coverage report, full, py3.10/npMin & py3.11/npPre, dev.py
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-latest
strategy:
matrix:
# Both use numpy 2.x-dev at build time; 3.10 job then downgrades to
# lowest supported NumPy version in order to test ABI compatibility.
python-version: ['3.10', '3.11']
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Ubuntu dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgmp-dev libmpfr-dev libmpc-dev ccache gfortran
- name: Caching Python dependencies
uses: actions/cache@v3
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-prerelease
- name: Install Python packages
run: |
python -m pip install cython pythran ninja meson-python pybind11 click rich_click pydevtool
# Note: matplotlib not installed here to avoid issues around numpy 2.0
# (it can be put back after matplotlib has made a 2.0-compatible
# release on PyPI.
python -m pip install --pre --upgrade pytest pytest-cov pytest-xdist mpmath gmpy2 threadpoolctl pooch hypothesis
# TODO: once the scipy_ symbol prefix issue is fixed, install
# scipy-openblas32 from the pre-releases bucket again (see gh-19640)
python -m pip install "scipy-openblas32<=0.3.23.293.2"
# Install numpy last, to ensure we get 2.0.0-dev (avoid possible <2.0 constraints).
python -m pip install --pre --upgrade --timeout=60 -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
- name: Prepare compiler cache
id: prep-ccache
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@v3
id: cache-ccache
with:
path: ${{ steps.prep-ccache.outputs.dir }}
# Restores ccache from either a previous build on this branch or on main
key: ${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-prerelease-${{ steps.prep-ccache.outputs.timestamp }}
restore-keys: |
${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-prerelease-
- name: Build and install SciPy
run: |
python dev.py build --gcov --with-scipy-openblas
- name: Ccache performance
shell: bash -l {0}
run: ccache -s
- name: Downgrade NumPy from 2.0-dev to lowest supported
if: matrix.python-version == '3.10'
run: |
python -m pip install "numpy==1.23.5"
- name: Test SciPy
run: |
export OPENBLAS_NUM_THREADS=1
python dev.py --no-build test -j2 --mode full -- --cov --cov-report term-missing
#################################################################################
linux_32bit:
name: 32-bit, fast, py3.10/npMin, dev.py
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-latest
# I tried running directly in a container:, using the image: and options:
# entries. Unfortunately at this time options: does not seem to listen to
# --platform linux/i386.
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- name: build + test
run: |
set -euo pipefail
docker pull quay.io/pypa/manylinux2014_i686
docker run -v $(pwd):/scipy --platform=linux/i386 quay.io/pypa/manylinux2014_i686 /bin/bash -c "cd /scipy && \
uname -a && \
basedir=\$(python3.10 tools/openblas_support.py) && \
cp -r \$basedir/lib/* /usr/local/lib && \
cp \$basedir/include/* /usr/local/include && \
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && \
python3.10 -m venv test && \
source test/bin/activate && \
python -m pip install doit click rich_click pydevtool meson ninja && \
python -m pip install numpy==1.23.5 cython pybind11 pytest pytest-timeout pytest-xdist pytest-env 'Pillow<10.0.0' mpmath pythran pooch meson hypothesis && \
LD_LIBRARY_PATH=/usr/local/lib python dev.py build && \
LD_LIBRARY_PATH=/usr/local/lib python dev.py test"
#################################################################################
distro_multiple_pythons:
# Purpose is to build for a non-default Python interpreter in a Linux distro
# For such a build config, `python`/`python3` executables may not have
# build dependencies like Cython or NumPy installed.
name: non-default Python interpreter, fast, py3.10/npMin, pip+pytest
# needs: get_commit_message
# if: >
# needs.get_commit_message.outputs.message == 1
# && (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- name: Setup system dependencies
run: |
sudo apt-get -y update
# `python3-dev` yields Python 3.10 on Ubuntu 22.04
sudo apt install -y python3-dev python3.11-dev ninja-build pkg-config libatlas-base-dev liblapack-dev
- name: Setup Python build deps
run: |
python3.11 -m pip install build meson-python pythran pybind11 cython numpy
# Things should work with a `meson` executable from a different Python env
python3.10 -m pip install meson
python3.11 -m pip install meson-python packaging pyproject-toml --no-deps
- name: Build wheel and install
run: |
python3.11 -m build -wnx -Csetup-args=-Dblas=blas-atlas -Csetup-args=-Dlapack=lapack-atlas -Ccompile-args=-j2
python3.11 -m pip install dist/*.whl
- name: Install test dependencies
run: |
python3.11 -m pip install pytest hypothesis
- name: Run tests
run: |
# Just a small subset of tests; this will be fine if the build
# succeeds (that's the real purpose of this job)
pushd $RUNNER_TEMP
python3.11 -m pytest --pyargs scipy.cluster
python3.11 -m pytest --pyargs scipy.linalg
popd