Opened 13 months ago

Last modified 2 months ago

#31905 new defect

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

Reported by: kcrisman Owned by:
Priority: major Milestone: sage-9.7
Component: porting Keywords:
Cc: dimpase, mkoeppe, mjo, fbissey Merged in:
Authors: Reviewers:
Report Upstream: Reported upstream. No feedback yet. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

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.

Change History (9)

comment:1 Changed 13 months ago by kcrisman

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

  • build/pkgs/cvxopt/patches/libsuitesparse_path.patch

    diff --git a/build/pkgs/cvxopt/patches/libsuitesparse_path.patch b/build/pkgs/cvxopt/patches/libsuitesparse_path.patch
    index fc8908aa7f..2da0e1f36a 100644
    a b  
    11diff --git a/setup.py b/setup.py
    2 index d312416..4fa14c4 100644
    32--- a/setup.py
    43+++ b/setup.py
    5 @@ -58,9 +58,9 @@ if sys.platform.startswith("darwin"):
    6      SUITESPARSE_LIB_DIR = '/usr/local/lib'
    7      SUITESPARSE_INC_DIR = '/usr/local/include'
     4@@ -56,11 +56,11 @@
     5 if sys.platform.startswith("darwin"):
     6     # macOS
     7-    SUITESPARSE_LIB_DIR = '/usr/local/lib'
     8-    SUITESPARSE_INC_DIR = '/usr/local/include'
     9+    SUITESPARSE_LIB_DIR = '/opt/homebrew/lib'
     10+    SUITESPARSE_INC_DIR = '/opt/homebrew/include'
    811 else:
    912-    if glob("/usr/lib/x86_64-linux-gnu/libsuitesparse*"):
    1013-        # 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.

comment:2 follow-up: Changed 13 months ago by mkoeppe

Upstream report...

comment:3 in reply to: ↑ 2 Changed 13 months ago by kcrisman

Upstream report...

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

comment:4 Changed 13 months ago by kcrisman

  • Report Upstream changed from N/A to Reported upstream. No feedback yet.

comment:5 Changed 10 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:6 Changed 6 months ago by mkoeppe

  • Cc mjo fbissey added

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 https://trac.sagemath.org/ticket/33083#comment:40 - a related issue on alpine.

comment:7 Changed 6 months ago by mkoeppe

  • Summary changed from cvxopt links wrong M1 directory to Fix suitesparse / cvxopt path configuration for Apple Silicon, Alpine Linux

comment:8 Changed 5 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:9 Changed 2 months ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.