From 7d48edb2f212005647c5767b57597973d4d0b209 Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 1 Mar 2024 17:14:58 -0500 Subject: [PATCH] Updated the shgrav.py package so that it can be activated during documentation building --- .readthedocs.yaml | 1 - swiftest/shgrav.py | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 275cc0938..ccbef0287 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -20,7 +20,6 @@ build: jobs: pre_build: - ford fortran_docs.md - - pip install pyshtools - DOC_BUILD=1 pip install . python: install: diff --git a/swiftest/shgrav.py b/swiftest/shgrav.py index 6664b3941..07019c04b 100644 --- a/swiftest/shgrav.py +++ b/swiftest/shgrav.py @@ -14,13 +14,20 @@ # from .constants import GC +import os -try: - import pyshtools as pysh +PYSHTOOLS_AVAILABLE = False + +if 'READTHEDOCS' in os.environ: + # Assume pyshtools is available when building on ReadTheDocs PYSHTOOLS_AVAILABLE = True -except ModuleNotFoundError: - PYSHTOOLS_AVAILABLE = False - print("pyshtools is not installed. Some features will be unavailable.") +else: + try: + import pyshtools as pysh + PYSHTOOLS_AVAILABLE = True + except ModuleNotFoundError: + print("pyshtools is not installed. Some features will be unavailable.") + if PYSHTOOLS_AVAILABLE: