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
|
name: Linux tests
# This file is meant for testing across supported Python versions, build types
# and interpreters (PyPy, python-dbg, a pre-release Python in summer time),
# build-via-sdist, run benchmarks, measure code coverage, and other build
# options.
on:
push:
branches:
# coverage comparison in the "full" step needs to run on main after merges
- main
pull_request:
branches:
- main
- maintenance/**
paths-ignore:
- '**.pyi'
- '**.md'
- '**.rst'
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
lint:
# To enable this job and subsequent jobs on a fork, comment out:
if: github.repository == 'numpy/numpy' && github.event_name != 'push'
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: '3.11'
- name: Install linter requirements
run:
python -m pip install -r requirements/linter_requirements.txt
- name: Run linter on PR
env:
BASE_REF: ${{ github.base_ref }}
run:
python tools/linter.py
- name: Check Python.h is first file included
run: |
python tools/check_python_h_first.py
smoke_test:
# To enable this job on a fork, comment out:
if: github.repository == 'numpy/numpy'
runs-on: ubuntu-latest
env:
MESON_ARGS: "-Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none"
strategy:
matrix:
version: ["3.11", "3.12", "3.13", "3.14", "3.14t"]
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: ${{ matrix.version }}
- uses: ./.github/meson_actions
pypy:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: 'pypy3.11-v7.3.20'
- name: Setup using scipy-openblas
run: |
python -m pip install -r requirements/ci_requirements.txt
spin config-openblas --with-scipy-openblas=32
- uses: ./.github/meson_actions
debug:
needs: [smoke_test]
runs-on: ubuntu-24.04
if: github.event_name != 'push'
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- name: Install debug Python
run: |
sudo apt-get update
sudo apt-get install python3-dbg ninja-build
- name: Build NumPy and install into venv
run: |
python3-dbg -m venv venv
source venv/bin/activate
pip install -U pip
pip install . -v -Csetup-args=-Dbuildtype=debug -Csetup-args=-Dallow-noblas=true
- name: Install test dependencies
run: |
source venv/bin/activate
pip install -r requirements/test_requirements.txt
- name: Run test suite
run: |
source venv/bin/activate
cd tools
pytest --timeout=600 --durations=10 --pyargs numpy -m "not slow"
full:
# Install as editable, then run the full test suite with code coverage
needs: [smoke_test]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: '3.11'
- name: Install build and test dependencies from PyPI
run: |
pip install -r requirements/build_requirements.txt
pip install -r requirements/test_requirements.txt
- name: Install gfortran and setup OpenBLAS (MacPython build)
run: |
set -xe
sudo apt update
sudo apt install gfortran libgfortran5
python -m pip install -r requirements/ci32_requirements.txt
mkdir -p ./.openblas
python -c"import scipy_openblas32 as ob32; print(ob32.get_pkg_config())" > ./.openblas/scipy-openblas.pc
- name: Install as editable
env:
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas
run: |
pip install -e . --no-build-isolation
- name: Run full test suite
run: |
pytest numpy --durations=10 --timeout=600 --cov-report=html:build/coverage
# TODO: gcov
env:
PYTHONOPTIMIZE: 2
armhf_test:
# Tests NumPy on 32-bit ARM hard-float (armhf) via compatibility mode
# running on aarch64 (ARM 64-bit) GitHub runners.
needs: [smoke_test]
if: github.repository == 'numpy/numpy'
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- name: Creates new container
run: |
docker run --name the_container --interactive \
-v $(pwd):/numpy arm32v7/ubuntu:24.04 /bin/linux32 /bin/bash -c "
apt update &&
apt install -y ninja-build cmake git python3 python-is-python3 python3-dev python3-pip python3-venv
"
docker commit the_container the_container
- name: Meson Build
run: |
docker run --rm -e "TERM=xterm-256color" \
-v $(pwd):/numpy the_container \
/bin/script -e -q -c "/bin/linux32 /bin/bash --noprofile --norc -eo pipefail -c '
cd /numpy &&
python -m venv venv &&
source venv/bin/activate &&
python -m pip install -r /numpy/requirements/build_requirements.txt &&
python -m pip install -r /numpy/requirements/test_requirements.txt &&
spin build
'"
- name: Meson Log
if: always()
run: 'cat build/meson-logs/meson-log.txt'
- name: Run Tests
run: |
docker run --rm -e "TERM=xterm-256color" \
-v $(pwd):/numpy the_container \
/bin/script -e -q -c "/bin/linux32 /bin/bash --noprofile --norc -eo pipefail -c '
cd /numpy && source venv/bin/activate && spin test -m full -- --timeout=600 --durations=10
'"
benchmark:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: '3.11'
- name: Install build and benchmarking dependencies
run: |
sudo apt-get update
sudo apt-get install libopenblas-dev ninja-build
pip install "asv<0.6.5" virtualenv packaging -r requirements/build_requirements.txt
- name: Install NumPy
run: |
spin build -- -Dcpu-dispatch=none
# Ensure to keep the below steps as single-line bash commands (it's a
# workaround for asv#1333, and it may have side-effects on multi-line commands)
- name: Appease asv's need for machine info
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
run: |
asv machine --yes --config benchmarks/asv.conf.json
- name: Run benchmarks
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
run: |
spin bench --quick
# These are run on CircleCI
# - name: Check docstests
# shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
# run: |
# pip install -r requirements/doc_requirements.txt -r requirements/test_requirements.txt
# spin check-docs -v
# spin check-tutorials -v
sdist:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: '3.11'
- name: Install gfortran and setup OpenBLAS (sdist build)
run: |
set -xe
python -m pip install -r requirements/ci_requirements.txt
mkdir -p ./.openblas
python -c"import scipy_openblas64 as ob64; print(ob64.get_pkg_config())" > ./.openblas/scipy-openblas.pc
- name: Build a wheel via an sdist
env:
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas
run: |
pip install build
python -m build
pip install dist/numpy*.whl
- name: Install test dependencies
run: |
pip install -r requirements/test_requirements.txt
- name: Run test suite
run: |
cd tools
pytest --pyargs numpy -m "not slow"
- name: Test SWIG binding
run: |
sudo apt update
sudo apt install make swig
make -C tools/swig/test test
array_api_tests:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- name: Checkout NumPy
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- name: Checkout array-api-tests
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
repository: data-apis/array-api-tests
ref: '3c273cd34d51c64ed893737306d36adab23a94a1' # v2025.05.23
submodules: 'true'
path: 'array-api-tests'
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: '3.11'
- name: Install build and test dependencies from PyPI
run: |
python -m pip install -r requirements/build_requirements.txt
python -m pip install -r requirements/test_requirements.txt
python -m pip install -r array-api-tests/requirements.txt
- name: Build and install NumPy
run: |
python -m pip install . -v -Csetup-args=-Dallow-noblas=true -Csetup-args=-Dcpu-baseline=none -Csetup-args=-Dcpu-dispatch=none
- name: Run the test suite
env:
ARRAY_API_TESTS_MODULE: numpy
PYTHONWARNINGS: 'ignore::UserWarning::,ignore::DeprecationWarning::,ignore::RuntimeWarning::'
run: |
cd ${GITHUB_WORKSPACE}/array-api-tests
pytest array_api_tests -v -c pytest.ini -n 4 --max-examples=1000 --derandomize --disable-deadline --xfails-file ${GITHUB_WORKSPACE}/tools/ci/array-api-xfails.txt
custom_checks:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: '3.11'
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
repository: numpy/numpy-release
path: numpy-release
persist-credentials: false
- name: Check scipy-openblas version in release pipelines
run: |
python tools/check_openblas_version.py --req-files numpy-release/requirements/openblas_requirements.txt
- name: Install build and test dependencies from PyPI
run: |
pip install -r requirements/build_requirements.txt
pip install -r requirements/test_requirements.txt
pip install vulture
- name: Build and install NumPy
run: |
# Install using the fastest way to build (no BLAS, no SIMD)
spin build -j2 -- -Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none
- name: Check build-internal dependencies
run: |
ninja -C build -t missingdeps
- name: Check installed test and stub files
run: |
python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy')
- name: Check for unreachable code paths in Python modules
run: |
# Need the explicit `bash -c` here because `grep` returns exit code 1 for no matches
bash -c "! vulture . --min-confidence 100 --exclude doc/,numpy/distutils/,vendored-meson/ | grep 'unreachable'"
- name: Check usage of install_tag
run: |
rm -rf build-install
./vendored-meson/meson/meson.py install -C build --destdir ../build-install --tags=runtime,python-runtime,devel
python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy') --no-tests
Linux_Python_311_32bit_full:
name: i686, cp311, full
needs: [smoke_test]
runs-on: ubuntu-latest
container:
# There are few options for i686 images at https://quay.io/organization/pypa,
# use the glibc2.28 one
image: quay.io/pypa/manylinux_2_28_i686
steps:
- name: Checkout and initialize submodules
# actions/checkout doesn't work in a container image
run: |
git config --global --add safe.directory $PWD
if [ $GITHUB_EVENT_NAME != pull_request ]; then
git clone --recursive --branch=$GITHUB_REF_NAME https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE
git reset --hard $GITHUB_SHA
else
git clone --recursive https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE
git fetch origin $GITHUB_REF:my_ref_name
git checkout $GITHUB_BASE_REF
git -c user.email="you@example.com" merge --no-commit my_ref_name
fi
git submodule update --init --recursive
- name: build
run: |
python3.11 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements/ci32_requirements.txt
pip install -r requirements/test_requirements.txt
spin config-openblas --with-scipy-openblas=32
export PKG_CONFIG_PATH=$(pwd)/.openblas
python -m pip install . -v -Csetup-args="-Dallow-noblas=false"
- name: test
run: |
source venv/bin/activate
cd tools
python -m pytest --pyargs numpy
|