From 7c37746b1162935c957041189a8494c6321ee4ec Mon Sep 17 00:00:00 2001 From: Stephen Moore Date: Mon, 16 Sep 2024 12:06:15 +1000 Subject: [PATCH] Don't rely on PATH to find sphinx-build This change makes it so that we don't rely on the correct `sphinx-build` being on PATH to build the docs. This is useful when the command that runs sphinx-autobuild runs in a virtualenv that isn't the currently activated virtualenv (i.e. via `uv run --extra docs` invocation) --- sphinx_autobuild/build.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sphinx_autobuild/build.py b/sphinx_autobuild/build.py index 2c0adc4..b54d4d4 100644 --- a/sphinx_autobuild/build.py +++ b/sphinx_autobuild/build.py @@ -1,6 +1,7 @@ """Logic for interacting with sphinx-build.""" import subprocess +import sys from sphinx_autobuild.utils import show @@ -28,9 +29,12 @@ def __call__(self, *, rebuild: bool = True): ) raise - show(command=["sphinx-build"] + self.sphinx_args) + show(command=["python", "-m", "sphinx"] + self.sphinx_args) try: - subprocess.run(["sphinx-build"] + self.sphinx_args, check=True) + subprocess.run( + [sys.executable, "-m", "sphinx"] + self.sphinx_args, + check=True, + ) except subprocess.CalledProcessError as e: print(f"Sphinx exited with exit code: {e.returncode}") print(