# Disable modules at compile-time or runtime

I'm building SAGE for a humble Raspberry Pi platform (although I'm currently experimenting compilation on a good computer), and given the power of the Pi target I'd like to build and use only a reduced part of SageMath's modules. Anything too far above the level of a high-school student can be cut off, I only plan to use exact calculus and basic analysis tools.

So far I've looked at the installation guide and tried a few things with the configure script, but I found no option to disable modules.

Is there anything planned for this purpose? Or do I have to build SageMath entirely no matter what?

I considered loading only part of the Python modules at runtime, but I figure SageMath will load the others when it sees fit.

Is there a way to disable part of SageMath at runtime?

edit retag close merge delete

Sort by » oldest newest most voted

Since you are compiling Sage on a powerful virtual machine, i would advise not touching the build system, just not to lose your time. If you absoluely want to do that, you can disable the compilation of some standard packages by declaring them optional (for this, you will have to edit the fiie SAGE_ROOT/build/pkgs/<package>/type for each <package>, and run ./configure again), but you will experience a lot of issues (unsatisfied dependencies). Some simple removals are doable (e.g. removing both r and ryp2).

Now, if you speak about runtime, you can remove some automatic imports at startup. The Sage modules are imported in SAGE_ROOT/src/sage/all.py, and it recursively calls the contents of SAGE_ROOT/src/sage/<module>/all.py for each <module>.

By the way, i would be interested to see how you deploy your build infrastructure (i personaly have some hand-made build system that is used to build some specific 32bit patchbots, Sage Dabian Live (and a bunch of Sage binaries a few years ago), and i was thinking whether it is worth cleaning them and why not extend them to build such weird images, hence i would be glad to see your approach).

For your needs, you could also try to just install sympy and run it from a jupyer notebook (probably both distributed from your distro).

more

Thanks! I'll start by giving the package type option a try. Currently I made a subset of packages optional and made sure that all packages depending on them were also optional. However, they are still built (typically ppl which is mentioned in no dependencies file). Did I miss something in the build system? Is there any way to know why Sage decides to build them? I checked the logs but found nothing of interest.

( 2018-10-11 21:17:56 +0200 )edit

Regarding ppl, you could have a look at SAGE_ROOT/build/make/deps too.

( 2018-10-12 01:20:44 +0200 )edit

Oh, you're right! I had missed the deps file for SageLib. Now I see how monolithic it is. ^^ I'll try the runtime method now, thanks again for your help!

( 2018-10-13 11:47:03 +0200 )edit

Making Sage more modular is on the roadmap and will make what you ask easier in the future, but it's not there yet. Besides removing R and RPy2 as @tmonteil suggests, I don't see any easy targets.

Below is a list (edited 2018-10-25) of more lightweight software in case SageMath takes too much space for your needs.

In the same spirit as the suggestion by @tmonteil to consider using

consider also

or, as suggested by @Loveless,

or the recently revived:

• Python-FLINT (Python bindings for FLINT and Arb), by Fredrik Johansson, who in the announcement of the latest revival, explains that

The goal is to have a Python wrapper for Flint and Arb that is just a standalone and lightweight Python module, no multi-gigabyte Sage installation required. Also, the user doesn't have to construct parent rings, so the interface is more convenient for quick calculations.

more

These alternatives sound good indeed! I may note use the Jupyter notebook (I need desktop programs), but SymPy is definitely a good choice. I also have Giac in mind.

( 2018-10-13 11:49:46 +0200 )edit

Yes, Giac is also an excellent idea.

( 2018-10-17 12:07:14 +0200 )edit