1
+ :: Build script for scipy_openblas wheel on Windows on ARM64
2
+
3
+ :: Usage: build_steps_win_arm64.bat [build_bits]
4
+ :: e.g build_steps_win_arm64.bat 64
5
+
6
+ :: BUILD_BITS (default binary architecture, 32 or 64, unspec -> 64).
7
+ :: Expects these binaries on the PATH:
8
+ :: clang-cl, flang-new, cmake, perl
9
+
10
+ @ echo off
11
+ setlocal enabledelayedexpansion
12
+
13
+ if " %1 " == " " (
14
+ set BUILD_BIT = 64
15
+ ) else (
16
+ set BUILD_BIT = %1
17
+ )
18
+ echo Building for %BUILD_BIT% -bit configuration...
19
+
20
+ :: Define destination directory
21
+ move " ..\local\scipy_openblas64" " ..\local\scipy_openblas32"
22
+ set " DEST_DIR = %CD% \..\local\scipy_openblas32"
23
+ cd ..
24
+
25
+ :: Check if 'openblas' folder exists and is empty
26
+ if exist " openblas" (
27
+ dir /b " openblas" | findstr . > nul
28
+ if errorlevel 1 (
29
+ echo OpenBLAS folder exists but is empty. Deleting and recloning...
30
+ rmdir /s /q " openblas"
31
+ )
32
+ )
33
+
34
+ :: Clone OpenBLAS if not present
35
+ if not exist " openblas" (
36
+ echo Cloning OpenBLAS repository with submodules...
37
+ git clone --recursive https://github.com/OpenMathLib/OpenBLAS.git OpenBLAS
38
+ if errorlevel 1 exit /b 1
39
+ )
40
+
41
+ :: Enter OpenBLAS directory and checkout develop branch
42
+ cd openblas
43
+ git checkout develop
44
+
45
+ echo Checked out to the latest branch of OpenBLAS.
46
+
47
+ :: Create build directory and navigate to it
48
+ if not exist build mkdir build
49
+ cd build
50
+
51
+ echo Setting up ARM64 Developer Command Prompt and running CMake...
52
+
53
+ :: Initialize VS ARM64 environment
54
+ for /f " usebackq tokens=*" %%i in (`" C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do call " %%i \VC\Auxiliary\Build\vcvarsall.bat" arm64
55
+
56
+ :: Run CMake and Ninja build
57
+ cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DTARGET=ARMV8 -DBUILD_SHARED_LIBS=ON -DARCH=arm64 ^
58
+ -DBINARY=%BUILD_BIT% -DCMAKE_SYSTEM_PROCESSOR=ARM64 -DCMAKE_C_COMPILER=clang-cl ^
59
+ -DCMAKE_Fortran_COMPILER=flang-new -DSYMBOLPREFIX=" scipy_" -DLIBNAMEPREFIX=" scipy_"
60
+ if errorlevel 1 exit /b 1
61
+
62
+ ninja
63
+ if errorlevel 1 exit /b 1
64
+
65
+ echo Build complete. Returning to Batch.
66
+
67
+ :: Rewrite the name of the project to scipy-openblas32
68
+ echo Rewrite to scipy_openblas32
69
+ cd ../..
70
+ powershell -Command " (Get-Content 'pyproject.toml') -replace 'openblas64', 'openblas32' | Set-Content 'pyproject.toml'"
71
+ powershell -Command " (Get-Content 'local\scipy_openblas32\__main__.py') -replace 'openblas64', 'openblas32' | Out-File 'local\scipy_openblas32\__main__.py' -Encoding utf8"
72
+ powershell -Command " (Get-Content 'local\scipy_openblas32\__init__.py') -replace 'openblas64', 'openblas32' | Out-File 'local\scipy_openblas32\__init__.py' -Encoding utf8"
73
+ powershell -Command " (Get-Content 'local\scipy_openblas32\__init__.py') -replace 'openblas_get_config64_', 'openblas_get_config' | Out-File 'local\scipy_openblas32\__init__.py' -Encoding utf8"
74
+ powershell -Command " (Get-Content 'local\scipy_openblas32\__init__.py') -replace 'cflags =.*', 'cflags = \" -DBLAS_SYMBOL_PREFIX=scipy_\" ' | Out-File 'local\scipy_openblas32\__init__.py' -Encoding utf8"
75
+
76
+ :: Prepare destination directory
77
+ cd OpenBLAS/build
78
+ echo Preparing destination directory at %DEST_DIR% ...
79
+ if not exist " %DEST_DIR% \lib\cmake\openblas" mkdir " %DEST_DIR% \lib\cmake\openblas"
80
+ if not exist " %DEST_DIR% \include" mkdir " %DEST_DIR% \include"
81
+
82
+ :: Move library files
83
+ echo Moving library files...
84
+ if exist lib\release (
85
+ move /Y lib\release\*.dll " %DEST_DIR% \lib\"
86
+ if errorlevel 1 exit /b 1
87
+ move /Y lib\release\*.dll.a " %DEST_DIR% \lib\scipy_openblas.lib"
88
+ if errorlevel 1 exit /b 1
89
+ ) else (
90
+ echo Error: lib/release directory not found!
91
+ exit /b 1
92
+ )
93
+
94
+ :: Copy CMake configuration files
95
+ echo Copying CMake configuration files...
96
+ if exist openblasconfig.cmake copy /Y openblasconfig.cmake " %DEST_DIR% \lib\cmake\openblas\"
97
+ if exist openblasconfigversion.cmake copy /Y openblasconfigversion.cmake " %DEST_DIR% \lib\cmake\openblas\"
98
+
99
+ :: Copy header files
100
+ echo Copying generated header files...
101
+ if exist generated xcopy /E /Y generated " %DEST_DIR% \include\"
102
+ if exist lapacke_mangling copy /Y lapacke_mangling " %DEST_DIR% \include\"
103
+ if exist openblas_config.h copy /Y openblas_config.h " %DEST_DIR% \include\"
104
+
105
+
106
+ :: Copy LAPACKE header files
107
+ echo Copying LAPACKE header files...
108
+ xcopy /Y " ..\lapack-netlib\lapacke\include\*.h" " %DEST_DIR% \include\"
109
+ if errorlevel 1 exit /b 1
110
+
111
+ :: Move back to the root directory
112
+ cd ../..
113
+
114
+ :: Build the Wheel & Install It
115
+ echo Running 'python -m build' to build the wheel...
116
+ python -m build
117
+ if errorlevel 1 exit /b 1
118
+
119
+ :: Locate the built wheel
120
+ for /f %%f in ('dir /b dist\scipy_openblas*.whl 2^ > nul ') do set WHEEL_FILE = dist\%%f
121
+
122
+ if not defined WHEEL_FILE (
123
+ echo Error: No wheel file found in dist folder.
124
+ exit /b 1
125
+ )
126
+
127
+ echo Installing wheel: %WHEEL_FILE%
128
+ pip install " %WHEEL_FILE% "
129
+ if errorlevel 1 exit /b 1
130
+
131
+ echo Done.
132
+ exit /b 0
0 commit comments