sphinx-doc / sphinx-autobuild

Watch a Sphinx directory and rebuild the documentation when a change is detected. Also includes a hot-reload web server.
MIT License
523 stars 75 forks source link

Don't depend on sphinx-build on PATH, use sphinx installed on the same interpreter #82

Closed KristianHolsheimer closed 3 years ago

KristianHolsheimer commented 3 years ago

Fixes #58 Fixes #74

Some of my CI/CD pipelines were failing because of this. The problem arises if sphinx-build in the local PATH points to a different python version from the main sys.executable.

coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 76.068% when pulling d824913ba95f32d49c07ab2c8c03640458d5d2ca on KristianHolsheimer:develop into e0f40b6359ca00a48ca5ba903de1e25da27de453 on GaretJax:develop.

KristianHolsheimer commented 3 years ago

@GaretJax The CI pipeline is failing, because pyaml doesn't like python 3.4:

Collecting PyYAML>=3.10 (from -r requirements.txt (line 4)) PyYAML requires Python '>=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4.*' but the running Python is 3.4.8

Would you be able to fix this? And if so, would you be able to let me know when I can rebase?

pradyunsg commented 3 years ago

Thanks for this PR @KristianHolsheimer! I recently got the commit bit here -- #81 -- I'm taking a bit of time modernizing stuff here.

I'll ping you here once all of that is done! ^>^

pradyunsg commented 3 years ago

This looks like a reasonable alternative fix for #58.

pradyunsg commented 3 years ago

Here's the updated patch for this:

diff --git a/pyproject.toml b/pyproject.toml
index faaf9dd..5772558 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -25,6 +25,7 @@ classifiers = [
 home-page = "https://github.com/GaretJax/sphinx_autobuild"
 license = "MIT"
 requires = [
+  "sphinx",
   "watchdog",
   "livereload",
 ]
diff --git a/src/sphinx_autobuild/sphinx.py b/src/sphinx_autobuild/sphinx.py
index edf41ea..d14c5c7 100644
--- a/src/sphinx_autobuild/sphinx.py
+++ b/src/sphinx_autobuild/sphinx.py
@@ -61,7 +61,7 @@ class SphinxBuilder(object):
         sys.stdout.write("-" * (81 - len(pre)))
         sys.stdout.write("\n")

-        args = ["sphinx-build"] + self._args
+        args = [sys.executable, "-m", "sphinx"] + self._args
         if pty:
             master, slave = pty.openpty()
             stdout = os.fdopen(master)

Feel free to add me as a co-author on the commit if you want, by including the following line in the commit message:

Co-authored-by: Pradyun Gedam <pradyunsg@users.noreply.github.com>
KristianHolsheimer commented 3 years ago

@pradyunsg I rebased on develop

pradyunsg commented 3 years ago

Many thanks @KristianHolsheimer! ^>^