Skip to content

Commit 98535e8

Browse files
committed
Handles the case where the documentation should be built from a JSBSim module installed with pip.
If `cmake` is called but the module `_jsbsim` is not built, then Sphinx complains because the build directory contains an incomplete `jsbsim` module. This commit works around that situation by allowing Sphinx to use a version of JSBSim that has been globally installed (with `pip` for instance) rather than the half-baked version that may reside in `build/tests`. The purpose of this commit is to allow building the Python docs with a JSBSim module that has been installed by `pip`. This saves an additional complete build of the Python module when releasing JSBSim with our CI/CD workflow in GitHub.
1 parent 24c3517 commit 98535e8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

doc/python/sphinx/conf.py.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ import sys
1616

1717
sys.path.insert(0, '${CMAKE_BINARY_DIR}/tests')
1818

19+
try:
20+
import jsbsim._jsbsim
21+
except ModuleNotFoundError:
22+
# If the JSBSim module cannot be loaded from the `tests` folder then
23+
# restore `sys.path` to its inital value and use the globally installed
24+
# JSBSim module, if there is one.
25+
sys.path = sys.path[1:]
26+
1927
# -- Project information -----------------------------------------------------
2028

2129
project = u'JSBSim'

0 commit comments

Comments
 (0)