1- :: Build script for scipy_openblas wheel on Windows on ARM64
2-
3- :: Usage: build_steps_win_arm64.bat [build_bits] [if_bits]
4- :: e.g build_steps_win_arm64.bat 64 64
5-
6- :: build_bits (default binary architecture, 32 or 64, unspec -> 64).
7- :: if_bits (default interface size, 32 or 64, unspec -> 32)
8- :: If INTERFACE64 environment variable is 1, then if_bits defaults to 64
9- :: Expects these binaries on the PATH:
10- :: clang-cl, flang-new, cmake, perl
11- :: First commit containing WoA build fixes.
12- :: Minimum OpenBLAS commit to build; we'll update to this if commit not
13- :: present.
1+ REM Build script for scipy_openblas wheel on Windows on ARM64
2+
3+ REM Usage: build_steps_win_arm64.bat [build_bits] [if_bits]
4+ REM e.g build_steps_win_arm64.bat 64 64
5+
6+ REM build_bits (default binary architecture, 32 or 64, unspec -> 64).
7+ REM if_bits (default interface size, 32 or 64, unspec -> 32)
8+ REM If INTERFACE64 environment variable is 1, then if_bits defaults to 64
9+ REM Expects these binaries on the PATH:
10+ REM clang-cl, flang-new, cmake, perl
11+ REM First commit containing WoA build fixes.
12+ REM Minimum OpenBLAS commit to build; we'll update to this if commit not
13+ REM present.
1414set first_woa_buildable_commit = " de2380e5a6149706a633322a16a0f66faa5591fc"
1515
1616@ echo off
@@ -33,7 +33,7 @@ if "%2"=="" (
3333)
3434echo Building for %build_bits% -bit binary, %if_bits% -bit interface...
3535
36- :: Define destination directory
36+ REM Define destination directory
3737pushd " %~dp0 \.."
3838set " ob_out_root = %CD% \local\scipy_openblas"
3939set " ob_64 = %ob_out_root% 64"
@@ -54,13 +54,13 @@ if "%if_bits%"=="64" (
5454 )
5555)
5656
57- :: Clone OpenBLAS
57+ REM Clone OpenBLAS
5858echo Cloning OpenBLAS repository with submodules...
5959git submodule update --init --recursive OpenBLAS
6060if errorlevel 1 exit /b 1
6161set /p OPENBLAS_COMMIT = < openblas_commit.txt
6262
63- :: Enter OpenBLAS directory and checkout buildable commit
63+ REM Enter OpenBLAS directory and checkout buildable commit
6464cd OpenBLAS
6565git checkout %OPENBLAS_COMMIT%
6666git merge-base --is-ancestor %first_woa_buildable_commit% HEAD 2 > NUL
@@ -70,30 +70,38 @@ if errorlevel 1 (
7070 exit /b 2
7171)
7272
73- :: Patch
73+ REM Patch
7474for /r %%f in (..\patches\*) do git apply %%f
7575if errorlevel 1 exit /b 1
7676
77- :: Set suffixed-ILP64 flags
77+ REM Patch VERSION
78+ REM version=$(grep "^version =" ../pyproject.toml | sed 's/version = "//;s/"//')
79+ REM sed -e "s/^VERSION = .*/VERSION = ${version}/" -i.bak Makefile.rule
80+
81+ for /f " tokens=3 delims= " %%v in ('findstr /b " version = " ..\pyproject.toml') do set version = %%v
82+ set version = %version:" =%
83+ powershell -Command " (Get-Content OpenBLAS/Makefile.rule) -replace '^VERSION = .*', 'VERSION = %version% ' | Set-Content Makefile.rule"
84+
85+ REM Set suffixed-ILP64 flags
7886if " %if_bits% " == " 64" (
7987 set " interface_flags = -DINTERFACE64=1 -DSYMBOLSUFFIX=64_"
8088) else (
8189 set " interface_flags = "
8290)
8391
84- :: Create build directory and navigate to it
92+ REM Create build directory and navigate to it
8593if exist build (rmdir /S /Q build || exit /b 1)
8694mkdir build || exit /b 1 & cd build || exit /b 1
8795
8896echo Setting up ARM64 Developer Command Prompt and running CMake...
8997
90- :: Initialize VS ARM64 environment
98+ REM Initialize VS ARM64 environment
9199CALL " C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsarm64.bat"
92100
93- :: Prefer LLVM flang
101+ REM Prefer LLVM flang
94102PATH=C:\Program Files\LLVM\bin;%PATH%
95103
96- :: Run CMake and Ninja build
104+ REM Run CMake and Ninja build
97105
98106set CFLAGS = -Wno-reserved-macro-identifier -Wno-unsafe-buffer-usage -Wno-unused-macros -Wno-sign-conversion -Wno-reserved-identifier
99107cmake .. -G Ninja ^
@@ -132,13 +140,13 @@ if "%if_bits%"=="32" (
132140 cd ..
133141)
134142
135- :: Prepare destination directory
143+ REM Prepare destination directory
136144cd OpenBLAS/build
137145echo Preparing destination directory at %DEST_DIR%
138146if not exist " %DEST_DIR% \lib\cmake\OpenBLAS" mkdir " %DEST_DIR% \lib\cmake\OpenBLAS"
139147if not exist " %DEST_DIR% \include" mkdir " %DEST_DIR% \include"
140148
141- :: Move library files
149+ REM Move library files
142150echo Moving library files...
143151if exist lib\release (
144152 move /Y lib\release\*.dll " %DEST_DIR% \lib\"
@@ -154,19 +162,19 @@ if exist lib\release (
154162 exit /b 1
155163)
156164
157- :: Copy CMake configuration files
165+ REM Copy CMake configuration files
158166echo Copying CMake configuration files...
159167if exist openblasconfig.cmake copy /Y openblasconfig.cmake " %DEST_DIR% \lib\cmake\openblas\"
160168if exist openblasconfigversion.cmake copy /Y openblasconfigversion.cmake " %DEST_DIR% \lib\cmake\openblas\"
161169
162- :: Copy header files
170+ REM Copy header files
163171echo Copying generated header files...
164172if exist generated xcopy /E /Y generated " %DEST_DIR% \include\"
165173if exist lapacke_mangling.h copy /Y lapacke_mangling.h " %DEST_DIR% \include\"
166174if exist openblas_config.h copy /Y openblas_config.h " %DEST_DIR% \include\"
167175
168176
169- :: Copy LAPACKE header files
177+ REM Copy LAPACKE header files
170178echo Copying LAPACKE header files...
171179xcopy /Y " ..\lapack-netlib\lapacke\include\*.h" " %DEST_DIR% \include\"
172180if errorlevel 1 exit /b 1
@@ -189,14 +197,14 @@ if errorlevel 1 (
189197 exit /b 1
190198)
191199
192- :: Move back to the root directory
200+ REM Move back to the root directory
193201cd ..
194202if errorlevel 1 (
195203 echo Current directory %CD% , cannot cd ..
196204 exit /b 1
197205)
198206
199- :: Build the Wheel & Install It
207+ REM Build the Wheel & Install It
200208echo Running 'python -m build' to build the wheel in %CD%
201209python -c " import build" 2 > NUL || pip install build
202210if " %if_bits% " == " 64" (
@@ -213,15 +221,15 @@ if "%if_bits%"=="32" (
213221 move /Y " %CD% \ob64_backup" " %ob_64% "
214222)
215223
216- :: Rename the wheel
224+ REM Rename the wheel
217225for %%f in (dist\*any.whl) do (
218226 set WHEEL_FILE = dist\%%f
219227 set " filename = %%~nxf "
220228 set " newname = !filename:any.whl =win_arm64.whl ! "
221229 ren " dist\!filename! " " !newname! "
222230)
223231
224- :: Locate the built wheel
232+ REM Locate the built wheel
225233for /f %%f in ('dir /b dist\scipy_openblas*.whl 2^ > nul ') do set WHEEL_FILE = dist\%%f
226234
227235if not defined WHEEL_FILE (
0 commit comments