Ask Your Question

How to make Sage use OpenSSL installed in /opt/local/{bin, lib,include}

asked 2020-12-21 03:04:33 +0100

Mouse gravatar image

updated 2021-03-12 20:54:40 +0100

FrédéricC gravatar image

MacOS Catalina 10.15.7. Seemingly no way to get Sage binary to recognize installed OpenSSL (I'm not taking about the screwed-up version of LibreSSL that MacOS is coming with now).

I have Python3{7,8,9} installed in /opt/local via Macports. OpenSSL-1.1.1i installed the same way (/opt/local). Everything works fine.

How do I get Sage to use the packages already installed, instead of, e.g., downloading its own copy of Python?

Barring that, what do I need to download to build from sources, so it can link with a normal OpenSSL, and maybe use a normal Python?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-12-21 06:26:41 +0100

slelievre gravatar image

updated 2021-03-21 02:43:08 +0100

This situation with OpenSSL is frustrating for you and for many Sage users on macOS and the developers are equally frustrated. Things will hopefully improve dramatically with the release of OpenSSL 3.0 which comes under an Apache license compatible with the GPL, so that Sage will be able to distribute it. Currently OpenSSL 3.0.0alpha9 is out... Progress on this front is tracked on the Sage side at

In the meanwhile, here are some possible ways forward.

The best is if you can fix Sage's Python in place by sticking in the appropriate SSL capability for it using the

That script is currently provided to fix Python 3.7, which will work with Sage 9.0 and 9.1; not yet with 9.2 which is based on Python 3.8.

Otherwise, I would either install Sage via Conda or build it from source, and then in your existing app, rename the sage executable (allowing to restore it later if needed), and put a symbolic link to an SSL-enabled Sage (either installed via Conda or built from source) in its place.

To install Sage on macOS is via Conda, follow this guide:

or make your own mix of that guide and the hints on the

To install from source, get the sources from the

Once you have extracted the source tarball, prepare as follows:

  • place the extracted folder where you want it (Sage stops working if moved after using it, so better put it where you want it before building; if you move Sage afterwards, you need to build it again)

  • open a terminal and change to the extracted Sage folder

Then, if you also have Homebrew, run the following:

source .homebrew-build-env

(There has been a lot of effort to make Sage use as many as possible of Homebrew's packages to save building many components. Not sure to what extent MacPort packages can be used.)

Decide on how many jobs to run in parallel while building, for example to run 1, 4, 8 or 16 jobs in parallel while building, use

MAKE='make -j1'
MAKE='make -j4'
MAKE='make -j8'
MAKE='make -j16'

Then configure:

make configure

Once you have run the configure step, check in the file config.log what it says on what it has decided regarding Python: build its own, use the one from MacPorts, use a different one?

Possibly you can tell it exactly which Python to use, using something like:

./configure --with-python=...

(someone else would have to confirm).

If it looks like it is going to use the Python you want, great.

Otherwise, run configure again enabling openssl.

./configure --enable-openssl

Check in config.log if it detected your existing openssl; otherwise build OpenSSL first to make sure an SSL-enabled Python will be built.

make -s V=0 openssl

Then build the rest of Sage:

make -s V=0

Edit to address original poster's comment after the answer above.

The Sage build system, despite all its quirks, works in a lot of situations, which is no small feat.

Improvements have always been welcome. Along the years, tremendous effort has gone into streamlining the build process, making it more modular, packaging Sage for various distributions.

There was a time when the Sage build system could not handle Fink or MacPorts or Homebrew being around; users had to tweak their PATH or rename their /opt/local or /usr/local while building Sage.

To make life easier, the build system was made to ignore the Fink and MacPorts directories itself. This lives on, as you found out.

Support for using Homebrew packages was added.

It would be nice to allow Sage's build system to use MacPorts in the same way it can use Homebrew. This is tracked at:

Contributions are welcome!

Update (2021-03-21)

There is recent progress on several fronts.

edit flag offensive delete link more


Great reply, thank you!

Unfortunately, I do not run Homebrew, for convenience and security reasons. On the other hand, the difference between finding Homebrew- and Macports-installed packages should be only in where to look for them. Thus, "re-targeting" to Macports (or enabling Macports in addition to Homebrew) should be just the matter of adding more locations to the search functions that look for stuff.

Trying sage -f python3 - it figures that Macports is installed, and asks to make it "invisible" for the build to proceed?!

Then, building pplpy, the stupid thing tries to compile .cpp files with clang instead of clang++, and then complains about C flags that aren't valid for C++.

Mouse gravatar imageMouse ( 2020-12-21 16:58:00 +0100 )edit

Edited answer to link to ticket tracking support for MacPorts. No work has started on that yet. Please contribute if you know how to achieve that!

Bugs are often stupid, sometimes due to an oversight, sometimes for historical reasons, ...

Constructive and informative bug reports are always welcome.

So are code contributions fixing them or documenting workarounds.

What version of Sage are you building? Latest stable? Latest develop?

What version of pplpy is giving trouble?

Do you have Apple's command-line tools only or the full Xcode with its command-line tools?

Try setting environment variables CC=clang CXX=clang++ before building pplpy?

Or can you locate where the bug lies that makes it use clang instead of clang++?

slelievre gravatar imageslelievre ( 2020-12-21 21:04:24 +0100 )edit

What version of Sage are you building?

Latest stable, 9.2.

What version of pplpy is giving trouble?

Whatever's coming with that Sage version. The report says pplpy-0.8.4.

Do you have Apple's command-line tools only or the full Xcode with its command-line tools?

Xcode with it's command-line tools, and CLT installed separately. Both v12.3. CC=clang and CXX=clang++ is already set - that's my env default.

can you locate where the bug lies that makes it use clang instead of clang++?

I wish. :-(

I have log files that might be useful for somebody who understands Sage and pplpy, bot don't know where to send them.

Mouse gravatar imageMouse ( 2020-12-22 04:17:46 +0100 )edit

You could write to the sage-support mailing list or the sage-devel mailing list describing the problem and attaching (or linking to) your config.log.

slelievre gravatar imageslelievre ( 2020-12-22 06:30:52 +0100 )edit

Those lists seem to require joining the group...?

Mouse gravatar imageMouse ( 2020-12-22 13:57:46 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-12-21 03:04:33 +0100

Seen: 557 times

Last updated: Mar 21 '21