GeezerVison is showing github.com — BLD: use scipy-openblas wheel (#24839) · numpy/numpy@21d29c5
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/meson_actions/action.yml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' | 8 | 8 | env: | 9 | 9 | TERM: xterm-256color | | 10 | + PKG_CONFIG_PATH: ./.openblas | 10 | 11 | run: | | 11 | 12 | echo "::group::Installing Build Dependencies" | 12 | 13 | pip install -r build_requirements.txt | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/linux.yml +9-8Lines changed: 9 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -73,10 +73,10 @@ jobs: | 73 | 73 | - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 | 74 | 74 | with: | 75 | 75 | python-version: 'pypy3.9-v7.3.12' | 76 | | - - name: Install system dependencies | | 76 | + - name: Setup using scipy-openblas | 77 | 77 | run: | | 78 | | - sudo apt-get update | 79 | | - sudo apt-get install libopenblas-dev ninja-build | | 78 | + python -m pip install scipy-openblas32 spin | | 79 | + spin config-openblas --with-scipy-openblas=32 | 80 | 80 | - uses: ./.github/meson_actions | 81 | 81 |
| 82 | 82 | debug: | @@ -124,15 +124,16 @@ jobs: | 124 | 124 | run: | | 125 | 125 | pip install -r build_requirements.txt | 126 | 126 | pip install -r test_requirements.txt | 127 | | - - name: Install gfortran and OpenBLAS (MacPython build) | | 127 | + - name: Install gfortran and setup OpenBLAS (MacPython build) | 128 | 128 | run: | | 129 | 129 | set -xe | 130 | 130 | sudo apt update | 131 | 131 | sudo apt install gfortran libgfortran5 | 132 | | - target=$(python tools/openblas_support.py) | 133 | | - sudo cp -r $target/lib/* /usr/lib | 134 | | - sudo cp $target/include/* /usr/include | | 132 | + pip install scipy-openblas32 | | 133 | + spin config-openblas --with-scipy-openblas=32 | 135 | 134 | - name: Build a wheel | | 135 | + env: | | 136 | + PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas | 136 | 137 | run: | | 137 | 138 | python -m build --wheel --no-isolation --skip-dependency-check | 138 | 139 | pip install dist/numpy*.whl | @@ -185,7 +186,7 @@ jobs: | 185 | 186 | - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 | 186 | 187 | with: | 187 | 188 | python-version: '3.11' | 188 | | - - name: Install gfortran and OpenBLAS (MacPython build) | | 189 | + - name: Install gfortran and setup OpenBLAS (MacPython build) | 189 | 190 | run: | | 190 | 191 | set -xe | 191 | 192 | sudo apt update | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/linux_blas.yml +2-6Lines changed: 2 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,13 +7,9 @@ name: BLAS tests (Linux) | 7 | 7 | # | 8 | 8 | # Jobs and their purpose: | 9 | 9 | # | 10 | | -# - openblas64_setuppy: | 11 | | -# This job uses the default 64-bit build of OpenBLAS with the | 12 | | -# `numpy.distutils`-based build. It can be removed once we remove | 13 | | -# support for those builds. | 14 | 10 | # - openblas32_stable_nightly: | 15 | | -# Uses the 32-bit OpenBLAS builds, both the latest stable release and a | 16 | | -# nightly build. | | 11 | +# Uses the 32-bit OpenBLAS builds, both the latest stable release | | 12 | +# and a nightly build. | 17 | 13 | # | 18 | 14 | # TODO: coverage here is limited, we should add non-OpenBLAS libraries and | 19 | 15 | # exercise the BLAS-related build options (see `meson_options.txt`). | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/linux_compiler_sanitizers.yml +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,14 +35,14 @@ jobs: | 35 | 35 | - name: Install dependencies | 36 | 36 | run: | | 37 | 37 | pip install -r build_requirements.txt | 38 | | - sudo apt-get update | 39 | | - sudo apt-get install -y libopenblas-serial-dev | | 38 | + pip install scipy-openblas32 spin | 40 | 39 | - name: Build | 41 | 40 | shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' | 42 | 41 | env: | 43 | 42 | TERM: xterm-256color | | 43 | + PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas | 44 | 44 | run: | 45 | | - spin build -- --werror -Db_sanitize=address,undefined | | 45 | + spin build --with-scipy-openblas=32 -- --werror -Db_sanitize=address,undefined | 46 | 46 | - name: Test | 47 | 47 | shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' | 48 | 48 | env: | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/linux_musl.yml +11-9Lines changed: 11 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,20 +48,22 @@ jobs: | 48 | 48 |
| 49 | 49 | ln -s /usr/local/bin/python3.10 /usr/local/bin/python | 50 | 50 |
| 51 | | - - name: test musllinux_x86_64 | | 51 | + - name: test-musllinux_x86_64 | | 52 | + env: | | 53 | + PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas | 52 | 54 | run: | | 53 | 55 | python -m venv test_env | 54 | 56 | source test_env/bin/activate | 55 | 57 |
| 56 | | - # required for figuring out the system tags in openblas_support | 57 | | - pip install packaging | 58 | | - | 59 | | - # install openblas by co-opting the CIBW setup script | 60 | | - RUNNER_OS=Linux sh tools/wheels/cibw_before_build.sh . | | 58 | + pip install scipy-openblas64 | 61 | 59 |
| 62 | | - pip install -r build_requirements.txt | 63 | | - pip install pytest pytest-xdist hypothesis typing_extensions | | 60 | + pip install -r build_requirements.txt -r test_requirements.txt | 64 | 61 |
| 65 | 62 | # use meson to build and test | 66 | | - spin build | | 63 | + spin build --with-scipy-openblas=64 | 67 | 64 | spin test -j auto | | 65 | +
| | 66 | + - name: Meson Log | | 67 | + shell: bash | | 68 | + run: | | | 69 | + cat build/meson-logs/meson-log.txt |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/windows.yml +14-21Lines changed: 14 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 37 | 37 | run: | | 38 | 38 | python -m pip install spin Cython | 39 | 39 |
| 40 | | - - name: Install OpenBLAS (MacPython build) | | 40 | + - name: Install pkg-config | 41 | 41 | run: | | 42 | | - # Download and install pre-built OpenBLAS library with 32-bit | 43 | | - # interfaces. Unpack it in the pkg-config hardcoded path | 44 | | - choco install unzip -y | 45 | | - choco install wget -y | 46 | 42 | choco install -y --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite | 47 | | - wget https://anaconda.org/multibuild-wheels-staging/openblas-libs/v0.3.21/download/openblas-v0.3.21-win_amd64-gcc_10_3_0.zip | 48 | | - unzip -d c:\opt openblas-v0.3.21-win_amd64-gcc_10_3_0.zip | 49 | | - echo "PKG_CONFIG_PATH=c:\opt\64\lib\pkgconfig;" >> $env:GITHUB_ENV | 50 | 43 |
| 51 | 44 | - name: Install Clang-cl | 52 | 45 | if: matrix.compiler == 'Clang-cl' | @@ -55,26 +48,26 @@ jobs: | 55 | 48 |
| 56 | 49 | - name: Install NumPy (MSVC) | 57 | 50 | if: matrix.compiler == 'MSVC' | | 51 | + env: | | 52 | + PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas | 58 | 53 | run: | | 59 | | - spin build -j2 -- --vsenv | | 54 | + python -m pip install scipy-openblas32 | | 55 | + spin build --with-scipy-openblas=32 -j2 -- --vsenv | 60 | 56 |
| 61 | 57 | - name: Install NumPy (Clang-cl) | 62 | 58 | if: matrix.compiler == 'Clang-cl' | | 59 | + env: | | 60 | + PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas | 63 | 61 | run: | | 64 | 62 | "[binaries]","c = 'clang-cl'","cpp = 'clang-cl'","ar = 'llvm-lib'","c_ld = 'lld-link'","cpp_ld = 'lld-link'" | Out-File $PWD/clang-cl-build.ini -Encoding ascii | 65 | | - spin build -j2 -- --vsenv --native-file=$PWD/clang-cl-build.ini | | 63 | + python -m pip install scipy-openblas32 | | 64 | + spin build --with-scipy-openblas=32 -j2 -- --vsenv --native-file=$PWD/clang-cl-build.ini | 66 | 65 |
| 67 | | - - name: Copy OpenBLAS DLL, write _distributor_init.py | | 66 | + - name: Meson Log | | 67 | + shell: bash | | 68 | + if: ${{ failure() }} | 68 | 69 | run: | | 69 | | - # Getting the OpenBLAS DLL to the right place so it loads | 70 | | - $installed_path = "$PWD\build-install\usr\Lib\site-packages" | 71 | | - $numpy_path = "${installed_path}\numpy" | 72 | | - $libs_path = "${installed_path}\numpy.libs" | 73 | | - mkdir ${libs_path} | 74 | | - $ob_path = "C:/opt/64/bin/" | 75 | | - cp $ob_path/*.dll $libs_path | 76 | | - # Write _distributor_init.py to load .libs DLLs. | 77 | | - python -c "from tools import openblas_support; openblas_support.make_init(r'${numpy_path}')" | | 70 | + cat build/meson-logs/meson-log.txt | 78 | 71 |
| 79 | 72 | - name: Install test dependencies | 80 | 73 | run: | | | 85 | 78 | run: | | 86 | 79 | spin test | 87 | 80 |
| 88 | | - msvc_32bit_python_openblas: | | 81 | + msvc_32bit_python_no_openblas: | 89 | 82 | name: MSVC, 32-bit Python, no BLAS | 90 | 83 | runs-on: windows-2019 | 91 | 84 | if: "github.repository == 'numpy/numpy'" | |
Collapse file Copy file name to clipboardExpand all lines: .gitignore +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -118,7 +118,6 @@ doc/source/**/generated/ | 118 | 118 |
| 119 | 119 | # Things specific to this project # | 120 | 120 | ################################### | 121 | | -# The line below should change to numpy/_version.py for NumPy 2.0 | 122 | 121 | benchmarks/results | 123 | 122 | benchmarks/html | 124 | 123 | benchmarks/env | @@ -139,3 +138,5 @@ tools/swig/test/Tensor.py | 139 | 138 | tools/swig/test/Vector.py | 140 | 139 | tools/swig/test/Vector_wrap.cxx | 141 | 140 | tools/swig/test/Array.py | | 141 | +.openblas | | 142 | +numpy/_distributor_init_local.py |
Collapse file Copy file name to clipboardExpand all lines: .spin/cmds.py +47-2Lines changed: 47 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 37 | 37 | "-v", "--verbose", is_flag=True, | 38 | 38 | help="Print all build output, even installation" | 39 | 39 | ) | | 40 | +@click.option( | | 41 | + "--with-scipy-openblas", type=click.Choice(["32", "64"]), | | 42 | + default=None, | | 43 | + help="Build with pre-installed scipy-openblas32 or scipy-openblas64 wheel" | | 44 | +) | 40 | 45 | @click.argument("meson_args", nargs=-1) | 41 | 46 | @click.pass_context | 42 | | -def build(ctx, meson_args, jobs=None, clean=False, verbose=False, quiet=False): | | 47 | +def build(ctx, meson_args, with_scipy_openblas, jobs=None, clean=False, verbose=False, quiet=False): | 43 | 48 | """🔧 Build package with Meson/ninja and install | 44 | 49 |
| 45 | 50 | MESON_ARGS are passed through e.g.: | @@ -53,6 +58,10 @@ def build(ctx, meson_args, jobs=None, clean=False, verbose=False, quiet=False): | 53 | 58 |
| 54 | 59 | CFLAGS="-O0 -g" spin build | 55 | 60 | """ | | 61 | + # XXX keep in sync with upstream build | | 62 | + if with_scipy_openblas: | | 63 | + _config_openblas(with_scipy_openblas) | | 64 | + ctx.params.pop("with_scipy_openblas", None) | 56 | 65 | ctx.forward(meson.build) | 57 | 66 |
| 58 | 67 |
| @@ -413,7 +422,7 @@ def ipython(ctx, ipython_args): | 413 | 422 | util.run(["ipython", "--ignore-cwd", | 414 | 423 | f"--TerminalIPythonApp.exec_lines={preimport}"] + | 415 | 424 | list(ipython_args)) | 416 | | - | | 425 | + | 417 | 426 |
| 418 | 427 | @click.command(context_settings={"ignore_unknown_options": True}) | 419 | 428 | @click.pass_context | @@ -425,3 +434,39 @@ def mypy(ctx): | 425 | 434 | ctx.params['pytest_args'] = [os.path.join('numpy', 'typing')] | 426 | 435 | ctx.params['markexpr'] = 'full' | 427 | 436 | ctx.forward(test) | | 437 | + | | 438 | +@click.command(context_settings={ | | 439 | + 'ignore_unknown_options': True | | 440 | +}) | | 441 | +@click.option( | | 442 | + "--with-scipy-openblas", type=click.Choice(["32", "64"]), | | 443 | + default=None, required=True, | | 444 | + help="Build with pre-installed scipy-openblas32 or scipy-openblas64 wheel" | | 445 | +) | | 446 | +def config_openblas(with_scipy_openblas): | | 447 | + """🔧 Create .openblas/scipy-openblas.pc file | | 448 | +
| | 449 | + Also create _distributor_init_local.py | | 450 | +
| | 451 | + Requires a pre-installed scipy-openblas64 or scipy-openblas32 | | 452 | + """ | | 453 | + _config_openblas(with_scipy_openblas) | | 454 | + | | 455 | + | | 456 | +def _config_openblas(blas_variant): | | 457 | + import importlib | | 458 | + basedir = os.getcwd() | | 459 | + openblas_dir = os.path.join(basedir, ".openblas") | | 460 | + pkg_config_fname = os.path.join(openblas_dir, "scipy-openblas.pc") | | 461 | + if blas_variant: | | 462 | + module_name = f"scipy_openblas{blas_variant}" | | 463 | + try: | | 464 | + openblas = importlib.import_module(module_name) | | 465 | + except ModuleNotFoundError: | | 466 | + raise RuntimeError(f"'pip install {module_name} first") | | 467 | + local = os.path.join(basedir, "numpy", "_distributor_init_local.py") | | 468 | + with open(local, "wt", encoding="utf8") as fid: | | 469 | + fid.write(f"import {module_name}\n") | | 470 | + os.makedirs(openblas_dir, exist_ok=True) | | 471 | + with open(pkg_config_fname, "wt", encoding="utf8") as fid: | | 472 | + fid.write(openblas.get_pkg_config().replace("\\", "/")) |
Collapse file Copy file name to clipboardExpand all lines: azure-pipelines.yml +4-7Lines changed: 4 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -73,13 +73,12 @@ stages: | 73 | 73 | cd /numpy && \ | 74 | 74 | /opt/python/cp39-cp39/bin/python -mvenv venv && \ | 75 | 75 | source venv/bin/activate && \ | 76 | | - target=\$(python3 tools/openblas_support.py) && \ | 77 | | - cp -r \$target/lib/* /usr/lib && \ | 78 | | - cp \$target/include/* /usr/include && \ | 79 | | - python3 -m pip install ninja && \ | | 76 | + python3 -m pip install ninja scipy-openblas32 spin && \ | 80 | 77 | python3 -m pip install -r test_requirements.txt && \ | 81 | 78 | echo CFLAGS \$CFLAGS && \ | 82 | | - python3 -m pip install -v . && \ | | 79 | + spin config-openblas --with-scipy-openblas=32 && \ | | 80 | + export PKG_CONFIG_PATH=/numpy/.openblas && \ | | 81 | + python3 -m pip install . && \ | 83 | 82 | cd tools && \ | 84 | 83 | python3 -m pytest --pyargs numpy" | 85 | 84 | displayName: 'Run 32-bit manylinux2014 Docker Build / Tests' | @@ -107,8 +106,6 @@ stages: | 107 | 106 | TEST_MODE: fast | 108 | 107 | BITS: 64 | 109 | 108 | NPY_USE_BLAS_ILP64: '1' | 110 | | - # Broken - it builds but _multiarray_umath doesn't import - needs investigating | 111 | | - DISABLE_BLAS: '1' | 112 | 109 |
| 113 | 110 | steps: | 114 | 111 | - template: azure-steps-windows.yml |
Collapse file Copy file name to clipboardExpand all lines: azure-steps-windows.yml +10-29Lines changed: 10 additions & 29 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,43 +24,24 @@ steps: | 24 | 24 | displayName: 'Install utilities' | 25 | 25 |
| 26 | 26 | - powershell: | | 27 | | - $ErrorActionPreference = "Stop" | 28 | | - mkdir C:/opt/openblas/openblas_dll | 29 | | - mkdir C:/opt/32/lib/pkgconfig | 30 | | - mkdir C:/opt/64/lib/pkgconfig | 31 | | - $target=$(python -c "import tools.openblas_support as obs; plat=obs.get_plat(); ilp64=obs.get_ilp64(); target=f'openblas_{plat}.zip'; obs.download_openblas(target, plat, ilp64);print(target)") | 32 | | - unzip -o -d c:/opt/ $target | 33 | | - echo "##vso[task.setvariable variable=PKG_CONFIG_PATH]c:/opt/64/lib/pkgconfig" | 34 | | - copy C:/opt/64/bin/*.dll C:/opt/openblas/openblas_dll | 35 | | - displayName: 'Download / Install OpenBLAS' | 36 | | - | 37 | | -- powershell: | | 38 | | - # Note: ensure the `pip install .` command remains the last one here, to | 39 | | - # avoid "green on failure" issues | 40 | | - python -c "from tools import openblas_support; openblas_support.make_init('numpy')" | | 27 | + # Note: ensure the `pip install .` command remains the last one here, | | 28 | + # to avoid "green on failure" issues | 41 | 29 | If ( Test-Path env:DISABLE_BLAS ) { | 42 | 30 | python -m pip install . -v -Csetup-args="--vsenv" -Csetup-args="-Dblas=none" -Csetup-args="-Dlapack=none" -Csetup-args="-Dallow-noblas=true" | 43 | 31 | } | 44 | 32 | elseif ( Test-Path env:NPY_USE_BLAS_ILP64 ) { | 45 | | - python -m pip install . -v -Csetup-args="--vsenv" -Csetup-args="-Duse-ilp64=true" -Csetup-args="-Dblas-symbol-suffix=64_" | 46 | | - } else { | | 33 | + python -m pip install scipy-openblas64 spin | | 34 | + spin config-openblas --with-scipy-openblas=64 | | 35 | + $env:PKG_CONFIG_PATH="$pwd/.openblas" | 47 | 36 | python -m pip install . -v -Csetup-args="--vsenv" | | 37 | + } else { | | 38 | + python -m pip install scipy-openblas32 spin | | 39 | + spin config-openblas --with-scipy-openblas=32 | | 40 | + $env:PKG_CONFIG_PATH="$pwd/.openblas" | | 41 | + python -m pip install . -v -Csetup-args="--vsenv" | 48 | 42 | } | 49 | 43 | displayName: 'Build NumPy' | 50 | 44 |
| 51 | | -- powershell: | | 52 | | - # copy from c:/opt/openblas/openblas_dll to numpy/../numpy.libs to ensure it can | 53 | | - # get loaded when numpy is imported (no RPATH on Windows) | 54 | | - $target = $(python -c "import sysconfig; print(sysconfig.get_path('platlib'))") | 55 | | - mkdir $target/numpy.libs | 56 | | - copy C:/opt/openblas/openblas_dll/*.dll $target/numpy.libs | 57 | | - displayName: 'Copy OpenBLAS DLL to site-packages' | 58 | | - | 59 | | -- script: | | 60 | | - python -m pip install threadpoolctl | 61 | | - python tools/openblas_support.py --check_version | 62 | | - displayName: 'Check OpenBLAS version' | 63 | | - | 64 | 45 | - powershell: | | 65 | 46 | cd tools # avoid root dir to not pick up source tree | 66 | 47 | # Get a gfortran onto the path for f2py tests | |
|