lark-parser / lark

Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
MIT License
4.77k stars 404 forks source link

1.1.5: documentation build fails #1269

Closed kloczek closed 1 year ago

kloczek commented 1 year ago

Looks like it is some issue with building documentation

+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v6.1.3
WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid language code. Falling back to 'en' (English).
making output directory... done
generating gallery...

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/events.py", line 96, in emit
    results.append(listener.handler(self.app, *args))
  File "/usr/lib/python3.8/site-packages/sphinx_gallery/gen_gallery.py", line 518, in generate_gallery_rst
    gallery_conf = parse_config(app)
  File "/usr/lib/python3.8/site-packages/sphinx_gallery/gen_gallery.py", line 135, in parse_config
    gallery_conf = _complete_gallery_conf(
  File "/usr/lib/python3.8/site-packages/sphinx_gallery/gen_gallery.py", line 278, in _complete_gallery_conf
    _import_matplotlib()
  File "/usr/lib/python3.8/site-packages/sphinx_gallery/scrapers.py", line 40, in _import_matplotlib
    matplotlib.use('agg')
AttributeError: module 'matplotlib' has no attribute 'use'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/cmd/build.py", line 279, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 262, in __init__
    self._init_builder()
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 335, in _init_builder
    self.events.emit('builder-inited')
  File "/usr/lib/python3.8/site-packages/sphinx/events.py", line 107, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function generate_gallery_rst at 0x7fcd473aac10> for event 'builder-inited' threw an exception (exception: module 'matplotlib' has no attribute 'use')

Extension error (sphinx_gallery.gen_gallery):
Handler <function generate_gallery_rst at 0x7fcd473aac10> for event 'builder-inited' threw an exception (exception: module 'matplotlib' has no attribute 'use')
erezsh commented 1 year ago

This might happen due to version collisions.

Have you tried running it in a virtualenv or a new Python installation?

kloczek commented 1 year ago

As long as ponf.py contains https://github.com/lark-parser/lark/blob/2de51ceaa542d4be322cba034ee29a2d887bfd19/docs/conf.py#L20-L22 sphinx is able to find lark-parser code and as I'm running build in isolated env where is installed only what is needed by package build it does not need to run in venv as well. Error messages are pointing exactly on code issue and some time ago with older spahinx and numpy documentation build usimg exactly the same procedure was wrking.

Can you try to reporoduce that issue using command which I'm using? 🤔

erezsh commented 1 year ago

What is the command you're using?

Keep in mind the documentation gets built independently by readthedocs on every commit to master.

kloczek commented 1 year ago

/usr/bin/sphinx-build -n -T -b man docs build/sphinx/man

kloczek commented 1 year ago

Keep in mind the documentation gets built independently by readthedocs on every commit to master.

Issue is related o run such build in env with exact versions of modules .. which I forgot to add to this ticket. Here is list of modules installed in build env

Package                       Version
----------------------------- -----------------
alabaster                     0.7.13
Babel                         2.12.1
build                         0.10.0
charset-normalizer            3.1.0
commonmark                    0.9.1
distro                        1.8.0
docutils                      0.19
exceptiongroup                1.0.0
gpg                           1.19.0
idna                          3.4
imagesize                     1.4.1
importlib-metadata            6.3.0
iniconfig                     2.0.0
installer                     0.7.0
Jinja2                        3.1.2
libcomps                      0.1.19
MarkupSafe                    2.1.2
olefile                       0.46
packaging                     23.0
Pillow                        9.5.0
pluggy                        1.0.0
Pygments                      2.15.0
pyproject_hooks               1.0.0
pytest                        7.3.0
python-dateutil               2.8.2
pytz                          2023.2
recommonmark                  0.7.1
requests                      2.28.2
setuptools                    65.6.3
six                           1.16.0
snowballstemmer               2.2.0
Sphinx                        6.1.3
sphinxcontrib-applehelp       1.0.4
sphinxcontrib-devhelp         1.0.2.dev20230405
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1.dev20230405
sphinxcontrib-qthelp          1.0.3.dev20230405
sphinxcontrib-serializinghtml 1.1.5
tomli                         2.0.1
urllib3                       1.26.15
wheel                         0.40.0
zipp                          3.15.0
MegaIng commented 1 year ago

In that list of installed packages, sphinx-gallery isn't listed at all, so that can't be the correct environment. I think that with /usr/bin/sphinx-build instead of sphinx-build you are calling out to the global python installation, not the local environment.

kloczek commented 1 year ago

With installed sphinx-gallery

+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v7.0.1
WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid language code. Falling back to 'en' (English).
making output directory... done

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/events.py", line 96, in emit
    results.append(listener.handler(self.app, *args))
  File "/usr/lib/python3.8/site-packages/sphinx_gallery/gen_gallery.py", line 1173, in fill_gallery_conf_defaults
    new_sphinx_gallery_conf = _fill_gallery_conf_defaults(
  File "/usr/lib/python3.8/site-packages/sphinx_gallery/gen_gallery.py", line 250, in _fill_gallery_conf_defaults
    _import_matplotlib()
  File "/usr/lib/python3.8/site-packages/sphinx_gallery/scrapers.py", line 39, in _import_matplotlib
    matplotlib.use('agg')
AttributeError: module 'matplotlib' has no attribute 'use'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 253, in __init__
    self.events.emit('config-inited', self.config)
  File "/usr/lib/python3.8/site-packages/sphinx/events.py", line 107, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function fill_gallery_conf_defaults at 0x7f2ac83e9820> for event 'config-inited' threw an exception (exception: module 'matplotlib' has no attribute 'use')

Extension error (sphinx_gallery.gen_gallery):
Handler <function fill_gallery_conf_defaults at 0x7f2ac83e9820> for event 'config-inited' threw an exception (exception: module 'matplotlib' has no attribute 'use')`