Skip to content

Commit 020da30

Browse files
authored
Merge pull request #128 from mattip/patch-external
create a single shared object libscipy_openblas64_.so or libscipy_openblas.so
2 parents f544ee0 + a141cd3 commit 020da30

File tree

10 files changed

+210
-14
lines changed

10 files changed

+210
-14
lines changed

.github/workflows/posix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
INTERFACE64: '1'
4747
env:
4848
REPO_DIR: OpenBLAS
49-
OPENBLAS_COMMIT: "9d425a5f"
49+
OPENBLAS_COMMIT: "v0.3.26"
5050
NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
5151
MACOSX_DEPLOYMENT_TARGET: 10.9
5252
MB_PYTHON_VERSION: ${{ matrix.python-version }}

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ main ]
88

99
env:
10-
OPENBLAS_COMMIT: "9d425a5f"
10+
OPENBLAS_COMMIT: "v0.3.26"
1111
OPENBLAS_ROOT: "c:\\opt"
1212
# Preserve working directory for calls into bash
1313
# Without this, invoking bash will cd to the home directory

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ env:
22
global:
33
# The archive that gets built has name from ``git describe`` on this
44
# commit.
5-
- OPENBLAS_COMMIT="9d425a5f"
5+
- OPENBLAS_COMMIT="v0.3.26"
66
- REPO_DIR=OpenBLAS
77
# Following generated with:
88
# travis encrypt -r MacPython/openblas-libs OPENBLAS_LIBS_STAGING_UPLOAD_TOKEN=<secret token value>

OpenBLAS

local/scipy_openblas64/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_pkg_config():
6262
libs_flags = f"-L${{libdir}} -l{get_library()}"
6363
else:
6464
extralib = f"-lm -lpthread -lgfortran -lquadmath -L${{libdir}} -l{get_library()}"
65-
libs_flags = ""
65+
libs_flags = "-L${{libdir}} -l{get_library()}"
6666
cflags = "-DBLAS_SYMBOL_PREFIX=scipy_ -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64 -DOPENBLAS_ILP64_NAMING_SCHEME"
6767
return dedent(f"""\
6868
libdir={get_lib_dir()}
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
From 258ad2ccebe93fa9c5ad74a17c603b3fb8925190 Mon Sep 17 00:00:00 2001
2+
From: mattip <[email protected]>
3+
Date: Sun, 21 Jan 2024 22:34:48 +0200
4+
Subject: [PATCH] create a single shared object
5+
6+
---
7+
Makefile | 10 ----------
8+
Makefile.install | 16 +---------------
9+
Makefile.system | 3 +++
10+
exports/Makefile | 4 ++--
11+
openblas.pc.in | 2 +-
12+
5 files changed, 7 insertions(+), 28 deletions(-)
13+
14+
diff --git a/Makefile b/Makefile
15+
index 8621a8b3f..56a449306 100644
16+
--- a/Makefile
17+
+++ b/Makefile
18+
@@ -134,17 +134,12 @@ shared : libs netlib $(RELA)
19+
ifneq ($(NO_SHARED), 1)
20+
ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS Android Haiku FreeBSD DragonFly))
21+
@$(MAKE) -C exports so
22+
- @ln -fs $(LIBSONAME) $(LIBPREFIX).so
23+
- @ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
24+
endif
25+
ifeq ($(OSNAME), $(filter $(OSNAME),OpenBSD NetBSD))
26+
@$(MAKE) -C exports so
27+
- @ln -fs $(LIBSONAME) $(LIBPREFIX).so
28+
endif
29+
ifeq ($(OSNAME), Darwin)
30+
@$(MAKE) -C exports dyn
31+
- @ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib
32+
- @ln -fs $(LIBDYNNAME) $(LIBPREFIX).$(MAJOR_VERSION).dylib
33+
endif
34+
ifeq ($(OSNAME), WINNT)
35+
@$(MAKE) -C exports dll
36+
@@ -229,13 +225,11 @@ endif
37+
endif
38+
@echo THELIBNAME=$(LIBNAME) >> Makefile.conf_last
39+
@echo THELIBSONAME=$(LIBSONAME) >> Makefile.conf_last
40+
- @-ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
41+
@touch lib.grd
42+
43+
prof : prof_blas prof_lapack
44+
45+
prof_blas :
46+
- ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
47+
for d in $(SUBDIRS) ; \
48+
do if test -d $$d; then \
49+
$(MAKE) -C $$d prof || exit 1 ; \
50+
@@ -230,7 +223,6 @@ ifeq ($(DYNAMIC_ARCH), 1)
51+
endif
52+
53+
blas :
54+
- ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
55+
for d in $(BLASDIRS) ; \
56+
do if test -d $$d; then \
57+
$(MAKE) -C $$d libs || exit 1 ; \
58+
@@ -238,7 +230,6 @@ blas :
59+
done
60+
61+
hpl :
62+
- ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
63+
for d in $(BLASDIRS) ../laswp exports ; \
64+
do if test -d $$d; then \
65+
$(MAKE) -C $$d $(@F) || exit 1 ; \
66+
@@ -252,7 +243,6 @@ ifeq ($(DYNAMIC_ARCH), 1)
67+
endif
68+
69+
hpl_p :
70+
- ln -fs $(LIBNAME_P) $(LIBPREFIX)_p.$(LIBSUFFIX)
71+
for d in $(SUBDIRS) ../laswp exports ; \
72+
do if test -d $$d; then \
73+
$(MAKE) -C $$d $(@F) || exit 1 ; \
74+
diff --git a/Makefile.install b/Makefile.install
75+
index 01899b970..cf3c8acce 100644
76+
--- a/Makefile.install
77+
+++ b/Makefile.install
78+
@@ -90,30 +90,20 @@ endif
79+
ifneq ($(NO_STATIC),1)
80+
@echo Copying the static library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
81+
@install -m644 $(LIBNAME) "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)"
82+
- @cd "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)" ; \
83+
- ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
84+
endif
85+
#for install shared library
86+
ifneq ($(NO_SHARED),1)
87+
@echo Copying the shared library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
88+
ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS Android Haiku FreeBSD DragonFly))
89+
@install -m755 $(LIBSONAME) "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)"
90+
- @cd "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)" ; \
91+
- ln -fs $(LIBSONAME) $(LIBPREFIX).so ; \
92+
- ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
93+
endif
94+
95+
ifeq ($(OSNAME), $(filter $(OSNAME),OpenBSD NetBSD))
96+
@cp $(LIBSONAME) "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)"
97+
- @cd "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)" ; \
98+
- ln -fs $(LIBSONAME) $(LIBPREFIX).so
99+
endif
100+
ifeq ($(OSNAME), Darwin)
101+
@-cp $(LIBDYNNAME) "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)"
102+
@-install_name_tool -id "$(OPENBLAS_LIBRARY_DIR)/$(LIBPREFIX).$(MAJOR_VERSION).dylib" "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME)"
103+
- @cd "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)" ; \
104+
- ln -fs $(LIBDYNNAME) $(LIBPREFIX).dylib ; \
105+
- ln -fs $(LIBDYNNAME) $(LIBPREFIX).$(MAJOR_VERSION).dylib
106+
endif
107+
ifeq ($(OSNAME), WINNT)
108+
@-cp $(LIBDLLNAME) "$(DESTDIR)$(OPENBLAS_BINARY_DIR)"
109+
@@ -140,16 +130,11 @@ endif
110+
ifneq ($(NO_STATIC),1)
111+
@echo Copying the static library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
112+
@installbsd -c -m 644 $(LIBNAME) "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)"
113+
- @cd "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)" ; \
114+
- ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
115+
endif
116+
#for install shared library
117+
ifneq ($(NO_SHARED),1)
118+
@echo Copying the shared library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
119+
@installbsd -c -m 755 $(LIBSONAME) "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)"
120+
- @cd "$(DESTDIR)$(OPENBLAS_LIBRARY_DIR)" ; \
121+
- ln -fs $(LIBSONAME) $(LIBPREFIX).so ; \
122+
- ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION)
123+
endif
124+
125+
endif
126+
@@ -162,6 +147,7 @@ endif
127+
128+
@echo Generating $(LIBSONAMEBASE)$(SUFFIX64).pc in "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)"
129+
@echo 'libdir='$(OPENBLAS_LIBRARY_DIR) > "$(PKGFILE)"
130+
+ @echo 'libprefix='$(SYMBOLPREFIX) >> "$(PKGFILE)"
131+
@echo 'libsuffix='$(SYMBOLSUFFIX) >> "$(PKGFILE)"
132+
@echo 'includedir='$(OPENBLAS_INCLUDE_DIR) >> "$(PKGFILE)"
133+
@echo 'openblas_config= USE_64BITINT='$(INTERFACE64) 'DYNAMIC_ARCH='$(DYNAMIC_ARCH) 'DYNAMIC_OLDER='$(DYNAMIC_OLDER) 'NO_CBLAS='$(NO_CBLAS) 'NO_LAPACK='$(NO_LAPACK) 'NO_LAPACKE='$(NO_LAPACKE) 'NO_AFFINITY='$(NO_AFFINITY) 'USE_OPENMP='$(USE_OPENMP) $(CORE) 'MAX_THREADS='$(NUM_THREADS)>> "$(PKGFILE)"
134+
diff --git a/Makefile.system b/Makefile.system
135+
index 30b0ddec2..b2c92b99a 100644
136+
--- a/Makefile.system
137+
+++ b/Makefile.system
138+
@@ -1695,6 +1695,9 @@ LIBNAME_P = $(LIBPREFIX)p$(REVISION)_p.$(LIBSUFFIX)
139+
endif
140+
endif
141+
142+
+# Override for scipy-openblas: don't put the revision into the so name
143+
+LIBNAME = $(LIBPREFIX).$(LIBSUFFIX)
144+
+LIBNAME_P = $(LIBPREFIX)_p.$(LIBSUFFIX)
145+
146+
LIBDLLNAME = $(LIBPREFIX).dll
147+
IMPLIBNAME = lib$(LIBNAMEBASE).dll.a
148+
diff --git a/exports/Makefile b/exports/Makefile
149+
index 7682f851d..632fa324b 100644
150+
--- a/exports/Makefile
151+
+++ b/exports/Makefile
152+
@@ -132,7 +132,7 @@ libgoto_hpl.def : $(GENSYM)
153+
./$(GENSYM) win2khpl $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)
154+
155+
ifeq ($(OSNAME), Darwin)
156+
-INTERNALNAME = $(LIBPREFIX).$(MAJOR_VERSION).dylib
157+
+INTERNALNAME = $(LIBPREFIX).dylib
158+
endif
159+
160+
ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
161+
@@ -169,7 +169,7 @@ INTERNALNAME = $(LIBPREFIX).so
162+
FEXTRALIB += -lm
163+
EXTRALIB += -lm
164+
else
165+
-INTERNALNAME = $(LIBPREFIX).so.$(MAJOR_VERSION)
166+
+INTERNALNAME = $(LIBPREFIX).so
167+
endif
168+
169+
ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
170+
diff --git a/openblas.pc.in b/openblas.pc.in
171+
index 8ad6e8bee..33209293d 100644
172+
--- a/openblas.pc.in
173+
+++ b/openblas.pc.in
174+
@@ -2,6 +2,6 @@ Name: openblas
175+
Description: OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version
176+
Version: ${version}
177+
URL: https://github.com/xianyi/OpenBLAS
178+
-Libs: -L${libdir} -lopenblas${libsuffix}
179+
+Libs: -L${libdir} -l${libprefix}openblas${libsuffix}
180+
Libs.private: ${extralib}
181+
Cflags: -I${includedir}
182+
--
183+
2.34.1
184+

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.24.95.1"
11+
version = "0.3.24.95.2"
1212
requires-python = ">=3.7"
1313
description = "Provides OpenBLAS for python packaging"
1414
readme = "README.md"

tools/build_openblas.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ cp -f "${static_libname}.renamed" "$openblas_root/$build_bits/lib/${DLL_BASENAME
122122

123123
cd $openblas_root
124124
# Copy library link file for custom name
125-
cd $build_bits/lib
125+
pushd $build_bits/lib
126126
cp ${our_wd}/OpenBLAS/exports/${DLL_BASENAME}.def ${DLL_BASENAME}.def
127127
# At least for the mingwpy wheel, we have to use the VC tools to build the
128128
# export library. Maybe fixed in later binutils by patch referred to in
@@ -135,7 +135,13 @@ dlltool --input-def ${DLL_BASENAME}.def \
135135
--output-lib ${DLL_BASENAME}.lib
136136
# Replace the DLL name with the generated name.
137137
sed -i "s/ -lopenblas.*$/ -l${DLL_BASENAME:3}/g" pkgconfig/openblas*.pc
138-
cd ../..
138+
mv pkgconfig/*.pc pkgconfig/scipy-openblas.pc
139+
if [ "$if_bits" == "64" ]; then
140+
sed -e "s/^Cflags.*/\0 -DBLAS_SYMBOL_PREFIX=scipy_ -DBLAS_SYMBOL_SUFFIX=64_/" -i pkgconfig/scipy-openblas.pc
141+
else
142+
sed -e "s/^Cflags.*/\0 -DBLAS_SYMBOL_PREFIX=scipy_/" -i pkgconfig/scipy-openblas.pc
143+
fi
144+
popd
139145
# Build template site.cfg for using this build
140146
cat > ${build_bits}/site.cfg.template << EOF
141147
[openblas${SYMBOLSUFFIX}]

tools/build_steps.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ function build_lib {
9393

9494
function patch_source {
9595
# Runs inside OpenBLAS directory
96-
# bash does not like an empty function, add a null statement
97-
:
96+
# Make the patches by git format-patch <old commit>
97+
for f in $(ls ../patches); do
98+
echo applying patch $f
99+
git apply ../patches/$f
100+
done
98101
}
99102

100103
function do_build_lib {
@@ -175,6 +178,7 @@ function do_build_lib {
175178
else
176179
local version=$(cd OpenBLAS && git describe --tags --abbrev=8)
177180
fi
181+
mv $BUILD_PREFIX/lib/pkgconfig/openblas*.pc $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc
178182
local plat_tag=$(get_plat_tag $plat)
179183
local suff=""
180184
[ -n "$suffix" ] && suff="-$suffix"
@@ -183,16 +187,18 @@ function do_build_lib {
183187
# do it ourselves
184188
static_libname=$(basename `find OpenBLAS -maxdepth 1 -type f -name '*.a' \! -name '*.dll.a'`)
185189
renamed_libname=$(basename `find OpenBLAS -maxdepth 1 -type f -name '*.renamed'`)
186-
# set -x # echo commands
187190
cp -f "OpenBLAS/${renamed_libname}" "$BUILD_PREFIX/lib/${static_libname}"
188-
# set +x
191+
sed -e "s/^Cflags.*/\0 -DBLAS_SYMBOL_PREFIX=scipy_ -DBLAS_SYMBOL_SUFFIX=64_/" -i.bak $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc
192+
else
193+
sed -e "s/^Cflags.*/\0 -DBLAS_SYMBOL_PREFIX=scipy_/" -i.bak $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc
189194
fi
195+
190196
local out_name="openblas${symbolsuffix}-${version}-${plat_tag}${suff}.tar.gz"
191197
tar zcvf libs/$out_name \
192198
$BUILD_PREFIX/include/*blas* \
193199
$BUILD_PREFIX/include/*lapack* \
194200
$BUILD_PREFIX/lib/libscipy_openblas* \
195-
$BUILD_PREFIX/lib/pkgconfig/openblas* \
201+
$BUILD_PREFIX/lib/pkgconfig/scipy-openblas* \
196202
$BUILD_PREFIX/lib/cmake/openblas
197203
}
198204

tools/local_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ else
1818

1919
fi
2020
export REPO_DIR=OpenBLAS
21-
export OPENBLAS_COMMIT="c2f4bdb"
21+
export OPENBLAS_COMMIT="v0.3.26"
2222

2323
# export MB_ML_LIBC=musllinux
2424
# export MB_ML_VER=_1_1

0 commit comments

Comments
 (0)