Skip to content

Commit 7a663b3

Browse files
committed
add an use_preloading option to get_pkg_config
1 parent 11f535a commit 7a663b3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

local/scipy_openblas64/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,23 @@ def get_library():
5353
# remove the leading lib from libscipy_openblas*
5454
return os.path.splitext(libs[0])[0][3:]
5555

56-
def get_pkg_config():
56+
def get_pkg_config(use_preloading=False):
5757
"""Return a multi-line string that, when saved to a file, can be used with
5858
pkg-config for build systems like meson
59+
60+
If use_preloading is True then on posix the ``Libs:`` directive will not add
61+
``f"-L{get_library()}" so that at runtime this module must be imported before
62+
the target module
5963
"""
6064
if sys.platform == "win32":
6165
extralib = "-defaultlib:advapi32 -lgfortran -lquadmath"
66+
libs_flags = f"-L${{libdir}} -l{get_library()}"
6267
else:
6368
extralib = f"-lm -lpthread -lgfortran -lquadmath -L${{libdir}} -l{get_library()}"
64-
libs_flags = f"-L${{libdir}} -l{get_library()}"
69+
if use_preloading:
70+
libs_flags = ""
71+
else:
72+
libs_flags = f"-L${{libdir}} -l{get_library()}"
6573
cflags = "-DBLAS_SYMBOL_PREFIX=scipy_ -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64 -DOPENBLAS_ILP64_NAMING_SCHEME"
6674
return dedent(f"""\
6775
libdir={get_lib_dir()}
@@ -111,7 +119,7 @@ def get_openblas_config():
111119
else:
112120
# Get openblas*
113121
libnames = [x for x in os.listdir(lib_dir) if x.startswith("libscipy")]
114-
122+
115123
dll = ctypes.CDLL(os.path.join(lib_dir, libnames[0]), ctypes.RTLD_GLOBAL)
116124
openblas_config = dll.scipy_openblas_get_config64_
117125
openblas_config.restype = ctypes.c_char_p

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "scipy_openblas64"
11-
version = "0.3.26.0.1"
11+
version = "0.3.26.0.2"
1212
requires-python = ">=3.7"
1313
description = "Provides OpenBLAS for python packaging"
1414
readme = "README.md"

0 commit comments

Comments
 (0)