Skip to content

Commit 68c771a

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

File tree

6 files changed

+56
-40
lines changed

6 files changed

+56
-40
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: 24 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,33 @@ 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 EXIST local\openblas\64 (
87+
move local\openblas\64\lib local\openblas\lib
88+
move local\openblas\64\include local\openblas\include
89+
move local\openblas\64\bin\* local\openblas\lib
90+
rmdir /s /q local\openblas\64
91+
) ELSE (
92+
move local\openblas\32\lib local\openblas\lib
93+
move local\openblas\32\include local\openblas\include
94+
move local\openblas\32\bin\* local\openblas\lib
95+
rmdir /s /q local\openblas\32
96+
)
97+
del /y local/openblas/lib/*.a
98+
del /y local/openblas/lib/*.exp
99+
del /y local/openblas/lib/*.def
100+
python -m pip wheel -w dist -vv .
83101
84102
- uses: actions/upload-artifact@v3
85103
with:
86104
path: builds/openblas*.zip
87105

106+
- uses: actions/upload-artifact@v3
107+
with:
108+
path: dist/openblas*.whl
109+
88110
- uses: conda-incubator/setup-miniconda@v2
89111
with:
90112
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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

tools/build_wheel_winbash.sh

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

travis-ci/build_wheel.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,28 @@ 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 -w 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

0 commit comments

Comments
 (0)