Skip to content

Commit 58550fa

Browse files
committed
tweak for 32/64 bit wheels, fixes for windows
1 parent 47bdfaf commit 58550fa

File tree

6 files changed

+67
-42
lines changed

6 files changed

+67
-42
lines changed

.github/workflows/posix.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
os: [ubuntu-latest, macos-11]
2222
PLAT: [i686, x86_64]
2323
INTERFACE64: ['0', '1']
24-
MB_ML_VER: [2014]
24+
MB_ML_VER: ['2014']
2525
include:
2626
- os: macos-11
2727
PLAT: arm64
@@ -40,8 +40,8 @@ jobs:
4040
MB_ML_LIBC: musllinux
4141
MB_ML_VER: _1_1
4242
exclude:
43-
- os: macos-11
44-
MB_ML_VER: 2014
43+
- PLAT: i686
44+
os: macos-11
4545
- PLAT: i686
4646
INTERFACE64: '1'
4747
env:

.github/workflows/windows.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
OPENBLAS_COMMIT: "c2f4bdb"
1111
OPENBLAS_ROOT: "c:\\opt"
1212
# Preserve working directory for calls into bash
13+
# Without this, invoking bash will cd to the home directory
1314
CHERE_INVOKING: "yes"
1415
BASH_PATH: "c:\\rtools40\\usr\\bin\\bash.exe"
1516

@@ -38,7 +39,7 @@ jobs:
3839
echo "START_DIR=$PWD" >> $env:GITHUB_ENV
3940
# For interpretation of MSYSTEM, see:
4041
# https://sourceforge.net/p/msys2/discussion/general/thread/b7dfdac8/#3939
41-
if ( ${{ matrix.plat }} -eq x86) {
42+
if ( "${{ matrix.plat }}" -eq "x86") {
4243
echo "PLAT=i686" >> $env:GITHUB_ENV
4344
echo "MSYSTEM=MINGW32" >> $env:GITHUB_ENV
4445
echo "LDFLAGS=-static -static-libgcc" >> $env:GITHUB_ENV
@@ -79,12 +80,41 @@ jobs:
7980

8081
- name: Build wheel
8182
run: |
82-
& $env:BASH_PATH -lc tools/build_wheel_winbash.sh
83+
python -m pip install wheel
84+
# This will fail if there is more than one file in libs
85+
unzip -d local/openblas builds/openblas*.zip
86+
if [[ -d local\openblas\64 ]]; then
87+
mv local/openblas/64/* local/openblas
88+
rm -rf local/openblas/64
89+
) ELSE (
90+
mv local/openblas/32/* local/openblas
91+
rm -rf local/openblas/32
92+
)
93+
mv local/openblas/bin/*.dll local/openblas/lib
94+
rm local/openblas/lib/*.a
95+
rm local/openblas/lib/*.exp
96+
rm local/openblas/lib/*.def
97+
python -m pip wheel -w dist -vv .
98+
99+
- name: Set up different Python
100+
uses: actions/setup-python@v4
101+
with:
102+
python-version: 3.11
103+
architecture: ${{ matrix.plat }}
104+
105+
- name: Test wheel
106+
run: |
107+
python -m pip install --no-index --find-links dist openblas
108+
python -m openblas
83109
84110
- uses: actions/upload-artifact@v3
85111
with:
86112
path: builds/openblas*.zip
87113

114+
- uses: actions/upload-artifact@v3
115+
with:
116+
path: dist/openblas*.whl
117+
88118
- uses: conda-incubator/setup-miniconda@v2
89119
with:
90120
activate-environment: upload

setup.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ def get_tag(self):
1212
python, abi, plat = bdist_wheel.get_tag(self)
1313
return python, "abi3", plat
1414

15+
library_dir=os.path.join(mydir, 'local', 'openblas', 'lib')
16+
inc_dir=os.path.join(mydir, 'local', 'openblas', 'include')
1517

16-
# TODO: determine if we are building 64- or 32- bit interfaces
17-
use_64=True
18-
if use_64:
19-
macros = [("SUFFIX", "64_")]
18+
if sys.platform == "win32":
19+
# Get libopenblas*.lib
20+
libnames = [x for x in os.listdir(library_dir) if x.endswith(".lib")]
2021
else:
21-
macros = []
22+
# Get openblas*
23+
libnames = [os.path.splitext(x)[0][3:]
24+
for x in os.listdir(library_dir) if x.startswith("libopenblas")]
25+
26+
macros = []
2227

2328
if sys.implementation.name == "cpython":
2429
cmdclass = {"bdist_wheel": bdist_wheel_abi3}
@@ -28,16 +33,12 @@ def get_tag(self):
2833
cmdclass = {}
2934
py_limited_api = {}
3035

31-
library_dir=os.path.join(mydir, 'local', 'openblas', 'lib')
32-
if sys.platform == "win32":
33-
libnames = [x for x in os.listdir(library_dir) if x.endswith(".lib")]
34-
else:
35-
libnames = [x for x in os.listdir(library_dir) if x.startswith("libopenblas")]
3636
setup(
3737
cmdclass=cmdclass,
3838
ext_modules=[Extension(
3939
"openblas._init_openblas", ["src/_init_openblas.c"],
40-
libraries=["openblas_python"],
40+
include_dirs=[inc_dir],
41+
libraries=libnames,
4142
library_dirs=[library_dir],
4243
extra_link_args=["-Wl,-rpath,$ORIGIN/lib"],
4344
define_macros=macros,

src/_init_openblas.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include <Python.h>
2+
#include <openblas_config.h>
23

3-
#ifdef SUFFIX
4+
#ifdef OPENBLAS_USE64BITINT
45
#define openblas_get_config openblas_get_config64_
56
#endif
67

7-
extern const char * openblas_get_config();
8-
98
PyObject *
109
get_config(PyObject *self, PyObject *args) {
1110
const char * config = openblas_get_config();

tools/build_wheel_winbash.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

travis-ci/build_wheel.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,32 @@ if [ "$?" != "0" ]; then
66
fi
77

88
mkdir -p local/openblas
9+
mkdir -p dist
10+
python3.7 -m pip install wheel auditwheel
11+
912
# This will fail if there is more than one file in libs
1013
tar -C local/openblas --strip-components=2 -xf libs/openblas*.tar.gz
1114

1215
# do not package the static libs and symlinks, only take the shared object
1316
find local/openblas/lib -maxdepth 1 -type l -delete
1417
rm local/openblas/lib/*.a
15-
1618
mv local/openblas/lib/libopenblas* local/openblas/lib/libopenblas_python.so
17-
patchelf --set-soname libopenblas_python.so local/openblas/lib/libopenblas_python.so
18-
python3.7 -m pip install wheel auditwheel
19-
python3.7 -m pip wheel -w /tmp/wheelhouse -vv .
20-
auditwheel repair -w dist/ /tmp/wheelhouse/openblas-*.whl
19+
20+
if [ $(uname) != "Darwin" ]; then
21+
patchelf --set-soname libopenblas_python.so local/openblas/lib/libopenblas_python.so
22+
fi
23+
24+
python3.7 -m pip wheel -w dist -vv .
25+
if [ $(uname) == "Darwin" ]; then
26+
python3.7 -m pip install delocate
27+
delocate-wheel dist/*.whl
28+
else
29+
auditwheel repair dist/*.whl
30+
fi
2131

2232
# Test that the wheel works with a different python
2333
python3.11 -m pip install --no-index --find-links dist openblas
34+
if [ $(uname) == "Darwin" ]; then
35+
otool -L /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/openblas/_init_openblas.abi3.so
36+
fi
2437
python3.11 -m openblas

0 commit comments

Comments
 (0)