From a6efb8dcd65aad0e497f4b607509657dfa0f8534 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Dec 2024 20:53:05 -0800 Subject: [PATCH 1/4] Fall back from 'import sage.all' to 'import sage.all__sagemath_graphs' --- gcaops/util/directed_graph_sage.py | 5 ++++- gcaops/util/formality_graph_sage.py | 5 ++++- gcaops/util/undirected_graph_sage.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) 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 From b8d69627f6dea10708f7d00e490043e39dbe4d6b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Dec 2024 20:53:41 -0800 Subject: [PATCH 2/4] setup.cfg: Define extra 'passagemath' --- setup.cfg | 9 +++++++++ 1 file changed, 9 insertions(+) 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 From 9cbe49c3c258b260f8619da4b30ba5c16c7cb6a2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Dec 2024 20:53:58 -0800 Subject: [PATCH 3/4] tox.ini: New --- tox.ini | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tox.ini 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)" From 258bb16e67ca60682f7f3e85d7c5c2b99dab700e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 30 Dec 2024 20:57:54 -0800 Subject: [PATCH 4/4] README.md: Document use with passagemath distributions --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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.)