Installing the Conjecturing package for Sage on MacOS Mojave

2019 November 10

Alas, the instructions for installing the Conjecturing package for Sage posted on Nico Van Cleemput’s Conjecturing website did not work for me right out of the box. So, in hopes of saving others a little time (or misery) here are instructions to perform a local installation of the Conjecturing package for Sage on macOS Mojave, as of 10 November 2019. Only use these if you strike out using Van Cleemput’s instructions.

All usual disclaimers and provisos apply. No warranties or representations. Mileage may vary.

Preliminaries

You will need a working installation of Sage 7.3 or later. As of this writing Sage 8.9 is current. Instructions here have been tested with Sage 8.9.

Before you try installing the Conjecturing package, try running sage -i from a command prompt. This is a preflight check to make sure Sage can build packages before we try building Conjecturing. Rebuilding Sage in this way may take a small eternity. Go do something else. Stretch. Get a cuppa. Read a journal article. Eventually, you should see “Sage build/upgrade complete!” If not, best to fix any issues before trying to build Conjecturing.

How to install

  • Download the latest Conjecturing package (0.12 as of this writing) from Nico Van Cleemput’s Conjecturing website. You’ll have a file conjecturing-0.12.tar.gz. Unzip / untar this file (but keep the original!). You should have a folder called conjecturing-0.12.

  • Open conjecturing-0.12 and read the README.md. There’s a subfolder called spkg. Open that and read the README.md there too! These provide instructions for installation.

  • For the lazy who skipped the previous step. Find the location of your Sage installation. To do this, go to a command prompt and type which sage, e.g.:

    $ which sage
     /Applications/SageMath/sage   <<< FOUND IT!

    So in this example SAGE_ROOT is /Applications/SageMath

  • Copy the directory found in the extracted archive spkg/conjecturing into the directory SAGE_ROOT/build/pkgs, e.g.,

    $ cp conjecturing-0.12/spkg/conjecturing /Applications/SageMath/build/pkgs
  • Copy the entire archive file conjecturing-0.12.tar.gz into SAGE_ROOT/upstream, e.g.,

    $ cp conjecturing-0.12.tar.gz /Applications/SageMath/sage/upstream
  • Run the following command:

    $ sage --package fix-checksum conjecturing
  • Install the package using the following command:

    $ sage -i conjecturing

    The first time I did this, the build failed. Here’s what I did to fix. First, Sage complained that spkg-install should not be flagged as executable. Fix:

    $ chmod -x SAGE_ROOT/build/pkgs/conjecturing/spkg-install

    Second, Sage complained that spkg-install should not have a shebang and that such would be prepended dynamically, so…

    $ vim ./build/pkgs/conjecturing/spkg-install

    …and remove the shebang (that’s the first line that starts with #!), save, and exit. (Obviously if you don’t use vim you can use your favorite text editor (e.g., vi, Atom, Sublime, Emacs, nano, TextMate, whatever).

    Third, Sage complained that malloc.h was not found. (Groan.) If this happens to you, here’s a fix:

    $ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
    installer: Package name is macOS_SDK_headers_for_macOS_10.14
    installer: Upgrading at base path /
    installer: The upgrade was successful.
    

    Why? Because Apple, that’s why. See relevant Apple developer docs. Note: These instructions should work for macOS 10.14 Mojave with Xcode 11.2. Installation of headers took about 5 minutes on my machine. Note: For macOS 10.15 Catalina and Xcode 11.3 (which I strongly discourage as of this writing), this may work instead export CPATH=xcrun --show-sdk-path/usr/include/malloc.

    If you get a complaint from the installer (above), because you don’t have the command line tools installed yet, try running this first:

    $ xcode-select --install 

    For some reason the Sage installer seems not to respect CFLAGS, so I had to export this environment variable before running the Sage installer again:

    $ export C_INCLUDE_PATH=/usr/include/malloc
    $ sage -i conjecturing

    The installer will spew gobbledygook all over your screen and it should (with a little luck) end with: “Sage build/upgrade complete!”

Now you should have the Conjecturing package installed! Yay! To confirm, start Sage, and run this command from a sage prompt:

sage: attach('conjecturing.py')

Conjecturiing

If this doesn’t work for you. Shoot me an email or swing by my office.

Tags: mathematics