sphinx-contrib / sphinxcontrib-versioning

Sphinx extension that allows building versioned docs for self-hosting.
https://sphinxcontrib-versioning.readthedocs.io/en/latest/
MIT License
125 stars 81 forks source link

Incompatible with Sphinx >= 2.0 #77

Open bdusell opened 4 years ago

bdusell commented 4 years ago

When running Sphinx 2.2.1, sphinx-versioning fails with

$ poetry run sphinx-versioning build docs docs/_build/html
Traceback (most recent call last):
  File "/app/.venv/bin/sphinx-versioning", line 7, in <module>
    from sphinxcontrib.versioning.__main__ import cli
  File "/app/.venv/lib/python3.7/site-packages/sphinxcontrib/versioning/__main__.py", line 13, in <module>
    from sphinxcontrib.versioning.routines import build_all, gather_git_info, pre_build, read_local_conf
  File "/app/.venv/lib/python3.7/site-packages/sphinxcontrib/versioning/routines.py", line 11, in <module>
    from sphinxcontrib.versioning.sphinx_ import build, read_config
  File "/app/.venv/lib/python3.7/site-packages/sphinxcontrib/versioning/sphinx_.py", line 9, in <module>
    from sphinx import application, build_main, locale
ImportError: cannot import name 'build_main' from 'sphinx' (/app/.venv/lib/python3.7/site-packages/sphinx/__init__.py)

It looks like build_main was deprecated in 2.0: https://www.sphinx-doc.org/en/master/extdev/deprecated.html

The alternative listed is to use sphinx.cmd.build.build_main().

I cannot downgrade due to another Sphinx plugin.

z00sts commented 4 years ago

workaround is here https://github.com/sphinx-contrib/sphinxcontrib-versioning/pull/78

swalsberger commented 4 years ago

@z00sts sorry I dont understand the workarround

for me it was ok, working with sphinx 1.7.7 sphinxcontrib-versioning 2.2.1

but now there is a new Problem with python 2 and sphinx < 1.8.5

VersionConflict: (Sphinx 1.7.7 (venv2/lib/site-packages), Requirement.parse('sphinx<2.0,>=1.8.5; python_version < "3.0"'))

is there a version of sphinx >=1.8.5 < 2.0 which is compatible with sphinxcontrib-versioning?

z00sts commented 4 years ago

@swalsberger I think there are few more issues with spinix >= 1.7+. I was fixing ImportError during getting help message:

Package                       Version                                                  
----------------------------- ----------
...
Sphinx                        2.2.2      
sphinxcontrib-applehelp       1.0.1      
sphinxcontrib-devhelp         1.0.1      
sphinxcontrib-htmlhelp        1.0.2      
sphinxcontrib-jsmath          1.0.1      
sphinxcontrib-qthelp          1.0.2      
sphinxcontrib-serializinghtml 1.1.3      
sphinxcontrib-versioning      2.2.1      
...
$ venv/bin/sphinx-versioning --help
Traceback (most recent call last):
  File "venv/bin/sphinx-versioning", line 11, in <module>
    load_entry_point('sphinxcontrib-versioning', 'console_scripts', 'sphinx-versioning')()
  File ".../sphinxcontrib-versioning/venv/lib/python3.7/site-packages/setuptools-40.8.0-py3.7.egg/pkg_resources/__init__.py", line 489, in load_entry_point
  File ".../sphinxcontrib-versioning/venv/lib/python3.7/site-packages/setuptools-40.8.0-py3.7.egg/pkg_resources/__init__.py", line 2793, in load_entry_point
  File ".../sphinxcontrib-versioning/venv/lib/python3.7/site-packages/setuptools-40.8.0-py3.7.egg/pkg_resources/__init__.py", line 2411, in load
  File ".../sphinxcontrib-versioning/venv/lib/python3.7/site-packages/setuptools-40.8.0-py3.7.egg/pkg_resources/__init__.py", line 2417, in resolve
  File ".../sphinxcontrib-versioning/sphinxcontrib/versioning/__main__.py", line 13, in <module>
    from sphinxcontrib.versioning.routines import build_all, gather_git_info, pre_build, read_local_conf
  File ".../sphinxcontrib-versioning/sphinxcontrib/versioning/routines.py", line 11, in <module>
    from sphinxcontrib.versioning.sphinx_ import build, read_config
  File ".../sphinxcontrib-versioning/sphinxcontrib/versioning/sphinx_.py", line 9, in <module>
    from sphinx import application, build_main, locale
ImportError: cannot import name 'build_main' from 'sphinx'
swalsberger commented 4 years ago

Ok, wie found the Problem sphinxcontrib-images >= 9.0 makes the trouble on python 2.x

now we have these versions sphinx==1.7.7 sphinxcontrib-versioning==2.2.1 sphinxcontrib-images==0.8.0 sphinxcontrib-websupport==1.1.2

jli commented 3 years ago

FYI, sphinx-multiversion is an alternative project (found here).

I just worked on a PR to switch to SMV from SCV: https://github.com/gro-intelligence/api-client/pull/292 It was straightforward, except that I needed to replicate the behavior of sphinx-versioning push via a shell script. (There are docs on how do to this, but the results are a little different and I didn't want to break any existing links, so needed to resort to a shell script.)

In terms of project health, it doesn't seem particularly active/responsive (looks like just @Holzhaus maintaining it, a number of open issues and PRs), so there is a risk there. But the code looks pretty clean/straightforward.

Holzhaus commented 3 years ago

@jli I originally started sphinx-multiversion because I needed a versioning extension for the Mixxx manual and I couldn't get sphinxcontrib-versioning to work. When I tried to fix the issues, I found the code to be a mess, so I wrote another one from scratch.

As the extension already satisfies my use-case, I consider the extension more or less finished. I try to look into open issues from time to time, but most of them are caused by other third party extensions that I don't use, so I'd appreciate PRs. And in case I ever get run over by a bus or choose to become a Pokemon trainer, you can still fork it - I think the code should be pretty easy to understand.