From 42c8937a8d419ae31c3b34828e841d49e08c8c9f Mon Sep 17 00:00:00 2001 From: yashksaini-coder Date: Mon, 1 Sep 2025 02:53:53 +0530 Subject: [PATCH] build(app): Add fallback to os.path.join + newsfragment 886 --- docs/conf.py | 15 +++++++++------ newsfragments/886.bugfix.rst | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 newsfragments/886.bugfix.rst diff --git a/docs/conf.py b/docs/conf.py index 64618359..6f7be709 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,20 +16,23 @@ # sys.path.insert(0, os.path.abspath('.')) import doctest -import os import sys from unittest.mock import MagicMock try: import tomllib -except ModuleNotFoundError: +except ImportError: # For Python < 3.11 - import tomli as tomllib # type: ignore (In case of >3.11 Pyrefly doesnt find tomli , which is right but a false flag) + import tomli as tomllib # type: ignore # Path to pyproject.toml (assuming conf.py is in a 'docs' subdirectory) -from libp2p.utils.paths import get_project_root, join_paths - -pyproject_path = join_paths(get_project_root(), "pyproject.toml") +try: + from libp2p.utils.paths import get_project_root, join_paths + pyproject_path = join_paths(get_project_root(), "pyproject.toml") +except ImportError: + # Fallback for documentation builds where libp2p is not available + import os + pyproject_path = os.path.join(os.path.dirname(__file__), "..", "pyproject.toml") with open(pyproject_path, "rb") as f: pyproject_data = tomllib.load(f) diff --git a/newsfragments/886.bugfix.rst b/newsfragments/886.bugfix.rst new file mode 100644 index 00000000..add7c4ab --- /dev/null +++ b/newsfragments/886.bugfix.rst @@ -0,0 +1,2 @@ +Fixed cross-platform path handling by replacing hardcoded OS-specific +paths with standardized utilities in core modules and examples. \ No newline at end of file