diff --git a/README.md b/README.md index 2f51ef5..977cc70 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,19 @@ sage: GC.cohomology_basis(4,6) ``` Extensive examples of the use of this software are contained in the author's PhD dissertation: [*The action of Kontsevich's graph complex on Poisson structures and star products: an implementation*](https://doi.org/10.25358/openscience-9274). + +## Installation in a virtual Python environment (no SageMath installation required) + +Create and activate a virtual environment: + + cd /path/to/gcaops-master/ + python3 -m venv venv_gcaops + . venv_gcaops/bin/activate + +Install the package in the virtual environment: + + pip install ".[passagemath]" + +This automatically installs the modularized parts of the Sage library that are +needed by the package. (These modularized distributions are provided by +https://github.com/passagemath.) diff --git a/gcaops/util/directed_graph_sage.py b/gcaops/util/directed_graph_sage.py index cd99eed..b8bc826 100644 --- a/gcaops/util/directed_graph_sage.py +++ b/gcaops/util/directed_graph_sage.py @@ -1,6 +1,9 @@ import subprocess import os -import sage.all # make SageMath work when called from Python +try: + import sage.all # make SageMath work when called from Python +except ImportError: + import sage.all__sagemath_graphs from sage.env import SAGE_NAUTY_BINS_PREFIX from sage.graphs.digraph import DiGraph from sage.graphs.graph import Graph diff --git a/gcaops/util/formality_graph_sage.py b/gcaops/util/formality_graph_sage.py index 5d49d0b..f48833d 100644 --- a/gcaops/util/formality_graph_sage.py +++ b/gcaops/util/formality_graph_sage.py @@ -1,7 +1,10 @@ import itertools import subprocess import os -import sage.all # make SageMath work when called from Python +try: + import sage.all # make SageMath work when called from Python +except ImportError: + import sage.all__sagemath_graphs from sage.env import SAGE_NAUTY_BINS_PREFIX from sage.graphs.digraph import DiGraph from gcaops.graph.formality_graph import FormalityGraph diff --git a/gcaops/util/undirected_graph_sage.py b/gcaops/util/undirected_graph_sage.py index e1bca8f..436af65 100644 --- a/gcaops/util/undirected_graph_sage.py +++ b/gcaops/util/undirected_graph_sage.py @@ -1,6 +1,9 @@ import subprocess import os -import sage.all # make SageMath work when called from Python +try: + import sage.all # make SageMath work when called from Python +except ImportError: + import sage.all__sagemath_graphs from sage.env import SAGE_NAUTY_BINS_PREFIX from sage.graphs.graph import Graph from gcaops.graph.undirected_graph import UndirectedGraph diff --git a/setup.cfg b/setup.cfg index 285de5b..0bf40ac 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,3 +20,12 @@ classifiers = packages = find: python_requires = >= 3 install_requires = + +[options.extras_require] +passagemath = + passagemath-graphs + passagemath-groups + passagemath-modules + passagemath-nauty + passagemath-plot + passagemath-repl diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..1c19a15 --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = passagemath + +[testenv:passagemath] +extras = + passagemath + +commands = + python3 -c "from sage.all__sagemath_categories import QQ; from gcaops.all import *; GC = UndirectedGraphComplex(QQ, implementation='vector', sparse=True); GC.cohomology_basis(4,6)"