Of course, we need tools for testing modularized distributions
of portions of the Sage library.
1. Modularized distributions must be testable separately!
2. But we want to keep integration testing with other portions of Sage too!
Enter "# optional", the doctest annotation that we already use whenever an optional package is needed for a particular test.
This mechanism can now also be used for making a doctest conditional on the presence of a portion of the Sage library. As of https://trac.sagemath.org/ticket/32649
, the available tags are sage.combinat
, and sage.symbolic
. It easy to add more such tags in src/sage/features/sagemath.py
uses this mechanism for sage.tensor (thanks, Eric!). This package is purely algebraic and has no dependency on symbolics. However, there were a small number of doctests that depend on the Symbolic Ring for integration testing. Now ticket #32712 made them conditional on the presence of sage.symbolic
: the tests are marked # optional - sage.symbolic
So how to test that this works?
Sure, we can go into local/..../site-packages and do "rm -rf sage/symbolic" and test that things still work. But that's not a good way of testing.
Instead we use a virtual environment
in which we only install a subset distribution of the Sage library (and its Python dependencies). The distribution sagemath-standard-no-symbolics
, under development in https://trac.sagemath.org/ticket/32601
, omits sage.symbolic, sage.functions, sage.calculus, and other packages/modules that make heavy use of symbolics.
This is where tox comes into play: It is the standard Python tool for creating disposable virtual environments for testing. Per testing instructions in https://trac.sagemath.org/ticket/32601
, after checking out the ticket branch and running "./bootstrap && make build" to update the normal Sage distribution, we can create a separate virtual environment for testing sagemath-standard-no-symbolics.
$ ./sage -sh -c '(cd pkgs/sagemath-standard-no-symbolics && SAGE_NUM_THREADS=16 tox -v -v -v -e py39-sagewheels-nopypi)'
will reuse all the non-Python dependencies previously built, and also reuse the wheels built for the Python packages in the Sage distribution. It does not make any changes to the normal installation of Sage. The virtual environment is created in a subdirectory of pkgs/sagemath-standard-no-symbolics/.tox; the whole .tox directory can be safely deleted at any time.
After the command finishes, we can start the separate subset-Sage in its virtual environment:
or run some tests:
$ pkgs/sagemath-standard-no-symbolics/.tox/py39-sagewheels-nopypi/bin/sage -tp 4 src/sage/graphs/