fabpot / sphinx-php

My Sphinx Extensions
MIT License
171 stars 37 forks source link

"Cannot import name lazy_gettext" since v2.0.0 … how to upgrade? #46

Closed greg0ire closed 4 years ago

greg0ire commented 4 years ago

We have failing builds over at Sonata: https://github.com/sonata-project/SonataUserBundle/pull/1187#issuecomment-650512342

It seems that since v2.0.0, this error occurs:

Extension error: Could not import extension sensio.sphinx.configurationblock (exception: cannot import name 'lazy_gettext' from 'sphinx.locale' (/opt/hostedtoolcache/Python/3.7.7/x64/lib/python3.7/site-packages/sphinx/locale/init.py))

How to fix this? Should we import extra things, maybe?

It seems to have to do with this file: https://github.com/fabpot/sphinx-php/blob/910374e0fa056104548e3cc50509ec90c13747e0/sensio/sphinx/__init__.py#L9

The build where it failed: https://github.com/sonata-project/SonataUserBundle/runs/813537832

Our requirements file: https://github.com/sonata-project/SonataUserBundle/blob/4.x/docs/requirements.txt

wouterj commented 4 years ago

@greg0ire symfony.com has updated the Sphinx version to 1.8.5 (From 1.3.x), the Sphinx PHP extension now requires v1.8.5.

greg0ire commented 4 years ago

@wouterj your comment allows me to reproduce the failure locally, like so:

cat docs/requirements.txt
Sphinx>=1.8.5
git+https://github.com/fabpot/sphinx-php.git
sphinx_rtd_theme

$ pip install --requirement docs/requirements.txt --user
Collecting git+https://github.com/fabpot/sphinx-php.git (from -r docs/requirements.txt (line 2))
  Cloning https://github.com/fabpot/sphinx-php.git to /tmp/pip-req-build-rtgpe3k6
  Running command git clone -q https://github.com/fabpot/sphinx-php.git /tmp/pip-req-build-rtgpe3k6
Requirement already satisfied (use --upgrade to upgrade): sphinx-php==1.0 from git+https://github.com/fabpot/sphinx-php.git in /home/greg/.local/lib/python3.8/site-packages (from -r docs/requirements.txt (line 2))
Collecting Sphinx>=1.8.5
  Downloading https://files.pythonhosted.org/packages/fc/3c/d356f63e2d90c72bcb634fd924d563548e97e5e66c0bef3b931f9285837b/Sphinx-3.1.1-py3-none-any.whl (2.9MB)
     |████████████████████████████████| 2.9MB 1.8MB/s 
Requirement already satisfied: sphinx_rtd_theme in /home/greg/.local/lib/python3.8/site-packages (from -r docs/requirements.txt (line 3)) (0.4.3)
Requirement already satisfied: sphinxcontrib-devhelp in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.0.2)
Requirement already satisfied: requests>=2.5.0 in /usr/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (2.22.0)
Requirement already satisfied: packaging in /usr/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (20.1)
Requirement already satisfied: Jinja2>=2.3 in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (2.11.2)
Requirement already satisfied: sphinxcontrib-jsmath in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.0.1)
Requirement already satisfied: sphinxcontrib-serializinghtml in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.1.4)
Requirement already satisfied: docutils>=0.12 in /usr/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (0.15.2)
Requirement already satisfied: alabaster<0.8,>=0.7 in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (0.7.12)
Requirement already satisfied: Pygments>=2.0 in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (2.6.1)
Requirement already satisfied: sphinxcontrib-htmlhelp in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.0.3)
Requirement already satisfied: babel>=1.3 in /usr/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (2.8.0)
Requirement already satisfied: snowballstemmer>=1.1 in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (2.0.0)
Requirement already satisfied: imagesize in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.2.0)
Requirement already satisfied: sphinxcontrib-qthelp in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.0.3)
Requirement already satisfied: sphinxcontrib-applehelp in /home/greg/.local/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.0.2)
Requirement already satisfied: setuptools in /usr/lib/python3.8/site-packages (from Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (41.6.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python3.8/site-packages (from requests>=2.5.0->Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/lib/python3.8/site-packages (from requests>=2.5.0->Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib/python3.8/site-packages (from requests>=2.5.0->Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.25.7)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/lib/python3.8/site-packages (from packaging->Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (2.4.7)
Requirement already satisfied: six in /usr/lib/python3.8/site-packages (from packaging->Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.14.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib64/python3.8/site-packages (from Jinja2>=2.3->Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (1.1.1)
Requirement already satisfied: pytz>=2015.7 in /usr/lib/python3.8/site-packages (from babel>=1.3->Sphinx>=1.8.5->-r docs/requirements.txt (line 1)) (2020.1)
Installing collected packages: Sphinx
  Found existing installation: Sphinx 1.3.6
    Uninstalling Sphinx-1.3.6:
      Successfully uninstalled Sphinx-1.3.6
  WARNING: The scripts sphinx-apidoc, sphinx-autogen, sphinx-build and sphinx-quickstart are installed in '/home/greg/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed Sphinx-3.1.1
╭─~/dev/SonataUserBundle on fix-doc-build ✔ (fork/fix-doc-build +3 -2)
╰$ make docs
cd docs && sphinx-build -W -b html -d _build/doctrees . _build/html
Traceback (most recent call last):
  File "/usr/bin/sphinx-build", line 7, in <module>
    from sphinx import main
ImportError: cannot import name 'main' from 'sphinx' (/home/greg/.local/lib/python3.8/site-packages/sphinx/__init__.py)
make: *** [Makefile:66: docs] Error 1
╭─~/dev/SonataUserBundle on fix-doc-build ✔ (fork/fix-doc-build +3 -2)
╰$ export PATH=/home/greg/.local/bin:$PATH                                         
╭─~/dev/SonataUserBundle on fix-doc-build ✔ (fork/fix-doc-build +3 -2)
╰$ make docs
cd docs && sphinx-build -W -b html -d _build/doctrees . _build/html
Running Sphinx v3.1.1

Extension error:
Could not import extension sensio.sphinx.configurationblock (exception: cannot import name 'lazy_gettext' from 'sphinx.locale' (/home/greg/.local/lib/python3.8/site-packages/sphinx/locale/__init__.py))
make: *** [Makefile:66: docs] Error 2
wouterj commented 4 years ago
Running Sphinx v3.1.1

You should replace Sphinx>=1.8.5 with Sphinx==1.8.5. You need exactly 1.8.5. This is still a quite old Sphinx version, but at least it's a lot newer. (updating Sphinx on symfony.com is close to a traumatic experience, as a lot of docs are rendered using it - all (IIRC even 1.x) versions of the Symfony docs, the bundle docs, the Fast Track book, etc).

greg0ire commented 4 years ago

That seems to work, at least locally, I'll push a new commit :)

greg0ire commented 4 years ago

It works in the CI too… should this be documented in the README maybe, or somewhere else?