sphinxcontrib-versioning icon indicating copy to clipboard operation
sphinxcontrib-versioning copied to clipboard

Incompatible with Sphinx >= 2.0

Open bdusell opened this issue 5 years ago • 6 comments

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.

bdusell avatar Dec 03 '19 12:12 bdusell

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

z00sts avatar Dec 09 '19 08:12 z00sts

@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?

swalsberger avatar Feb 04 '20 12:02 swalsberger

@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'

z00sts avatar Feb 05 '20 03:02 z00sts

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

swalsberger avatar Feb 05 '20 06:02 swalsberger

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.

jli avatar Dec 02 '20 19:12 jli

@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.

Holzhaus avatar Dec 02 '20 20:12 Holzhaus