Instead of trying to convince setup.py to do what we want, the wheel
package empowers us to unpack and directly manipulate the wheel.
In particular this is important because `--skip-build` really does
not work.

First we build a native wheel. If skip_host is True, then this
"native" wheel has defective empty files as binaries, if it's False,
we build a real native wheel. If skip_host is False, then we use
pip to install our native wheel into host directory.

Then we unpack the wheel, replace the platform tag with
wasm32_emscripten, remove the non-metadata files, and copy in the
new files with the cross compiled binaries.

Of course, this is all only necessary for binary extensions.


Hopefully this will help get us towards using alternative build
backends. The one concern is that this approach depends on
implementation details of where the build backend puts the files
into the directory tree before copying them into the wheel. If
the build backend moved the linked binaries after building them,
we would be in trouble. Or worse if the build backend deleted the
files after packing them into the wheel, we'd be in trouble.

Basically, it seems clear that we can only support alternative
build backends on a case-by-case basis.

@henryiii I'm curious what your thoughts are cross compilation + arbitrary build backends.

Better package cross compilation. Instead of trying to convince setup.py to do what we want, the wheel
package empowers us to unpack and directly manipulate the wheel.
In particular this is important because `--skip-build` really does
not work.

First we build a native wheel. If skip_host is True, then this
"native" wheel has defective empty files as binaries, if it's False,
we build a real native wheel. If skip_host is False, then we use
pip to install our native wheel into host directory.

Then we unpack the wheel, replace the platform tag with
wasm32_emscripten, remove the non-metadata files, and copy in the
new files with the cross compiled binaries.

Of course, this is all only necessary for binary extensions.


Hopefully this will help get us towards using alternative build
backends. The one concern is that this approach depends on
implementation details of where the build backend puts the files
into the directory tree before copying them into the wheel. If
the build backend moved the linked binaries after building them,
we would be in trouble. Or worse if the build backend deleted the
files after packing them into the wheel, we'd be in trouble.

Basically, it seems clear that we can only support alternative
build backends on a case-by-case basis.

@henryiii I'm curious what your thoughts are cross compilation + arbitrary build backends.

From 549ab1f7916e16222bdfc67a46f7a7b9b2125265 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 18 Dec 2021 11:41:15 -0800
Subject: [PATCH] gemm_ no const

cgemm, dgemm, sgemm, and zgemm are declared with `const` in slu_cdefs.h, but 
other places don't have the cosnt causing compile errors.
This patch drops the consts and fixes the problem.

---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
index 346f9af0a..8af19888f 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
@@ -272,9 +272,9 @@ extern void    ccheck_tempv(int, complex *);
 
 /*! \brief BLAS */
 
-extern int cgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const complex*, const complex*, const int*, const complex*,
-		  const int*, const complex*, complex*, const int*);
+extern int cgemm_( char*,  char*,  int*,  int*,  int*,
+                   complex*,  complex*,  int*,  complex*,
+		   int*,  complex*, complex*,  int*);
 extern int ctrsv_(char*, char*, char*, int*, complex*, int*,
                   complex*, int*);
 extern int ctrsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
index 934cd677a..33e869fb7 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
@@ -269,9 +269,9 @@ extern void    dcheck_tempv(int, double *);
 
 /*! \brief BLAS */
 
-extern int dgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const double*, const double*, const int*, const double*,
-		  const int*, const double*, double*, const int*);
+extern int dgemm_( char*,  char*,  int*,  int*,  int*,
+                   double*,  double*,  int*,  double*,
+		   int*,  double*, double*,  int*);
 extern int dtrsv_(char*, char*, char*, int*, double*, int*,
                   double*, int*);
 extern int dtrsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
index 1b6db977e..fee4bc1d6 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
@@ -269,9 +269,9 @@ extern void    scheck_tempv(int, float *);
 
 /*! \brief BLAS */
 
-extern int sgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const float*, const float*, const int*, const float*,
-		  const int*, const float*, float*, const int*);
+extern int sgemm_( char*,  char*,  int*,  int*,  int*,
+                   float*,  float*,  int*,  float*,
+		   int*,  float*, float*,  int*);
 extern int strsv_(char*, char*, char*, int*, float*, int*,
                   float*, int*);
 extern int strsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
index abb7d937e..6c572ff2b 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
@@ -272,9 +272,9 @@ extern void    zcheck_tempv(int, doublecomplex *);
 
 /*! \brief BLAS */
 
-extern int zgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const doublecomplex*, const doublecomplex*, const int*, const doublecomplex*,
-		  const int*, const doublecomplex*, doublecomplex*, const int*);
+extern int zgemm_( char*,  char*,  int*,  int*,  int*,
+                   doublecomplex*,  doublecomplex*,  int*,  doublecomplex*,
+		   int*,  doublecomplex*, doublecomplex*,  int*);
 extern int ztrsv_(char*, char*, char*, int*, doublecomplex*, int*,
                   doublecomplex*, int*);
 extern int ztrsm_(char*, char*, char*, char*, int*, int*,
-- 
2.25.1


From 549ab1f7916e16222bdfc67a46f7a7b9b2125265 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 18 Dec 2021 11:41:15 -0800
Subject: [PATCH] gemm_ no const

cgemm, dgemm, sgemm, and zgemm are declared with `const` in slu_cdefs.h, but 
other places don't have the cosnt causing compile errors.
This patch drops the consts and fixes the problem.

---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
index 346f9af0a..8af19888f 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
@@ -272,9 +272,9 @@ extern void    ccheck_tempv(int, complex *);
 
 /*! \brief BLAS */
 
-extern int cgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const complex*, const complex*, const int*, const complex*,
-		  const int*, const complex*, complex*, const int*);
+extern int cgemm_( char*,  char*,  int*,  int*,  int*,
+                   complex*,  complex*,  int*,  complex*,
+		   int*,  complex*, complex*,  int*);
 extern int ctrsv_(char*, char*, char*, int*, complex*, int*,
                   complex*, int*);
 extern int ctrsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
index 934cd677a..33e869fb7 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
@@ -269,9 +269,9 @@ extern void    dcheck_tempv(int, double *);
 
 /*! \brief BLAS */
 
-extern int dgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const double*, const double*, const int*, const double*,
-		  const int*, const double*, double*, const int*);
+extern int dgemm_( char*,  char*,  int*,  int*,  int*,
+                   double*,  double*,  int*,  double*,
+		   int*,  double*, double*,  int*);
 extern int dtrsv_(char*, char*, char*, int*, double*, int*,
                   double*, int*);
 extern int dtrsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
index 1b6db977e..fee4bc1d6 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
@@ -269,9 +269,9 @@ extern void    scheck_tempv(int, float *);
 
 /*! \brief BLAS */
 
-extern int sgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const float*, const float*, const int*, const float*,
-		  const int*, const float*, float*, const int*);
+extern int sgemm_( char*,  char*,  int*,  int*,  int*,
+                   float*,  float*,  int*,  float*,
+		   int*,  float*, float*,  int*);
 extern int strsv_(char*, char*, char*, int*, float*, int*,
                   float*, int*);
 extern int strsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
index abb7d937e..6c572ff2b 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
@@ -272,9 +272,9 @@ extern void    zcheck_tempv(int, doublecomplex *);
 
 /*! \brief BLAS */
 
-extern int zgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const doublecomplex*, const doublecomplex*, const int*, const doublecomplex*,
-		  const int*, const doublecomplex*, doublecomplex*, const int*);
+extern int zgemm_( char*,  char*,  int*,  int*,  int*,
+                   doublecomplex*,  doublecomplex*,  int*,  doublecomplex*,
+		   int*,  doublecomplex*, doublecomplex*,  int*);
 extern int ztrsv_(char*, char*, char*, int*, doublecomplex*, int*,
                   doublecomplex*, int*);
 extern int ztrsm_(char*, char*, char*, char*, int*, int*,
-- 
2.25.1

