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

Sphinx >7.3.2 imports themes in env, even if not set via html_theme #12299

Closed
lucyleeow opened this issue Apr 17, 2024 · 3 comments
Closed

Sphinx >7.3.2 imports themes in env, even if not set via html_theme #12299

lucyleeow opened this issue Apr 17, 2024 · 3 comments
Labels

Comments

@lucyleeow
Copy link

lucyleeow commented Apr 17, 2024

Describe the bug

Noticed with Sphinx >7.3.2 and pydata-sphinx-theme.

  1. make a clean sphinx setup with sphinx-quickstart
  2. Don't change conf.py at all, default theme is 'alabaster' but pydata-sphinx-theme is installed in env
  3. run make html and I get the following error:
Extension error (pydata_sphinx_theme.pygment):
Handler <function overwrite_pygments_css at 0x7ff2b211eef0> for event 'build-finished' threw an exception (exception: 'pygment_light_style')

full error message from a test failure (from sphinx-gallery/sphinx-gallery#1243):

../../../micromamba/envs/test/lib/python3.11/site-packages/sphinx/events.py:97: in emit
    results.append(listener.handler(self.app, *args))
../../../micromamba/envs/test/lib/python3.11/site-packages/pydata_sphinx_theme/pygment.py:81: in overwrite_pygments_css
    style_name = app.builder.theme.get_options()[style_key]
E   KeyError: 'pygment_light_style'

The above exception was the direct cause of the following exception:
sphinx_gallery/tests/test_gen_gallery.py:493: in test_show_memory_callable
    sphinx_app = sphinx_app_wrapper.build_sphinx_app()
sphinx_gallery/tests/conftest.py:179: in build_sphinx_app
    app.build(*args, **kwargs)
../../../micromamba/envs/test/lib/python3.11/site-packages/sphinx/application.py:353: in build
    self.events.emit('build-finished', None)
../../../micromamba/envs/test/lib/python3.11/site-packages/sphinx/events.py:108: in emit
    raise ExtensionError(
E   sphinx.errors.ExtensionError: Handler <function overwrite_pygments_css at 0x11884d6c0> for event 'build-finished' threw an exception (exception: 'pygment_light_style')

Note pygment.overwrite_pygments_css in pydata-sphinx-theme is connected to 'build-finished' (ref)

Tested and fine with Sphinx 7.3.0 and 7.3.1. If I uninstall pydata-sphinx-theme its also fine.

Could it be related to: 982681b ?

How to Reproduce

  1. make a clean sphinx setup with sphinx-quickstart, include pydata-sphinx-theme in env
  2. run make html

Environment Information

Platform:              linux; (Linux-5.15.0-102-generic-x86_64-with-glibc2.35)
Python version:        3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0])
Python implementation: CPython
Sphinx version:        7.3.2
Docutils version:      0.20.1
Jinja2 version:        3.1.2
Pygments version:      2.17.2

Sphinx extensions

No response

Additional context

No response

@AA-Turner
Copy link
Member

@lucyleeow are you able to test with 3bcc669? I've changed the theme loading to be lazy via a closure rather than eager (as in 7.3.2).

A

@lucyleeow
Copy link
Author

Fixed the problem thanks!

@AA-Turner
Copy link
Member

Sphinx 7.3.7 has been released with fixes.

A

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2024
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