SageMath Package Template
A lightweight template that shows how to structure a SageMath package and ship a couple of runnable demos.
Quick start
- Install the package in editable mode with
sage -pip install -e . - Run the elliptic curve demo:
sage -python elliptic_curve_demo.py
Just shortcuts
just prepare– create the Sage-aware virtualenv and install the package editablejust run– execute the elliptic curve demo inside that virtualenvjust test– run the unit tests with Sage's Pythonjust pytest– run the unit tests through pytest to get pytest-style output and plugins
Running tests
Use Sage's Python so Sage-specific imports resolve correctly when you run the bundled unittest suite. The tests ship as unittest.TestCase classes, so you can call either driver:
sage -python -m unittest discover -s tests -t .
# or, for pytest reporting
sage -python -m pytest
Project layout
demo_package/– minimal package source codeelliptic_curve_demo.py– Python entry point using SageMathtests/– example unittest-based tests
Feel free to copy this template, rename the package, and extend the demos for your own SageMath projects.
Languages
Python
64.4%
Just
35.6%