From 8764f0526df022fc4e55039d9ac6f6496a9896f5 Mon Sep 17 00:00:00 2001 From: Tom Vo Date: Tue, 5 Dec 2023 09:18:31 -0800 Subject: [PATCH 1/3] Try to mock esmpy --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index c6b06944..4b87d001 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -53,7 +53,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"] +autodoc_mock_imports = ["ESMF", "esmpy"] autodoc_member_order = "bysource" autodoc_default_options = { "members": True, From daf4f9bb1b5b8136d7a3b900e3eb8d5445bc0208 Mon Sep 17 00:00:00 2001 From: Tom Vo Date: Tue, 5 Dec 2023 09:44:32 -0800 Subject: [PATCH 2/3] Add workaround to Read The Docs ESMKFILE env var --- docs/conf.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 4b87d001..a79ff6b3 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 @@ -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, From b00a623e44e9762dbe80b8ed05ad867a094f5c00 Mon Sep 17 00:00:00 2001 From: Tom Vo Date: Tue, 5 Dec 2023 10:00:24 -0800 Subject: [PATCH 3/3] Update docs/conf.py --- docs/conf.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a79ff6b3..01b3142c 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,12 +26,9 @@ # 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. +# causes "ESMFMKFILE" to not be set (required by `esmpy` and `xesmf`). # 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