Skip to content

Commit

Permalink
Don't rely on PATH to find sphinx-build
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
delfick committed Sep 16, 2024
1 parent 7d199ed commit 4c25da7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sphinx_autobuild/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Logic for interacting with sphinx-build."""

import sys
import subprocess

from sphinx_autobuild.utils import show
Expand Down Expand Up @@ -28,9 +29,12 @@ def __call__(self, *, rebuild: bool = True):
)
raise

show(command=["sphinx-build"] + self.sphinx_args)
show(command=[sys.executable, "-m", "sphinx.cmd.build"] + self.sphinx_args)
try:
subprocess.run(["sphinx-build"] + self.sphinx_args, check=True)
subprocess.run(
[sys.executable, "-m", "sphinx.cmd.build"] + self.sphinx_args,
check=True,
)
except subprocess.CalledProcessError as e:
print(f"Sphinx exited with exit code: {e.returncode}")
print(
Expand Down

0 comments on commit 4c25da7

Please sign in to comment.