Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import sphinxcontrib.serializinghtml fails with circular import woes #6245

Closed
craigcitro opened this issue Apr 2, 2019 · 4 comments
Closed
Labels

Comments

@craigcitro
Copy link

Describe the bug
There seems to be a circular import problem when trying to import sphinxcontrib.serializinghtml.

To Reproduce
Steps to reproduce the behavior:

$ docker run -it --rm --entrypoint bash python:3.7

# Install sphinx & sphinxcontrib-serializinghtml
root@5a4dc3112f09:/# python3 -m pip install sphinx==2.0.0 sphinxcontrib-serializinghtml==1.1.1
...
Successfully installed Jinja2-2.10 MarkupSafe-1.1.1 Pygments-2.3.1 alabaster-0.7.12 babel-2.6.0 certifi-2019.3.9 chardet-3.0.4 docutils-0.14 idna-2.8 imagesize-1.1.0 packaging-19.0 pyparsing-2.3.1 pytz-2018.9 requests-2.21.0 six-1.12.0 snowballstemmer-1.2.1 sphinx-2.0.0 sphinxcontrib-applehelp-1.0.1 sphinxcontrib-devhelp-1.0.1 sphinxcontrib-htmlhelp-1.0.1 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.2 sphinxcontrib-serializinghtml-1.1.1 urllib3-1.24.1

# Attempt to import, fails
root@5a4dc3112f09:/# python3
Python 3.7.3 (default, Mar 27 2019, 23:40:30)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sphinxcontrib.serializinghtml
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/sphinxcontrib/serializinghtml/__init__.py", line 15, in <module>
    from sphinx.builders.html import BuildInfo, StandaloneHTMLBuilder
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/html.py", line 1237, in <module>
    from sphinxcontrib.serializinghtml import (  # NOQA
ImportError: cannot import name 'LAST_BUILD_FILENAME' from 'sphinxcontrib.serializinghtml' (/usr/local/lib/python3.7/site-packages/sphinxcontrib/serializinghtml/__init__.py)
# Import sphinx.builders.html first, things work
>>> import sphinx.builders.html
>>> import sphinxcontrib.serializinghtml
>>>

Expected behavior
No other imports should be required before sphinxcontrib.serializinghtml.

Environment info

  • OS:
    root@5a4dc3112f09:/# uname -a
    Linux 5a4dc3112f09 4.19.20-1rodete1-amd64 Global citations #1 SMP Debian 4.19.20-1rodete1 (2019-02-12 > 2018) x86_64 GNU/Linux

  • Python version: [e.g. 3.7.1]
    root@5a4dc3112f09:/# python3 -V
    Python 3.7.3

  • Sphinx version: [e.g. 1.8.2]

  • Sphinx extensions: [e.g. sphinx.ext.autodoc, recommonmark]
    root@5a4dc3112f09:/# python3 -m pip list | grep -i sphinx
    Sphinx 2.0.0
    sphinxcontrib-applehelp 1.0.1
    sphinxcontrib-devhelp 1.0.1
    sphinxcontrib-htmlhelp 1.0.1
    sphinxcontrib-jsmath 1.0.1
    sphinxcontrib-qthelp 1.0.2
    sphinxcontrib-serializinghtml 1.1.1

tk0miya added a commit to tk0miya/sphinx that referenced this issue Apr 4, 2019
tk0miya added a commit to tk0miya/sphinx that referenced this issue Apr 4, 2019
tk0miya added a commit that referenced this issue Apr 4, 2019
Fix #6245: circular import error on importing SerializingHTMLBuilder
@tk0miya
Copy link
Member

tk0miya commented Apr 4, 2019

Fixed by #6249 and sphinx-doc/sphinxcontrib-serializinghtml#1 (No.1!!)
Thank you for reporting :-)

@tk0miya tk0miya closed this as completed Apr 4, 2019
@craigcitro
Copy link
Author

Actually, it looks like I'm still hitting the same problem -- the new code you've added isn't used until after the failing import.

Notebook with repro: https://colab.research.google.com/drive/1PmL2l3f3BwAhwxmaEeM52XxE1fqksiML

@progval
Copy link
Contributor

progval commented Jul 1, 2019

Same as @craigcitro, I can't run Sphinx at all because the circular import still exists:

@tk0miya
Copy link
Member

tk0miya commented Jul 6, 2019

@progval Could you file a new issue please? I'll check it later.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants