diff --git a/docs/_ext/import_projects.py b/docs/_ext/import_projects.py index da551ae374..7cd5319921 100644 --- a/docs/_ext/import_projects.py +++ b/docs/_ext/import_projects.py @@ -1,5 +1,4 @@ import inspect -import os import re import shutil import subprocess @@ -83,27 +82,23 @@ def parse(self): def update_sys_path_for_flytekit(import_project_config: ImportProjectsConfig): + flytekit_dir = Path(import_project_config.flytekit_api_dir).resolve(strict=True) + flytekit_src_dir = flytekit_dir / "flytekit" + plugins_dir = flytekit_dir / "plugins" + # create flytekit/_version.py file manually - with open( - f"{import_project_config.flytekit_api_dir}/flytekit/_version.py", "w" - ) as f: + with (flytekit_src_dir / "_version.py").open("w") as f: f.write(f'__version__ = "dev"') # add flytekit to python path - flytekit_dir = os.path.abspath(import_project_config.flytekit_api_dir) - flytekit_src_dir = os.path.abspath(os.path.join(flytekit_dir, "flytekit")) - plugins_dir = os.path.abspath(os.path.join(flytekit_dir, "plugins")) - - sys.path.insert(0, flytekit_src_dir) - sys.path.insert(0, flytekit_dir) + sys.path.insert(0, str(flytekit_src_dir)) + sys.path.insert(0, str(flytekit_dir)) # add plugins to python path - for possible_plugin_dir in os.listdir(plugins_dir): - dir_path = os.path.abspath((os.path.join(plugins_dir, possible_plugin_dir))) - plugin_path = os.path.abspath(os.path.join(dir_path, "flytekitplugins")) - if os.path.isdir(dir_path) and os.path.exists(plugin_path): - sys.path.insert(0, dir_path) - + for possible_plugin_dir in plugins_dir.iterdir(): + plugin_path = possible_plugin_dir / "flytekitplugins" + if possible_plugin_dir.is_dir() and plugin_path.exists(): + sys.path.insert(0, str(possible_plugin_dir)) def update_html_context(project: Project, tag: str, commit: str, config: Config): tag_url = "#" if tag == "dev" else f"{project.source}/releases/tag/{tag}" diff --git a/docs/conf.py b/docs/conf.py index 00382fa77a..67baf0d907 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,9 +10,10 @@ # 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. +# documentation root, use pathlib.Path.resolve(strict=True) to make it absolute, like shown here. import os +from pathlib import Path import logging import sys @@ -21,8 +22,8 @@ from sphinx.util import logging as sphinx_logging -sys.path.insert(0, os.path.abspath("../")) -sys.path.append(os.path.abspath("./_ext")) +sys.path.insert(0, str(Path("../").resolve(strict=True))) +sys.path.append(str(Path("./_ext").resolve(strict=True))) sphinx.application.ExtensionError = sphinx.errors.ExtensionError diff --git a/flyteidl/conf.py b/flyteidl/conf.py index 1aa29d6025..f74cb992cf 100644 --- a/flyteidl/conf.py +++ b/flyteidl/conf.py @@ -10,7 +10,7 @@ # 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. +# documentation root, use pathlib.Path.resolve(strict=True) to make it absolute, like shown here. # import os import re