Skip to content

Commit db0024b

Browse files
authored
Merge pull request #7 from OpenPTV/copilot/fix-cibuildwheels-bugs
Fix Windows builds: handle scipy-openblas64 ILP64 interface and MSVC incompatibilities
2 parents 8d6a706 + c2ea444 commit db0024b

File tree

4 files changed

+37
-30
lines changed

4 files changed

+37
-30
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ jobs:
2222
with:
2323
python-version: "3.11"
2424

25-
- name: Install cibuildwheel and build dependencies
26-
run: |
27-
python -m pip install --upgrade pip
28-
# Install these on the host so cibuildwheel can resolve the paths
29-
python -m pip install cibuildwheel scipy-openblas delvewheel
25+
- name: Install cibuildwheel
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install cibuildwheel
3029
31-
- name: Build wheels
32-
run: python -m cibuildwheel --output-dir wheelhouse
30+
- name: Install Windows build dependencies
31+
if: runner.os == 'Windows'
32+
run: |
33+
# Install these on the host so cibuildwheel can resolve the paths
34+
python -m pip install scipy-openblas64 delvewheel
3335
3436
- name: Build wheels
3537
run: python -m cibuildwheel --output-dir wheelhouse

_codeql_detected_source_root

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.

pyproject.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ environment = { EASYSBA_USE_ACCELERATE = "1", EASYSBA_LAPACK_LIBS = "" }
2727
[tool.cibuildwheel.windows]
2828
# We already installed these on the host, but we install them in the
2929
# build venv as well to be safe for the repair step.
30-
before-build = "pip install scipy-openblas delvewheel"
30+
before-build = "pip install scipy-openblas64 delvewheel"
31+
# Use the repair-wheel-command to bundle the DLL
32+
repair-wheel-command = "python -c \"import scipy_openblas64, subprocess, sys; subprocess.check_call(['delvewheel', 'repair', '--add-path', scipy_openblas64.get_lib_dir(), '-w', sys.argv[1], sys.argv[2]])\" {dest_dir} {wheel}"
3133

3234
[tool.cibuildwheel.windows.environment]
33-
EASYSBA_LAPACK_LIBS = "openblas"
34-
# These $(...) commands will now work because scipy-openblas is on the host
35-
INCLUDE = "$(python -c \"import scipy_openblas; print(scipy_openblas.get_include_dir())\");$INCLUDE"
36-
LIB = "$(python -c \"import scipy_openblas; print(scipy_openblas.get_lib_dir())\");$LIB"
37-
38-
[tool.cibuildwheel.windows.repair-wheel-command]
39-
# Use the repair-wheel-command to bundle the DLL
40-
repair-wheel-command = "python -c \"import scipy_openblas, subprocess, sys; subprocess.check_call(['delvewheel', 'repair', '--add-path', scipy_openblas.get_lib_dir(), '-w', sys.argv[1], sys.argv[2]])\" {dest_dir} {wheel}"
35+
EASYSBA_LAPACK_LIBS = "libscipy_openblas64_"
36+
# Only add the library directory for linking. Do NOT add include directory
37+
# to avoid conflicts with scipy-openblas64's lapack.h (has C99 complex types
38+
# incompatible with MSVC). The project has its own lapack_compat.h header.
39+
LIB = "$(python -c \"import scipy_openblas64; print(scipy_openblas64.get_lib_dir())\");$LIB"

src/lapack_compat.h

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,53 @@ extern "C" {
77

88
typedef int lapack_int;
99

10+
// On Windows with scipy-openblas64, symbols have scipy_ prefix and 64_ suffix
11+
#if defined(_WIN32) || defined(_WIN64)
12+
#define FORTRAN_WRAPPER(name) scipy_##name##64_
13+
#else
1014
#define FORTRAN_WRAPPER(name) name##_
15+
#endif
1116

12-
void dgeqrf_(const lapack_int *m, const lapack_int *n, double *a,
17+
void FORTRAN_WRAPPER(dgeqrf)(const lapack_int *m, const lapack_int *n, double *a,
1318
const lapack_int *lda, double *tau, double *work,
1419
const lapack_int *lwork, lapack_int *info);
15-
void dorgqr_(const lapack_int *m, const lapack_int *n, const lapack_int *k,
20+
void FORTRAN_WRAPPER(dorgqr)(const lapack_int *m, const lapack_int *n, const lapack_int *k,
1621
double *a, const lapack_int *lda, const double *tau,
1722
double *work, const lapack_int *lwork, lapack_int *info);
18-
void dtrtrs_(const char *uplo, const char *trans, const char *diag,
23+
void FORTRAN_WRAPPER(dtrtrs)(const char *uplo, const char *trans, const char *diag,
1924
const lapack_int *n, const lapack_int *nrhs, const double *a,
2025
const lapack_int *lda, double *b, const lapack_int *ldb,
2126
lapack_int *info);
22-
void dpotrf_(const char *uplo, const lapack_int *n, double *a,
27+
void FORTRAN_WRAPPER(dpotrf)(const char *uplo, const lapack_int *n, double *a,
2328
const lapack_int *lda, lapack_int *info);
24-
void dpotrs_(const char *uplo, const lapack_int *n, const lapack_int *nrhs,
29+
void FORTRAN_WRAPPER(dpotrs)(const char *uplo, const lapack_int *n, const lapack_int *nrhs,
2530
const double *a, const lapack_int *lda, double *b,
2631
const lapack_int *ldb, lapack_int *info);
27-
void dgetrf_(const lapack_int *m, const lapack_int *n, double *a,
32+
void FORTRAN_WRAPPER(dgetrf)(const lapack_int *m, const lapack_int *n, double *a,
2833
const lapack_int *lda, lapack_int *ipiv, lapack_int *info);
29-
void dgetrs_(const char *trans, const lapack_int *n, const lapack_int *nrhs,
34+
void FORTRAN_WRAPPER(dgetrs)(const char *trans, const lapack_int *n, const lapack_int *nrhs,
3035
const double *a, const lapack_int *lda, const lapack_int *ipiv,
3136
double *b, const lapack_int *ldb, lapack_int *info);
32-
void dgetri_(const lapack_int *n, double *a, const lapack_int *lda,
37+
void FORTRAN_WRAPPER(dgetri)(const lapack_int *n, double *a, const lapack_int *lda,
3338
const lapack_int *ipiv, double *work, const lapack_int *lwork,
3439
lapack_int *info);
35-
void dgesdd_(const char *jobz, const lapack_int *m, const lapack_int *n,
40+
void FORTRAN_WRAPPER(dgesdd)(const char *jobz, const lapack_int *m, const lapack_int *n,
3641
double *a, const lapack_int *lda, double *s, double *u,
3742
const lapack_int *ldu, double *vt, const lapack_int *ldvt,
3843
double *work, const lapack_int *lwork, lapack_int *iwork,
3944
lapack_int *info);
40-
void dsytrf_(const char *uplo, const lapack_int *n, double *a,
45+
void FORTRAN_WRAPPER(dsytrf)(const char *uplo, const lapack_int *n, double *a,
4146
const lapack_int *lda, lapack_int *ipiv, double *work,
4247
const lapack_int *lwork, lapack_int *info);
43-
void dsytrs_(const char *uplo, const lapack_int *n, const lapack_int *nrhs,
48+
void FORTRAN_WRAPPER(dsytrs)(const char *uplo, const lapack_int *n, const lapack_int *nrhs,
4449
const double *a, const lapack_int *lda, const lapack_int *ipiv,
4550
double *b, const lapack_int *ldb, lapack_int *info);
46-
void dsytri_(const char *uplo, const lapack_int *n, double *a,
51+
void FORTRAN_WRAPPER(dsytri)(const char *uplo, const lapack_int *n, double *a,
4752
const lapack_int *lda, const lapack_int *ipiv, double *work,
4853
lapack_int *info);
49-
void dpotf2_(const char *uplo, const lapack_int *n, double *a,
54+
void FORTRAN_WRAPPER(dpotf2)(const char *uplo, const lapack_int *n, double *a,
5055
const lapack_int *lda, lapack_int *info);
51-
void dpotri_(const char *uplo, const lapack_int *n, double *a,
56+
void FORTRAN_WRAPPER(dpotri)(const char *uplo, const lapack_int *n, double *a,
5257
const lapack_int *lda, lapack_int *info);
5358

5459
#ifdef __cplusplus

0 commit comments

Comments
 (0)