Skip to content

Commit d3627f0

Browse files
committed
DEV:Streamline OpenBLAS handling on Win machine
[skip ci]
1 parent c137672 commit d3627f0

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

dev.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,19 +558,39 @@ def copy_openblas(cls, dirs):
558558
default `_distributor_init.py` file with the one
559559
we use for wheels uploaded to PyPI so that DLL gets loaded.
560560
561-
Assumes pkg-config is installed and aware of OpenBLAS.
561+
Assumes pkg-config is installed and aware of OpenBLAS.
562+
563+
The "dirs" parameter is typically a "Dirs" object with the
564+
structure as the following, say, if dev.py is run from the
565+
folder "repo":
566+
567+
dirs = Dirs(
568+
root=WindowsPath('C:/.../repo'),
569+
build=WindowsPath('C:/.../repo/build'),
570+
installed=WindowsPath('C:/.../repo/build-install'),
571+
site=WindowsPath('C:/.../repo/build-install/Lib/site-packages'
572+
)
573+
562574
"""
563575
# Get OpenBLAS lib path from pkg-config
564576
cmd = ['pkg-config', '--variable', 'libdir', 'openblas']
565577
result = subprocess.run(cmd, capture_output=True, text=True)
578+
# pkg-config does not return any meaningful error message if fails
566579
if result.returncode != 0:
567-
print(result.stderrr)
580+
print('"pkg-config --variable libdir openblas" '
581+
'command did not manage to find OpenBLAS '
582+
'succesfully. Try running manually on the '
583+
'command prompt for more information.')
568584
return result.returncode
569585

570-
openblas_lib_path = Path(result.stdout.strip())
586+
# Skip the drive letter of the path -> /c to get Windows drive
587+
# to be appended correctly to avoid "C:\c\..." from stdout.
588+
openblas_lib_path = Path(result.stdout.strip()[2:]).resolve()
571589
if not openblas_lib_path.stem == 'lib':
572-
raise RuntimeError(
573-
f'Expecting "lib" at end of "{openblas_lib_path}"')
590+
raise RuntimeError('"pkg-config --variable libdir openblas" '
591+
'command did not return a path ending with'
592+
' "lib" folder. Instead it returned '
593+
f'"{openblas_lib_path}"')
574594

575595
# Look in bin subdirectory for OpenBLAS binaries.
576596
bin_path = openblas_lib_path.parent / 'bin'
@@ -580,8 +600,8 @@ def copy_openblas(cls, dirs):
580600
libs_path.mkdir(exist_ok=True)
581601
# Copy DLL files from OpenBLAS install to scipy install .libs subdir.
582602
for dll_fn in bin_path.glob('*.dll'):
583-
out_fname = libs_path / dll_fn.parts[-1]
584-
print(f'Copying {dll_fn} to {out_fname}')
603+
out_fname = libs_path / dll_fn.name
604+
print(f'Copying {dll_fn} ----> {out_fname}')
585605
out_fname.write_bytes(dll_fn.read_bytes())
586606

587607
# Write _distributor_init.py to scipy install dir;

0 commit comments

Comments
 (0)