Lunderberg commented on a change in pull request #8735:
URL: https://github.com/apache/tvm/pull/8735#discussion_r687871308
##########
File path: docs/conf.py
##########
@@ -30,18 +30,30 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import gc
-import sys
+import importlib.util
import inspect
-import os, subprocess
+import os
+from pathlib import Path
import shlex
+import subprocess
+import sys
+
import sphinx_gallery
+
# 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.
-curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
-sys.path.insert(0, os.path.join(curr_path, "../python/"))
-sys.path.insert(0, os.path.join(curr_path, "../vta/python"))
+curr_path = Path(__file__).expanduser().absolute().parent
+if curr_path.name == "_staging":
+ # Can't use curr_path.parent, because sphinx_gallery requires a relative
path.
+ tvm_path = Path(os.pardir, os.pardir)
+else:
+ tvm_path = Path(os.pardir)
+
+
+sys.path.insert(0, str(tvm_path.joinpath("python")))
Review comment:
Ah, I knew there was a shortcut but I couldn't find it in the
documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]