Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix suitesparse / cvxopt path configuration for Apple Silicon, Alpine Linux #31905

Closed
kcrisman opened this issue Jun 4, 2021 · 12 comments
Closed

Comments

@kcrisman
Copy link
Member

kcrisman commented Jun 4, 2021

I was able to successfully build Sage on M1 (see #30592) but had two main types of doctest errors.

> However, I did see some of this type as well in the sage/numerical tests: 
> 
> ImportError: dlopen(/Users/karl.crisman/Downloads/BrewSage/sage-9.4.beta0/local/lib/python3.9/site-packages/cvxopt/cholmod.cpython-39-darwin.so, 2): Symbol not found: _cholmod_l_allocate_dense 
> Referenced from: /Users/karl.crisman/Downloads/BrewSage/sage-9.4.beta0/local/lib/python3.9/site-packages/cvxopt/cholmod.cpython-39-darwin.so 
> Expected in: flat namespace 
> in /Users/karl.crisman/Downloads/BrewSage/sage-9.4.beta0/local/lib/python3.9/site-packages/cvxopt/cholmod.cpython-39-darwin.so 


otool -L /Users/karl.crisman/Downloads/BrewSage/sage-9.4.beta0/local/lib/python3.9/site-packages/cvxopt/cholmod.cpython-39-darwin.so 


/Users/karl.crisman/Downloads/BrewSage/sage-9.4.beta0/local/lib/python3.9/site-packages/cvxopt/cholmod.cpython-39-darwin.so:
	/opt/homebrew/opt/openblas/lib/libopenblas.0.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5) 

This apparently requires a change in the setup.py (see this sage-devel discussion):

if sys.platform.startswith("darwin"): 
SUITESPARSE_LIB_DIR = '/usr/local/lib' 
SUITESPARSE_INC_DIR = '/usr/local/include' 

to allow /opt/homebrew.

Upstream: Reported upstream. No feedback yet.

CC: @dimpase @mkoeppe @orlitzky @kiwifb

Component: porting

Issue created by migration from https://trac.sagemath.org/ticket/31905

@kcrisman kcrisman added this to the sage-9.4 milestone Jun 4, 2021
@kcrisman
Copy link
Member Author

kcrisman commented Jun 4, 2021

comment:1

The following diff works and fixes the bad doctests for me (except some unrelated ones for graphics).

diff --git a/build/pkgs/cvxopt/patches/libsuitesparse_path.patch b/build/pkgs/cvxopt/patches/libsuitesparse_path.patch
index fc8908aa7f..2da0e1f36a 100644
--- a/build/pkgs/cvxopt/patches/libsuitesparse_path.patch
+++ b/build/pkgs/cvxopt/patches/libsuitesparse_path.patch
@@ -1,10 +1,13 @@
 diff --git a/setup.py b/setup.py
-index d312416..4fa14c4 100644
 --- a/setup.py
 +++ b/setup.py
-@@ -58,9 +58,9 @@ if sys.platform.startswith("darwin"):
-     SUITESPARSE_LIB_DIR = '/usr/local/lib'
-     SUITESPARSE_INC_DIR = '/usr/local/include'
+@@ -56,11 +56,11 @@
+ if sys.platform.startswith("darwin"):
+     # macOS
+-    SUITESPARSE_LIB_DIR = '/usr/local/lib'
+-    SUITESPARSE_INC_DIR = '/usr/local/include'
++    SUITESPARSE_LIB_DIR = '/opt/homebrew/lib'
++    SUITESPARSE_INC_DIR = '/opt/homebrew/include'
  else:
 -    if glob("/usr/lib/x86_64-linux-gnu/libsuitesparse*"):
 -        # Ubuntu/Debian

I am not currently in a position to make a proper branch with this testing setup, my apologies, and in any case it needs some additional logic to test for which version of MacOS we have and/or if homebrew is being used.

@mkoeppe
Copy link
Member

mkoeppe commented Jun 4, 2021

comment:2

Upstream report...

@kcrisman
Copy link
Member Author

kcrisman commented Jun 4, 2021

comment:3

Upstream report...

Will they see this as a bug? I already asked about whether to report upstream here.

@kcrisman
Copy link
Member Author

kcrisman commented Jun 4, 2021

Upstream: Reported upstream. No feedback yet.

@kcrisman
Copy link
Member Author

kcrisman commented Jun 4, 2021

comment:4

cvxopt/cvxopt#195

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 22, 2021
@mkoeppe
Copy link
Member

mkoeppe commented Jan 17, 2022

comment:6

These defaults in cvxopt's setup.py can be overridden using environment variables
CVXOPT_SUITESPARSE_INC_DIR, CVXOPT_SUITESPARSE_LIB_DIR.
We already set these variables when we build our own suitesparse (then SAGE_SUITESPARSE_PREFIX is nonempty).

On macOS, we could just set these variables also (to something arbitrary) when system suitesparse is in use.

See also #33083 comment:40 - a related issue on alpine.

@mkoeppe mkoeppe changed the title cvxopt links wrong M1 directory Fix suitesparse / cvxopt path configuration for Apple Silicon, Alpine Linux Jan 17, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Jan 28, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 May 3, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@jhpalmieri
Copy link
Member

comment:11

Maybe this is resolved? I can build Sage (including cvxopt) on an M2 computer using homebrew's suitesparse, and all tests pass. If that's the issue, perhaps it's solved. Or is it about using Sage's suitesparse + Sage's cvxopt?

@mkoeppe
Copy link
Member

mkoeppe commented Sep 26, 2022

comment:12

It's plausible that the cvxopt update in #34150 may have fixed it, but I haven't checked

@jhpalmieri
Copy link
Member

comment:13

setup.py still says

if sys.platform.startswith("darwin"):
    # macOS
    SUITESPARSE_LIB_DIR = '/usr/local/lib'
    SUITESPARSE_INC_DIR = '/usr/local/include'

and /opt is not found anywhere in that file, and looking at the log file, I don't know how it's finding the suitesparse libraries.

@jhpalmieri
Copy link
Member

comment:14

I propose closing this. Sage builds fine on my M2, using a homebrew installation of suitesparse.

@jhpalmieri jhpalmieri removed this from the sage-9.8 milestone Nov 16, 2022
@dimpase
Copy link
Member

dimpase commented Nov 16, 2022

comment:16

Replying to John Palmieri:

I propose closing this. Sage builds fine on my M2, using a homebrew installation of suitesparse.

can one build Sage's suitsparse on M2, and use it to build cvxopt?
If so, we can close it.

@jhpalmieri
Copy link
Member

comment:17

Replying to Dima Pasechnik:

Replying to John Palmieri:

I propose closing this. Sage builds fine on my M2, using a homebrew installation of suitesparse.

can one build Sage's suitsparse on M2, and use it to build cvxopt?
If so, we can close it.

I can build successfully using Sage's suitesparse and also homebrew's suitesparse, so setting to positive review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants