Skip to content

Commit e4ed8ce

Browse files
committed
fix running python to get scipy-openblas.pc
1 parent beb25a6 commit e4ed8ce

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

local/scipy_openblas64/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ def get_pkg_config(use_preloading=False, use_prefix=False):
6767
If use_preloading is True then on posix the ``Libs:`` directive will not add
6868
``f"-L{get_library()}" so that at runtime this module must be imported before
6969
the target module
70+
71+
If use_prefix is True, then `pcfiledir` will be used and the file should be
72+
stored in `dirname(__file__)/lib/pkgconfig` for use with pkgconf-pypi
7073
"""
71-
machine = platform.machine().lower()
7274
extralib = ""
7375
if sys.platform == "win32":
76+
machine = platform.machine().lower()
7477
if machine != "arm64":
7578
extralib = "-defaultlib:advapi32 -lgfortran -lquadmath"
7679
libs_flags = f"-L${{libdir}} -l{get_library()}"

tools/build_prepare_wheel.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ else
4949
cat tools/LICENSE_linux.txt >> LICENSE.txt
5050
fi
5151

52+
if [ "$(uname)" == "Darwin" -a "${PLAT}" == "x86_64" ]; then
53+
local PYTHON="arch -x86_64 python3"
54+
else
55+
local PYTHON=python3
56+
fi
5257
if [ "${INTERFACE64}" != "1" ]; then
5358
# rewrite the name of the project to scipy-openblas32
5459
# this is a hack, but apparently there is no other way to change the name
@@ -63,9 +68,9 @@ if [ "${INTERFACE64}" != "1" ]; then
6368
sed -e "s/openblas64/openblas32/" -i.bak local/scipy_openblas32/__main__.py
6469
sed -e "s/openblas64/openblas32/" -i.bak local/scipy_openblas32/__init__.py
6570
rm local/scipy_openblas32/*.bak
66-
PYTHONPATH=$PWD/local python -c "import scipy_openblas32 as s; print(s.get_pkg_config(use_prefix=True))" > local/scipy_openblas32/lib/pkgconfig/scipy-openblas.pc
71+
PYTHONPATH=$PWD/local $PYTHON -c "import scipy_openblas32 as s; print(s.get_pkg_config(use_prefix=True))" > local/scipy_openblas32/lib/pkgconfig/scipy-openblas.pc
6772
else
68-
PYTHONPATH=$PWD/local python -c "import scipy_openblas64 as s; print(s.get_pkg_config(use_prefix=True))" > local/scipy_openblas64/lib/pkgconfig/scipy-openblas.pc
73+
PYTHONPATH=$PWD/local $PYTHON -c "import scipy_openblas64 as s; print(s.get_pkg_config(use_prefix=True))" > local/scipy_openblas64/lib/pkgconfig/scipy-openblas.pc
6974
fi
7075

7176
rm -rf dist/*

tools/build_steps_win_arm64.bat

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,28 +118,21 @@ if errorlevel 1 exit /b 1
118118

119119
echo Build complete. Returning to Batch.
120120

121+
cd ../../local
121122
if "%if_bits%"=="32" (
122123
echo Rewrite to scipy_openblas32
123-
cd ../..
124124
set out_pyproject=pyproject_64_32.toml
125125
powershell -Command "(Get-Content 'pyproject.toml') -replace 'openblas64', 'openblas32' | Set-Content !out_pyproject!"
126-
cd local
127126
move scipy_openblas64 scipy_openblas32
128127
powershell -Command "(Get-Content 'scipy_openblas32\__main__.py') -replace 'openblas64', 'openblas32' | Out-File 'scipy_openblas32\__main__.py' -Encoding utf8"
129128
powershell -Command "(Get-Content 'scipy_openblas32\__init__.py') -replace 'openblas64', 'openblas32' | Out-File 'scipy_openblas32\__init__.py' -Encoding utf8"
130129
powershell -Command "(Get-Content 'scipy_openblas32\__init__.py') -replace 'openblas_get_config64_', 'openblas_get_config' | Out-File 'scipy_openblas32\__init__.py' -Encoding utf8"
131130
powershell -Command "(Get-Content 'scipy_openblas32\__init__.py') -replace 'cflags =.*', 'cflags = \"-DBLAS_SYMBOL_PREFIX=scipy_\"' | Out-File 'local\scipy_openblas32\__init__.py' -Encoding utf8"
132-
mkdir scipy_openblas32\lib\pkgconfig
133-
python -c "import scipy_openblas32 as s; print(s.get_pkg_config(use_prefix=True))" > scipy_openblas32/lib/pkgconfig/scipy-openblas.pc
134-
) else (
135-
cd local
136-
mkdir scipy_openblas64\lib\pkgconfig
137-
python -c "import scipy_openblas64 as s; print(s.get_pkg_config(use_prefix=True))" > scipy_openblas64/lib/pkgconfig/scipy-openblas.pc
138131
)
139132

140133
:: Prepare destination directory
141-
cd OpenBLAS/build
142-
echo Preparing destination directory at %DEST_DIR%...
134+
cd ../OpenBLAS/build
135+
echo Preparing destination directory at %DEST_DIR%
143136
if not exist "%DEST_DIR%\lib\cmake\OpenBLAS" mkdir "%DEST_DIR%\lib\cmake\OpenBLAS"
144137
if not exist "%DEST_DIR%\include" mkdir "%DEST_DIR%\include"
145138

@@ -175,9 +168,19 @@ if exist openblas_config.h copy /Y openblas_config.h "%DEST_DIR%\include\"
175168
echo Copying LAPACKE header files...
176169
xcopy /Y "..\lapack-netlib\lapacke\include\*.h" "%DEST_DIR%\include\"
177170
if errorlevel 1 exit /b 1
178-
171+
172+
:: Create pkgconfig scipy-openblas.pc
173+
cd ../../local
174+
if "%if_bits%"=="32" (
175+
mkdir scipy_openblas32\lib\pkgconfig
176+
python -c "import scipy_openblas32 as s; print(s.get_pkg_config(use_prefix=True))" > scipy_openblas32/lib/pkgconfig/scipy-openblas.pc
177+
) else (
178+
mkdir scipy_openblas64\lib\pkgconfig
179+
python -c "import scipy_openblas64 as s; print(s.get_pkg_config(use_prefix=True))" > scipy_openblas64/lib/pkgconfig/scipy-openblas.pc
180+
)
181+
179182
:: Move back to the root directory
180-
cd ../..
183+
cd /..
181184

182185
:: Build the Wheel & Install It
183186
echo Running 'python -m build' to build the wheel...

0 commit comments

Comments
 (0)