8000 Merge pull request #29082 from charris/backport-29039 · numpy/numpy@426f3e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 426f3e3

Browse files
authored
Merge pull request #29082 from charris/backport-29039
BLD: bump OpenBLAS version, use OpenBLAS for win-arm64 [wheel build]
2 parents b6a7581 + caf40e7 commit 426f3e3

File tree

6 files changed

+38
-42
lines changed

6 files changed

+38
-42
lines changed

.github/workflows/wheels.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ jobs:
184184
name: ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
185185
path: ./wheelhouse/*.whl
186186

187-
- uses: mamba-org/setup-micromamba@0dea6379afdaffa5d528b3d1dabc45da37f443fc
187+
- name: install micromamba
188+
uses: mamba-org/setup-micromamba@0dea6379afdaffa5d528b3d1dabc45da37f443fc
188189
if: ${{ matrix.buildplat[1] != 'win_arm64' }} # unsupported platform at the moment
189190
with:
190191
# for installation of anaconda-client, required for upload to
@@ -198,6 +199,16 @@ jobs:
198199
create-args: >-
199200
anaconda-client
200201
202+
- name: win-arm64 install anaconda client
203+
if: ${{ matrix.buildplat[1] == 'win_arm64' }}
204+
run: |
205+
# Rust installation needed for rpds-py.
206+
Invoke-WebRequest https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe -UseBasicParsing -Outfile rustup-init.exe
207+
.\rustup-init.exe -y
208+
$env:PATH="$env:PATH;$env:USERPROFILE\.cargo\bin"
209+
pip install anaconda-client
210+
211+
201212
- name: Upload wheels
202213
if: success() && github.repository == 'numpy/numpy'
203214
shell: bash -el {0}

pyproject.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,16 @@ repair-wheel-command = [
178178
]
179179

180180
[tool.cibuildwheel.windows]
181-
# This does not work, use CIBW_ENVIRONMENT_WINDOWS
182-
environment = {PKG_CONFIG_PATH="./.openblas"}
183181
config-settings = "setup-args=--vsenv setup-args=-Dallow-noblas=false build-dir=build"
184182
repair-wheel-command = "bash -el ./tools/wheels/repair_windows.sh {wheel} {dest_dir}"
183+
# This does not work, use CIBW_ENVIRONMENT_WINDOWS
184+
environment = {PKG_CONFIG_PATH="./.openblas"}
185185

186186
[[tool.cibuildwheel.overrides]]
187187
select = "*-win32"
188188
config-settings = "setup-args=--vsenv setup-args=-Dallow-noblas=true build-dir=build"
189189
repair-wheel-command = ""
190190

191-
[[tool.cibuildwheel.overrides]]
192-
select = "*-win_arm64"
193-
config-settings = "setup-args=--vsenv setup-args=-Dallow-noblas=true build-dir=build"
194-
repair-wheel-command = ""
195-
196191
[[tool.cibuildwheel.overrides]]
197192
select = "*pyodide*"
198193
before-test = "pip install -r {project}/requirements/emscripten_test_requirements.txt"

requirements/ci32_requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
spin==0.13
22
# Keep this in sync with ci_requirements.txt
3-
scipy-openblas32==0.3.29.0.0
3+
scipy-openblas32==0.3.29.0.0 ; sys_platform != 'win32' or platform_machine != 'ARM64'
4+
scipy-openblas32==0.3.29.265.0 ; sys_platform == 'win32' and platform_machine == 'ARM64'

requirements/ci_requirements.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
spin==0.13
22
# Keep this in sync with ci32_requirements.txt
3-
scipy-openblas32==0.3.29.0.0
4-
scipy-openblas64==0.3.29.0.0
3+
scipy-openblas32==0.3.29.0.0 ; sys_platform != 'win32' or platform_machine != 'ARM64'
4+
scipy-openblas32==0.3.29.265.0 ; sys_platform == 'win32' and platform_machine == 'ARM64'
5+
# Note there is not yet a win-arm64 wheel, so we currently only exclude win-arm64
6+
scipy-openblas64==0.3.29.0.0 ; sys_platform != 'win32' or platform_machine != 'ARM64'

tools/wheels/cibw_before_build.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,40 @@ fi
2222
if [[ $(python -c"import sys; print(sys.maxsize)") < $(python -c"import sys; print(2**33)") ]]; then
2323
echo "No BLAS used for 32-bit wheels"
2424
export INSTALL_OPENBLAS=false
25-
elif [[ $(python -c"import sysconfig; print(sysconfig.get_platform())") == "win-arm64" ]]; then
26-
echo "No BLAS used for ARM64 wheels"
27-
export INSTALL_OPENBLAS=false
2825
elif [ -z $INSTALL_OPENBLAS ]; then
2926
# the macos_arm64 build might not set this variable
3027
export INSTALL_OPENBLAS=true
3128
fi
3229

3330
# Install Openblas from scipy-openblas64
3431
if [[ "$INSTALL_OPENBLAS" = "true" ]] ; then
35-
echo PKG_CONFIG_PATH $PKG_CONFIG_PATH
32+
# by default, use scipy-openblas64
33+
OPENBLAS=openblas64
34+
# Possible values for RUNNER_ARCH in github are
35+
# X86, X64, ARM, or ARM64
36+
# TODO: should we detect a missing RUNNER_ARCH and use platform.machine()
37+
# when wheel build is run outside github?
38+
# On 32-bit platforms, use scipy_openblas32
39+
# On win-arm64 use scipy_openblas32
40+
if [[ $RUNNER_ARCH == "X86" || $RUNNER_ARCH == "ARM" ]] ; then
41+
OPENBLAS=openblas32
42+
elif [[ $RUNNER_ARCH == "ARM64" && $RUNNER_OS == "Windows" ]] ; then
43+
OPENBLAS=openblas32
44+
fi
45+
echo PKG_CONFIG_PATH is $PKG_CONFIG_PATH, OPENBLAS is ${OPENBLAS}
3646
PKG_CONFIG_PATH=$PROJECT_DIR/.openblas
3747
rm -rf $PKG_CONFIG_PATH
3848
mkdir -p $PKG_CONFIG_PATH
3949
python -m pip install -r requirements/ci_requirements.txt
40-
python -c "import scipy_openblas64; print(scipy_openblas64.get_pkg_config())" > $PKG_CONFIG_PATH/scipy-openblas.pc
50+
python -c "import scipy_${OPENBLAS}; print(scipy_${OPENBLAS}.get_pkg_config())" > $PKG_CONFIG_PATH/scipy-openblas.pc
4151
# Copy the shared objects to a path under $PKG_CONFIG_PATH, the build
4252
# will point $LD_LIBRARY_PATH there and then auditwheel/delocate-wheel will
4353
# pull these into the wheel. Use python to avoid windows/posix problems
4454
python <<EOF
45-
import os, scipy_openblas64, shutil
46-
srcdir = os.path.join(os.path.dirname(scipy_openblas64.__file__), "lib")
55+
import os, scipy_${OPENBLAS}, shutil
56+
srcdir = os.path.join(os.path.dirname(scipy_${OPENBLAS}.__file__), "lib")
4757
shutil.copytree(srcdir, os.path.join("$PKG_CONFIG_PATH", "lib"))
48-
srcdir = os.path.join(os.path.dirname(scipy_openblas64.__file__), ".dylibs")
58+
srcdir = os.path.join(os.path.dirname(scipy_${OPENBLAS}.__file__), ".dylibs")
4959
if os.path.exists(srcdir): # macosx delocate
5060
shutil.copytree(srcdir, os.path.join("$PKG_CONFIG_PATH", ".dylibs"))
5161
EOF

tools/wheels/repair_windows.sh

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,8 @@ set -xe
33
WHEEL="$1"
44
DEST_DIR="$2"
55

6-
# create a temporary directory in the destination folder and unpack the wheel
7-
# into there
86
cwd=$PWD
9-
10-
pushd $DEST_DIR
11-
mkdir -p tmp
12-
pushd tmp
13-
wheel unpack $WHEEL
14-
pushd numpy*
15-
16-
# To avoid DLL hell, the file name of libopenblas that's being vendored with
17-
# the wheel has to be name-mangled. delvewheel is unable to name-mangle PYD
18-
# containing extra data at the end of the binary, which frequently occurs when
19-
# building with mingw.
20-
# We therefore find each PYD in the directory structure and strip them.
21-
22-
for f in $(find ./numpy* -name '*.pyd'); do strip $f; done
23-
24-
25-
# now repack the wheel and overwrite the original
26-
wheel pack .
27-
mv -fv *.whl $WHEEL
28-
297
cd $DEST_DIR
30-
rm -rf tmp
318

329
# the libopenblas.dll is placed into this directory in the cibw_before_build
3310
# script.

0 commit comments

Comments
 (0)
0