diff --git a/.github/actions/action.yml b/.github/actions/action.yml index 20a239026e4f..2c271c0c5726 100644 --- a/.github/actions/action.yml +++ b/.github/actions/action.yml @@ -11,7 +11,6 @@ runs: echo DOWNLOAD_OPENBLAS $DOWNLOAD_OPENBLAS echo USE_DEBUG $USE_DEBUG echo NPY_USE_BLAS_ILP64 $NPY_USE_BLAS_ILP64 - echo NUMPY_EXPERIMENTAL_ARRAY_FUNCTION $NUMPY_EXPERIMENTAL_ARRAY_FUNCTION echo USE_ASV $USE_ASV echo PATH $PATH echo python `which python` diff --git a/.github/meson_actions/action.yml b/.github/meson_actions/action.yml index aff70da169bc..fb3042c0ade2 100644 --- a/.github/meson_actions/action.yml +++ b/.github/meson_actions/action.yml @@ -3,27 +3,35 @@ description: "checkout repo, build, and test numpy" runs: using: composite steps: - - name: Install dependencies - shell: bash - run: pip install -r build_requirements.txt - name: Build shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' env: TERM: xterm-256color - run: - spin build -- ${MESON_ARGS[@]} - - name: Check build-internal dependencies - shell: bash - run: - ninja -C build -t missingdeps - - name: Check installed test and stub files + PKG_CONFIG_PATH: ./.openblas + run: | + echo "::group::Installing Build Dependencies" + pip install -r build_requirements.txt + echo "::endgroup::" + echo "::group::Building NumPy" + spin build --clean -- ${MESON_ARGS[@]} + echo "::endgroup::" + + - name: Meson Log shell: bash - run: - python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy') + if: always() + run: | + echo "::group::Meson Log" + cat build/meson-logs/meson-log.txt + echo "::endgroup::" + - name: Test shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' env: TERM: xterm-256color run: | - pip install pytest pytest-xdist hypothesis typing_extensions - spin test -j auto + echo "::group::Installing Test Dependencies" + pip install pytest pytest-xdist hypothesis typing_extensions setuptools + echo "::endgroup::" + echo "::group::Test NumPy" + spin test + echo "::endgroup::" diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml deleted file mode 100644 index e570c5540415..000000000000 --- a/.github/workflows/build_test.yml +++ /dev/null @@ -1,447 +0,0 @@ -name: Build_Test - -on: - push: - branches: - # coverage comparison in the "full" step needs to run on main after merges - - main - pull_request: - branches: - - main - - maintenance/** - -defaults: - run: - shell: bash - -env: - DOWNLOAD_OPENBLAS: 1 - PYTHON_VERSION: 3.9 - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read # to fetch code (actions/checkout) - -jobs: - lint: - if: github.repository == 'numpy/numpy' && github.event_name != 'push' - runs-on: ubuntu-latest - continue-on-error: true - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Install linter requirements - run: - python -m pip install -r linter_requirements.txt - - name: Run linter on PR diff - run: - python tools/linter.py --branch origin/${{ github.base_ref }} - - smoke_test: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - env: - MESON_ARGS: "-Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none" - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/meson_actions - - basic: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - strategy: - matrix: - python-version: ["3.9", "3.10", "3.11", "pypy3.9-v7.3.12"] - env: - EXPECT_CPU_FEATURES: "SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL" - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ matrix.python-version }} - - uses: ./.github/actions - - old_gcc: - needs: [smoke_test] - # provides GCC 7, 8 - runs-on: ubuntu-20.04 - if: github.event_name != 'push' - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - # comes with python3.6 - - name: Install Python3.9 - run: | - sudo apt update - # for add-apt-repository - sudo apt install software-properties-common -y - sudo add-apt-repository ppa:deadsnakes/ppa -y - sudo apt install python3.9-dev ninja-build -y - sudo ln -s /usr/bin/python3.9 /usr/bin/pythonx - pythonx -m pip install --upgrade pip setuptools wheel - pythonx -m pip install -r test_requirements.txt - - name: Install Compilers - run: sudo apt install g++-7 g++-8 -y - - name: Build gcc-7 - run: | - export CC=/usr/bin/gcc-7 - export CXX=/usr/bin/g++-7 - rm -rf build && pythonx setup.py install --user - - name: Runtests gcc-7 - run: pythonx runtests.py -n - - name: Build gcc-8 - run: | - export CC=/usr/bin/gcc-8 - export CXX=/usr/bin/g++-8 - rm -rf build && pythonx setup.py install --user - - name: Runtests gcc-8 - run: pythonx runtests.py -n - - without_optimizations: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - MESON_ARGS: "-Dallow-noblas=true -Ddisable-optimization=true" - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/meson_actions - - with_baseline_only: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - MESON_ARGS: "-Dallow-noblas=true -Dcpu-dispatch=none" - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/meson_actions - - without_avx512: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - MESON_ARGS: "-Dallow-noblas=true -Dcpu-dispatch=SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,AVX2,FMA3" - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/meson_actions - - without_avx512_avx2_fma3: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - MESON_ARGS: "-Dallow-noblas=true -Dcpu-dispatch=SSSE3,SSE41,POPCNT,SSE42,AVX,F16C" - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/meson_actions - - debug: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - USE_DEBUG: 1 - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - uses: ./.github/actions - - blas64: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - NPY_USE_BLAS_ILP64: 1 - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/actions - - full: - needs: [smoke_test] - runs-on: ubuntu-22.04 - env: - USE_WHEEL: 1 - RUN_FULL_TESTS: 1 - RUN_COVERAGE: 1 - INSTALL_PICKLE5: 1 - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/actions - - benchmark: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - PYTHONOPTIMIZE: 2 - BLAS: None - LAPACK: None - ATLAS: None - NPY_BLAS_ORDER: mkl,blis,openblas,atlas,blas - NPY_LAPACK_ORDER: MKL,OPENBLAS,ATLAS,LAPACK - USE_ASV: 1 - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/actions - - relaxed_strides_debug: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - CHECK_BLAS: 1 - NPY_USE_BLAS_ILP64: 1 - NPY_RELAXED_STRIDES_DEBUG: 1 - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/actions - - use_wheel: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - USE_WHEEL: 1 - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/actions - - no_openblas: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - BLAS: None - LAPACK: None - ATLAS: None - DOWNLOAD_OPENBLAS: '' - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/actions - - sdist: - needs: [smoke_test] - runs-on: ubuntu-latest - if: github.event_name != 'push' - env: - USE_SDIST: 1 - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - uses: ./.github/actions - - armv7_simd_test: - needs: [smoke_test] - # make sure this matches the base docker image below - runs-on: ubuntu-22.04 - if: github.event_name != 'push' - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - name: Initialize binfmt_misc for qemu-user-static - run: | - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Creates new container - run: | - # use x86_64 cross-compiler to speed up the build - sudo apt update - sudo apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gfortran-arm-linux-gnueabihf - - docker run --name the_container --interactive -v /:/host -v $(pwd):/numpy arm32v7/ubuntu:22.04 /bin/bash -c " - apt update && - apt install -y git python3 python3-dev python3-pip && - python3 -m pip install -r /numpy/test_requirements.txt - ln -s /host/lib64 /lib64 && - ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu && - ln -s /host/usr/arm-linux-gnueabihf /usr/arm-linux-gnueabihf && - rm -rf /usr/lib/gcc/arm-linux-gnueabihf && ln -s /host/usr/lib/gcc-cross/arm-linux-gnueabihf /usr/lib/gcc/arm-linux-gnueabihf && - rm -f /usr/bin/arm-linux-gnueabihf-gcc && ln -s /host/usr/bin/arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc && - rm -f /usr/bin/arm-linux-gnueabihf-g++ && ln -s /host/usr/bin/arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++ && - rm -f /usr/bin/arm-linux-gnueabihf-gfortran && ln -s /host/usr/bin/arm-linux-gnueabihf-gfortran /usr/bin/arm-linux-gnueabihf-gfortran && - rm -f /usr/bin/arm-linux-gnueabihf-ar && ln -s /host/usr/bin/arm-linux-gnueabihf-ar /usr/bin/arm-linux-gnueabihf-ar && - rm -f /usr/bin/arm-linux-gnueabihf-as && ln -s /host/usr/bin/arm-linux-gnueabihf-as /usr/bin/arm-linux-gnueabihf-as && - rm -f /usr/bin/arm-linux-gnueabihf-ld && ln -s /host/usr/bin/arm-linux-gnueabihf-ld /usr/bin/arm-linux-gnueabihf-ld && - rm -f /usr/bin/arm-linux-gnueabihf-ld.bfd && ln -s /host/usr/bin/arm-linux-gnueabihf-ld.bfd /usr/bin/arm-linux-gnueabihf-ld.bfd - " - docker commit the_container the_container - - name: Build - run: | - sudo docker run --name the_build --interactive -v $(pwd):/numpy -v /:/host the_container /bin/bash -c " - uname -a && - gcc --version && - g++ --version && - arm-linux-gnueabihf-gfortran --version && - python3 --version && - git config --global --add safe.directory /numpy - cd /numpy && - python3 setup.py install - " - docker commit the_build the_build - - name: Run SIMD Tests - run: | - docker run --rm --interactive -v $(pwd):/numpy the_build /bin/bash -c " - cd /numpy && F90=arm-linux-gnueabihf-gfortran python3 runtests.py -n -v -- -k 'test_simd or test_kind' - " - - sde_simd_avx512_test: - # Intel Software Development Emulator (SDE) is used to run a given program - # on a specific instruction set architecture and capture various performance details. - # see https://www.intel.com/content/www/us/en/developer/articles/tool/software-development-emulator.html - needs: [smoke_test] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Install Intel SDE - run: | - curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/732268/sde-external-9.7.0-2022-05-09-lin.tar.xz - mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/ - sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde - - name: Install dependencies - run: python -m pip install -r test_requirements.txt - - name: Build - run: python setup.py build - --simd-test="\$werror AVX512F AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL" - install - # KNM implies KNL - - name: Run SIMD tests (Xeon PHI) - run: sde -knm -- python runtests.py -n -v -- -k test_simd - # ICL implies SKX, CLX and CNL - - name: Run SIMD tests (Ice Lake) - run: sde -icl -- python runtests.py -n -v -- -k test_simd - - intel_spr_sde_test: - needs: [smoke_test] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Install Intel SDE - run: | - curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/784319/sde-external-9.24.0-2023-07-13-lin.tar.xz - mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/ - sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde - - name: Install dependencies - run: | - python -m pip install -r test_requirements.txt - sudo apt install gcc-12 g++-12 - - name: Build and install NumPy - run: | - export CC=/usr/bin/gcc-12 - export CXX=/usr/bin/g++-12 - python setup.py develop - - name: Show config - run: | - python -c "import numpy as np; np.show_config()" - # Run only a few tests, running everything in an SDE takes a long time - # Using pytest directly, unable to use python runtests.py -n -t ... - - name: Run linalg/ufunc/umath tests - run: | - python -m pytest numpy/core/tests/test_umath* numpy/core/tests/test_ufunc.py numpy/linalg/tests/test_* - # Can't run on SDE just yet: see https://github.com/numpy/numpy/issues/23545#issuecomment-1659047365 - #sde -spr -- python -m pytest numpy/core/tests/test_umath* numpy/core/tests/test_ufunc.py numpy/linalg/tests/test_* diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 000000000000..d73de33c7640 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,208 @@ +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 like relaxed-strides. + +on: + push: + branches: + # coverage comparison in the "full" step needs to run on main after merges + - main + pull_request: + branches: + - main + - maintenance/** + +defaults: + run: + shell: bash + +env: + DOWNLOAD_OPENBLAS: 1 + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +jobs: + lint: + if: github.repository == 'numpy/numpy' && github.event_name != 'push' + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.9' + - name: Install linter requirements + run: + python -m pip install -r linter_requirements.txt + - name: Run linter on PR diff + run: + python tools/linter.py --branch origin/${{ github.base_ref }} + + smoke_test: + if: "github.repository == 'numpy/numpy'" + runs-on: ubuntu-latest + env: + MESON_ARGS: "-Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none" + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.9' + - uses: ./.github/meson_actions + + basic: + needs: [smoke_test] + runs-on: ubuntu-latest + if: github.event_name != 'push' + strategy: + matrix: + python-version: ["3.9", "pypy3.9-v7.3.12"] + env: + EXPECT_CPU_FEATURES: "SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL" + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: ${{ matrix.python-version }} + - uses: ./.github/actions + + debug: + needs: [smoke_test] + runs-on: ubuntu-latest + if: github.event_name != 'push' + env: + USE_DEBUG: 1 + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.11' + + - uses: ./.github/actions + + full: + # Build a wheel, install it, then run the full test suite with code coverage + needs: [smoke_test] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.9' + - name: Install build and test dependencies from PyPI + run: | + pip install -r build_requirements.txt + pip install -r test_requirements.txt + - name: Install gfortran and OpenBLAS (MacPython build) + run: | + set -xe + sudo apt install gfortran libgfortran5 + target=$(python tools/openblas_support.py) + sudo cp -r $target/lib/* /usr/lib + sudo cp $target/include/* /usr/include + - name: Build a wheel + run: | + python -m build --wheel --no-isolation --skip-dependency-check + pip install dist/numpy*.whl + - name: Run full test suite + run: | + cd tools + pytest --pyargs numpy --cov-report=html:build/coverage + # TODO: gcov + + benchmark: + needs: [smoke_test] + runs-on: ubuntu-latest + if: github.event_name != 'push' + env: + PYTHONOPTIMIZE: 2 + BLAS: None + LAPACK: None + ATLAS: None + NPY_BLAS_ORDER: mkl,blis,openblas,atlas,blas + NPY_LAPACK_ORDER: MKL,OPENBLAS,ATLAS,LAPACK + USE_ASV: 1 + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.9' + - uses: ./.github/actions + + relaxed_strides_debug: + needs: [smoke_test] + runs-on: ubuntu-latest + if: github.event_name != 'push' + env: + CHECK_BLAS: 1 + NPY_USE_BLAS_ILP64: 1 + NPY_RELAXED_STRIDES_DEBUG: 1 + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.11' + - uses: ./.github/actions + + sdist: + needs: [smoke_test] + runs-on: ubuntu-latest + if: github.event_name != 'push' + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.11' + - name: Install gfortran and OpenBLAS (MacPython build) + run: | + set -xe + sudo apt install gfortran libgfortran5 + target=$(python tools/openblas_support.py) + sudo cp -r $target/lib/* /usr/lib + sudo cp $target/include/* /usr/include + - name: Build a wheel via an sdist + run: | + pip install build + python -m build + pip install dist/numpy*.whl + - name: Install test dependencies + run: | + pip install -r test_requirements.txt + pip install ninja + - name: Run test suite + run: | + cd tools + pytest --pyargs numpy -m "not slow" + diff --git a/.github/workflows/linux_blas.yml b/.github/workflows/linux_blas.yml new file mode 100644 index 000000000000..699381f6584f --- /dev/null +++ b/.github/workflows/linux_blas.yml @@ -0,0 +1,109 @@ +name: BLAS tests (Linux) + +# This file is meant for testing different BLAS/LAPACK flavors and build +# options on Linux. All other yml files for Linux will only test without BLAS +# (mostly because that's easier and faster to build) or with the same 64-bit +# OpenBLAS build that is used in the wheel jobs. +# +# Jobs and their purpose: +# +# - openblas64_setuppy: +# This job uses the default 64-bit build of OpenBLAS with the +# `numpy.distutils`-based build. It can be removed once we remove +# support for those builds. +# - openblas32_stable_nightly: +# Uses the 32-bit OpenBLAS builds, both the latest stable release and a +# nightly build. +# +# TODO: coverage here is limited, we should add non-OpenBLAS libraries and +# exercise the BLAS-related build options (see `meson_options.txt`). + +on: + pull_request: + branches: + - main + - maintenance/** + +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: + openblas64_setuppy: + runs-on: ubuntu-latest + if: "github.repository == 'numpy/numpy'" + env: + DOWNLOAD_OPENBLAS: 1 + NPY_USE_BLAS_ILP64: 1 + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.11' + - uses: ./.github/actions + + openblas32_stable_nightly: + if: "github.repository == 'numpy/numpy'" + runs-on: ubuntu-latest + strategy: + matrix: + USE_NIGHTLY_OPENBLAS: [false, true] + env: + USE_NIGHTLY_OPENBLAS: ${{ matrix.USE_NIGHTLY_OPENBLAS }} + name: "Test Linux (${{ matrix.USE_NIGHTLY_OPENBLAS && 'nightly' || 'stable' }} OpenBLAS)" + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + pip install -r build_requirements.txt + # Install OpenBLAS + set -xe + if [[ $USE_NIGHTLY_OPENBLAS == "true" ]]; then + target=$(python tools/openblas_support.py --nightly) + else + target=$(python tools/openblas_support.py) + fi + sudo cp -r $target/lib/* /usr/lib + sudo cp $target/include/* /usr/include + + - name: Build + shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' + env: + TERM: xterm-256color + run: + spin build -- --werror + + - 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: Test + shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' + env: + TERM: xterm-256color + LD_LIBRARY_PATH: "/usr/local/lib/" # to find libopenblas.so.0 + + run: | + pip install pytest pytest-xdist hypothesis typing_extensions + spin test -j auto diff --git a/.github/workflows/linux_meson.yml b/.github/workflows/linux_meson.yml deleted file mode 100644 index ebbd52997e42..000000000000 --- a/.github/workflows/linux_meson.yml +++ /dev/null @@ -1,355 +0,0 @@ -name: BLAS tests (Linux) - -# This file is meant for testing different BLAS/LAPACK flavors and build -# options on Linux. All other yml files for Linux will only test without BLAS -# (mostly because that's easier and faster to build) or with the same 64-bit -# OpenBLAS build that is used in the wheel jobs. -# -# Jobs and their purpose: -# -# - openblas32_stable_nightly: -# Uses the 32-bit OpenBLAS builds, both the latest stable release -# and a nightly build. -# - openblas_no_pkgconfig_fedora: -# Test OpenBLAS on Fedora. Fedora doesn't ship .pc files for OpenBLAS, -# hence this exercises the "system dependency" detection method. -# - flexiblas_fedora: -# Tests FlexiBLAS (the default on Fedora for its own packages), via -# pkg-config. FlexiBLAS allows runtime switching of BLAS/LAPACK -# libraries, which is a useful capability (not tested in this job). -# - openblas_cmake: -# Tests whether OpenBLAS LP64 is detected correctly when only CMake -# and not pkg-config is installed. -# - netlib: -# Installs vanilla blas/lapack, which is the last option tried in -# auto-detection. -# - mkl: -# Tests MKL installed from PyPI (because easiest/fastest, if broken) in -# 3 ways: both LP64 and ILP64 via pkg-config, and then using the -# Single Dynamic Library (SDL, or `libmkl_rt`). -# - blis: -# Simple test for LP64 via pkg-config -# - atlas: -# Simple test for LP64 via pkg-config - -on: - pull_request: - branches: - - main - - maintenance/** - -defaults: - run: - shell: bash - -env: - PYTHON_VERSION: 3.11 - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read # to fetch code (actions/checkout) - -jobs: - meson_spin: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - strategy: - matrix: - USE_NIGHTLY_OPENBLAS: [false, true] - env: - USE_NIGHTLY_OPENBLAS: ${{ matrix.USE_NIGHTLY_OPENBLAS }} - name: "Test Linux (${{ matrix.USE_NIGHTLY_OPENBLAS && 'nightly' || 'stable' }} OpenBLAS)" - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Install dependencies - run: | - pip install -r build_requirements.txt - # Install OpenBLAS - set -xe - if [[ $USE_NIGHTLY_OPENBLAS == "true" ]]; then - target=$(python tools/openblas_support.py --nightly) - else - target=$(python tools/openblas_support.py) - fi - sudo cp -r $target/lib/* /usr/lib - sudo cp $target/include/* /usr/include - - name: Build - shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' - env: - TERM: xterm-256color - run: - spin build -- --werror - - 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: Test - shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' - env: - TERM: xterm-256color - LD_LIBRARY_PATH: "/usr/local/lib/" # to find libopenblas.so.0 - run: | - export NPY_RUN_MYPY_IN_TESTSUITE=1 - pip install pytest pytest-xdist hypothesis typing_extensions - spin test -j auto - - - openblas_no_pkgconfig_fedora: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - container: fedora:39 - name: "OpenBLAS (Fedora, no pkg-config, LP64/ILP64)" - steps: - - name: Install system dependencies - run: | - dnf install git gcc-gfortran g++ python3-devel openblas-devel -y - - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - submodules: recursive - fetch-depth: 0 - - - name: Install dependencies - run: | - pip install -r build_requirements.txt - pip install pytest hypothesis typing_extensions - - - name: Build (LP64) - run: spin build -- -Dblas=openblas -Dlapack=openblas -Ddisable-optimization=true - - - name: Test - run: spin test -- numpy/linalg - - - name: Build (ILP64) - run: | - rm -rf build - spin build -- -Duse-ilp64=true -Ddisable-optimization=true - - - name: Test - run: spin test -- numpy/linalg - - - flexiblas_fedora: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - container: fedora:39 - name: "FlexiBLAS (LP64, ILP64 on Fedora)" - steps: - - name: Install system dependencies - run: | - dnf install git gcc-gfortran g++ python3-devel flexiblas-devel -y - - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - submodules: recursive - fetch-depth: 0 - - - name: Install dependencies - run: | - pip install -r build_requirements.txt - pip install pytest hypothesis typing_extensions - - - name: Build - run: spin build -- -Ddisable-optimization=true - - - name: Test - run: spin test -- numpy/linalg - - - name: Build (ILP64) - run: | - rm -rf build - spin build -- -Ddisable-optimization=true -Duse-ilp64=true - - - name: Test (ILP64) - run: spin test -- numpy/linalg - - - openblas_cmake: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - name: "OpenBLAS with CMake" - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install -r build_requirements.txt - pip install pytest pytest-xdist hypothesis typing_extensions - sudo apt-get install libopenblas-dev cmake - sudo apt-get remove pkg-config - - - name: Build - run: spin build -- -Ddisable-optimization=true - - - name: Test - run: spin test -j auto -- numpy/linalg - - - netlib: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - name: "Netlib BLAS/LAPACK" - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install -r build_requirements.txt - sudo apt-get install liblapack-dev pkg-config - - - name: Build - run: | - spin build -- -Ddisable-optimization=true - - - name: Test - run: | - pip install pytest pytest-xdist hypothesis typing_extensions - spin test -j auto -- numpy/linalg - - - mkl: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - name: "MKL (LP64, ILP64, SDL)" - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install -r build_requirements.txt - pip install pytest pytest-xdist hypothesis typing_extensions - pip install mkl mkl-devel - - - name: Repair MKL pkg-config files and symlinks - run: | - # MKL 2023.2 works when installed from conda-forge (except for `-iomp` - # and `-tbb` pkg-config files), Spack, or with the standalone Intel - # installer. The standalone installer is the worst option, since it's - # large and clumsy to install and requires running a setvars.sh script - # before things work. The PyPI MKL packages are broken and need the - # fixes in this step. For details, see - # https://github.com/conda-forge/intel_repack-feedstock/issues/34 - cd $Python3_ROOT_DIR/lib/pkgconfig - sed -i 's/\/intel64//g' mkl*.pc - # add the expected .so -> .so.2 symlinks to fix linking - cd .. - for i in $( ls libmkl*.so.2 ); do ln -s $i ${i%.*}; done - - - name: Build with defaults (LP64) - run: | - pkg-config --libs mkl-dynamic-lp64-seq # check link flags - spin build -- -Ddisable-optimization=true - - - name: Test - run: spin test -- numpy/linalg - - - name: Build with ILP64 - run: | - git clean -xdf > /dev/null - pkg-config --libs mkl-dynamic-ilp64-seq - spin build -- -Duse-ilp64=true -Ddisable-optimization=true - - - name: Test - run: spin test -- numpy/linalg - - - name: Build without pkg-config (default options, SDL) - run: | - git clean -xdf > /dev/null - pushd $Python3_ROOT_DIR/lib/pkgconfig - rm mkl*.pc - popd - export MKLROOT=$Python3_ROOT_DIR - spin build -- -Ddisable-optimization=true - - - name: Test - run: spin test -- numpy/linalg - - blis: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - name: "BLIS" - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install -r build_requirements.txt - pip install pytest pytest-xdist hypothesis typing_extensions - sudo apt-get install libblis-dev libopenblas-dev pkg-config - - - name: Add BLIS pkg-config file - run: | - # Needed because blis.pc missing in Debian: - # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989076 - # The alternative here would be to use another distro or Miniforge - sudo cp tools/ci/_blis_debian.pc /usr/lib/x86_64-linux-gnu/pkgconfig/blis.pc - # Check if the patch works: - pkg-config --libs blis - pkg-config --cflags blis - - - name: Build - run: spin build -- -Dblas=blis -Ddisable-optimization=true - - - name: Test - run: spin test -- numpy/linalg - - atlas: - if: "github.repository == 'numpy/numpy'" - runs-on: ubuntu-latest - name: "ATLAS" - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - submodules: recursive - fetch-depth: 0 - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - pip install -r build_requirements.txt - pip install pytest pytest-xdist hypothesis typing_extensions - sudo apt-get install libatlas-base-dev pkg-config - - - name: Build - run: spin build -- -Dblas=blas-atlas -Dlapack=lapack-atlas -Ddisable-optimization=true - - - name: Test - run: spin test -- numpy/linalg - diff --git a/.github/workflows/linux_simd.yml b/.github/workflows/linux_simd.yml new file mode 100644 index 000000000000..f8b694124d41 --- /dev/null +++ b/.github/workflows/linux_simd.yml @@ -0,0 +1,212 @@ +name: Linux SIMD tests + +# This file is meant for testing different SIMD-related build options and +# optimization levels. See `meson_options.txt` for the available build options. +# +# Jobs and their purposes: +# +# - baseline_only: +# Focuses on completing as quickly as possible and acts as a filter for other, more resource-intensive jobs. +# Utilizes only the default baseline targets (e.g., SSE3 on X86_64) without enabling any runtime dispatched features. +# +# - old_gcc: +# Tests the oldest supported GCC version with default CPU/baseline/dispatch settings. +# +# - without_optimizations: +# Completely disables all SIMD optimizations and other compiler optimizations such as loop unrolling. +# +# - native: +# Tests against the host CPU features set as the baseline without enabling any runtime dispatched features. +# Intended to assess the entire NumPy codebase against host flags, even for code sections lacking handwritten SIMD intrincis. +# +# - without_avx512/avx2/fma3: +# Uses runtime SIMD dispatching but disables AVX2, FMA3, and AVX512. +# Intended to evaluate 128-bit SIMD extensions without FMA support. +# +# - without_avx512: +# Uses runtime SIMD dispatching but disables AVX512. +# Intended to evaluate 128-bit/256-bit SIMD extensions. +# +# - intel_sde: +# Executes only the SIMD tests for various AVX512 SIMD extensions under the Intel Software Development Emulator (SDE). +# +on: + pull_request: + branches: + - main + - maintenance/** + +defaults: + run: + shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' + +env: + TERM: xterm-256color + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +jobs: + baseline_only: + if: "github.repository == 'numpy/numpy'" + runs-on: ubuntu-latest + env: + MESON_ARGS: "-Dallow-noblas=true -Dcpu-dispatch=none" + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + with: + python-version: '3.9' + - uses: ./.github/meson_actions + name: Build/Test + + old_gcc: + if: github.event_name != 'push' + needs: [baseline_only] + runs-on: ubuntu-latest + env: + MESON_ARGS: "-Dallow-noblas=true" + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + with: + python-version: '3.9' + + - name: Install GCC/8/9 + run: | + echo "deb http://archive.ubuntu.com/ubuntu focal main universe" | sudo tee /etc/apt/sources.list.d/focal.list + sudo apt update + sudo apt install -y g++-8 g++-9 + + - name: Enable gcc-8 + run: | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 1 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 1 + + - uses: ./.github/meson_actions + name: Build/Test against gcc-8 + + - name: Enable gcc-9 + run: | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 2 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 2 + + - uses: ./.github/meson_actions + name: Build/Test against gcc-9 + + specialize: + needs: [baseline_only] + runs-on: ubuntu-latest + if: github.event_name != 'push' + continue-on-error: true + strategy: + matrix: + BUILD_PROP: + #- [ + #"without optimizations", + #"-Dallow-noblas=true -Ddisable-optimization=true", + #"3.12" + #] + - [ + "native", + "-Dallow-noblas=true -Dcpu-baseline=native -Dcpu-dispatch=none", + "3.11" + ] + - [ + "without avx512", + "-Dallow-noblas=true -Dcpu-dispatch=SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,AVX2,FMA3", + "3.10" + ] + - [ + "without avx512/avx2/fma3", + "-Dallow-noblas=true -Dcpu-dispatch=SSSE3,SSE41,POPCNT,SSE42,AVX,F16C", + "3.9" + ] + + env: + MESON_ARGS: ${{ matrix.BUILD_PROP[1] }} + + name: "${{ matrix.BUILD_PROP[0] }}" + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + with: + python-version: "${{ matrix.BUILD_PROP[2] }}" + - uses: ./.github/meson_actions + name: Build/Test + + intel_sde: + needs: [baseline_only] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + with: + python-version: '3.11' + + - name: Install Intel SDE + run: | + curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/784319/sde-external-9.24.0-2023-07-13-lin.tar.xz + mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/ + sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde + + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y g++-13 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 1 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 1 + python -m pip install -r build_requirements.txt + python -m pip install pytest pytest-xdist hypothesis typing_extensions + + - name: Build + run: spin build -- -Dallow-noblas=true -Dcpu-baseline=avx512f -Dtest-simd='BASELINE,AVX512_KNL,AVX512_KNM,AVX512_SKX,AVX512_CLX,AVX512_CNL,AVX512_ICL,AVX512_SPR' + + - name: Meson Log + if: always() + run: cat build/meson-logs/meson-log.txt + + - name: SIMD tests (KNM) + run: | + export NUMPY_SITE=$(realpath build-install/usr/lib/python*/site-packages/) + export PYTHONPATH="$PYTHONPATH:$NUMPY_SITE" + cd build-install && + sde -knm -- python -c "import numpy; numpy.show_config()" && + sde -knm -- python -m pytest $NUMPY_SITE/numpy/core/tests/test_simd* + + - name: SIMD tests (SPR) + run: | + export NUMPY_SITE=$(realpath build-install/usr/lib/python*/site-packages/) + export PYTHONPATH="$PYTHONPATH:$NUMPY_SITE" + cd build-install && + sde -spr -- python -c "import numpy; numpy.show_config()" && + sde -spr -- python -m pytest $NUMPY_SITE/numpy/core/tests/test_simd* + + # Can't run on SDE just yet: see https://github.com/numpy/numpy/issues/23545#issuecomment-1659047365 + # + #- name: linalg/ufunc/umath tests (SPR) + # run: | + # export NUMPY_SITE=$(realpath build-install/usr/lib/python*/site-packages/) + # export PYTHONPATH="$PYTHONPATH:$NUMPY_SITE" + # cd build-install && + # sde -spr -- python -c "import numpy; numpy.show_config()" && + # sde -spr -- python -m pytest $NUMPY_SITE/numpy/core/tests/test_umath* \ + # $NUMPY_SITE/numpy/core/tests/test_ufunc.py \ + # $NUMPY_SITE/numpy/linalg/tests/test_* + diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 000000000000..c89b8e11ec95 --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,67 @@ +name: Run MyPy + +# Mypy is too slow to run as part of regular CI. The purpose of the jobs in +# this file is to cover running Mypy across: +# +# - OSes: Linux, Windows and macOS +# - Python versions: lowest/highest supported versions, and an intermediate one +# +# The build matrix aims for sparse coverage across those two dimensions. +# Use of BLAS/LAPACK and SIMD is disabled on purpose, because those things +# don't matter for static typing and this speeds up the builds. +# +# This is a separate job file so it's easy to trigger by hand. + +on: + pull_request: + branches: + - main + - maintenance/** + paths-ignore: + - 'benchmarks/' + - '.circlecl/' + - 'docs/' + - 'meson_cpu/' + - 'tools/' + workflow_dispatch: + +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: + mypy: + if: "github.repository == 'numpy/numpy'" + name: "MyPy" + runs-on: ${{ matrix.os_python[0] }} + strategy: + matrix: + os_python: + - [ubuntu-latest, '3.10'] # switch to 3.12-dev after mypy is upgraded (see gh-23764) + - [windows-2019, '3.11'] + - [macos-12, '3.9'] + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: recursive + fetch-depth: 0 + - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: ${{ matrix.os_python[1] }} + - name: Install dependencies + run: | + pip install -r build_requirements.txt + pip install -r test_requirements.txt + - name: Build + run: | + spin build -j2 -- -Dallow-noblas=true -Ddisable-optimization=true --vsenv + - name: Run Mypy + run: | + spin mypy diff --git a/numpy/typing/tests/data/reveal/warnings_and_errors.pyi b/numpy/typing/tests/data/reveal/warnings_and_errors.pyi index 16492c2fb41b..b026e4f6e3b0 100644 --- a/numpy/typing/tests/data/reveal/warnings_and_errors.pyi +++ b/numpy/typing/tests/data/reveal/warnings_and_errors.pyi @@ -5,7 +5,7 @@ import numpy as np if sys.version_info >= (3, 11): from typing import assert_type else: - from typing_nptensions import assert_type + from typing_extensions import assert_type assert_type(np.ModuleDeprecationWarning(), np.ModuleDeprecationWarning) assert_type(np.VisibleDeprecationWarning(), np.VisibleDeprecationWarning) diff --git a/numpy/typing/tests/test_typing.py b/numpy/typing/tests/test_typing.py index cd009bb6e7f2..68c6f5d03fab 100644 --- a/numpy/typing/tests/test_typing.py +++ b/numpy/typing/tests/test_typing.py @@ -26,6 +26,20 @@ ) +# Only trigger a full `mypy` run if this environment variable is set +# Note that these tests tend to take over a minute even on a macOS M1 CPU, +# and more than that in CI. +RUN_MYPY = "NPY_RUN_MYPY_IN_TESTSUITE" in os.environ +if RUN_MYPY and RUN_MYPY not in ('0', '', 'false'): + RUN_MYPY = True + +# Skips all functions in this file +pytestmark = pytest.mark.skipif( + not RUN_MYPY, + reason="`NPY_RUN_MYPY_IN_TESTSUITE` not set" +) + + try: from mypy import api except ImportError: diff --git a/vendored-meson/meson b/vendored-meson/meson index 66ba7dbbfe28..ea5809096404 160000 --- a/vendored-meson/meson +++ b/vendored-meson/meson @@ -1 +1 @@ -Subproject commit 66ba7dbbfe2838983f65ad8fe16da1535ebf5b9d +Subproject commit ea580909640457450e03d8b84d1fec9f035d7acb