Skip to content

Commit

Permalink
Fix RTD build (#79)
Browse files Browse the repository at this point in the history
* Add custom commands to .readthedocs.yaml

* Correct format

* Remove make commands

* Revert RTD yml

* Modify python path in conf.py

* More explicit path setup

* Make sure pip is installed

* Use RTD dummy for CONDA_PREFIX

* Remove dummy definition from RTD yaml

* Fill CONDA_PREFIX with dummy in conf.py instead
  • Loading branch information
NoraLoose authored Sep 16, 2024
1 parent c83b1a1 commit fc35204
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
Expand All @@ -15,9 +14,13 @@ build:
sphinx:
configuration: docs/conf.py

# Conda environment
conda:
environment: ci/environment.yml

# Python dependencies and install method
python:
install:
- method: pip
path: .

3 changes: 3 additions & 0 deletions ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ dependencies:
- mpich
- xarray
- netCDF4
- pip
# docs
- sphinx
- nbsphinx
- sphinx-book-theme
- sphinxcontrib-bibtex
- myst-parser
- pip:
- readthedocs-sphinx-ext
# for running jupyter notebooks
- ipykernel
22 changes: 22 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

import os
import pathlib
import sys


print("python exec:", sys.executable)
print("sys.path:", sys.path)
root = pathlib.Path(__file__).parent.parent.absolute()
os.environ["PYTHONPATH"] = str(root)
# cstar will look for os.environ["CONDA_PREFIX"] but this is not available on RTD; let's fill it with dummy
os.environ["CONDA_PREFIX"] = str(root)
sys.path.insert(0, str(root))

import cstar # isort:skip


project = "C-Star"
copyright = "2024, [C]Worthy"
author = "C-Star developers"
Expand Down

0 comments on commit fc35204

Please sign in to comment.