Skip to content

Commit

Permalink
Add workaround to Read The Docs ESMKFILE env var
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Dec 5, 2023
1 parent 8764f05 commit daf4f9b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@
#
import os
import sys
from pathlib import Path
from typing import Dict

import sphinx_autosummary_accessors

# A workaround that sets the "ESMFMKFILE" env variable for the Read The Docs
# build to work. Read The Docs does not activate the conda environment which
# causes "ESMFMKFILE" to not be set.
# Source: https://github.com/conda-forge/esmf-feedstock/issues/91
if os.environ.get("READTHEDOCS") and "ESMFMKFILE" not in os.environ:
# RTD doesn't activate the env, and esmpy depends on a env var set there
# We assume the `os` package is in {ENV}/lib/pythonX.X/os.py
# See conda-forge/esmf-feedstock#91 and readthedocs/readthedocs.org#4067
os.environ["ESMFMKFILE"] = str(Path(os.__file__).parent.parent / "esmf.mk")

sys.path.insert(0, os.path.abspath("..")) # noqa: I001, I003
import xcdat # noqa: I001, E402

Expand Down Expand Up @@ -53,7 +64,7 @@
# with xesmf.
# Related issue: https://github.com/readthedocs/readthedocs.org/issues/5512
# Solution: https://docs.readthedocs.io/en/stable/faq.html#why-do-i-get-import-errors-from-libraries-depending-on-c-modules
autodoc_mock_imports = ["ESMF", "esmpy"]
autodoc_mock_imports = ["ESMF"]
autodoc_member_order = "bysource"
autodoc_default_options = {
"members": True,
Expand Down

0 comments on commit daf4f9b

Please sign in to comment.