executablebooks / sphinx-thebe

A Sphinx extension to convert static code into interactive code cells with Jupyter, Thebe, and Binder.
https://sphinx-thebe.readthedocs.io/en/latest/
MIT License
28 stars 15 forks source link

0.1.2: documentation build fails (module is not ready for sphinx 5.x) #55

Closed kloczek closed 1 year ago

kloczek commented 2 years ago

Describe the bug

As same as in https://github.com/executablebooks/sphinx-book-theme/issues/571 looks like here as well documentation build fails.

First of all currently it is not possible to use straight sphinx-build command to build documentation out of source tree

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

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/registry.py", line 430, in load_extension
    mod = import_module(extname)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'sphinx_thebe'

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 272, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 223, in __init__
    self.setup_extension(extension)
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 380, in setup_extension
    self.registry.load_extension(self, extname)
  File "/usr/lib/python3.8/site-packages/sphinx/registry.py", line 433, in load_extension
    raise ExtensionError(__('Could not import extension %s') % extname,
sphinx.errors.ExtensionError: Could not import extension sphinx_thebe (exception: No module named 'sphinx_thebe')

Extension error:
Could not import extension sphinx_thebe (exception: No module named 'sphinx_thebe')

This can be fixed by patch like below:

--- a/docs/conf.py
+++ b/docs/conf.py
@@ -11,11 +11,10 @@
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
-#
-# import os
-# import sys
-# sys.path.insert(0, os.path.abspath('.'))

+import os
+import sys
+sys.path.insert(0, os.path.abspath(".."))

 # -- Project information -----------------------------------------------------

This patch fixes what is in the comment and that can of fix is suggested in sphinx example copy.py https://www.sphinx-doc.org/en/master/usage/configuration.html#example-of-configuration-file

Than .. on building documentation

+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v5.0.2
WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English).
making output directory... done
myst v0.17.2: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=['colon_fence'], linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', disable_syntax=[], all_links_external=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, highlight_code_blocks=True, number_code_blocks=[], title_to_header=False, heading_anchors=None, heading_slug_func=None, footnote_transition=True, sub_delimiters=('{', '}'), words_per_minute=200)
myst-nb v0.15.0: NbParserConfig(custom_formats={}, metadata_key='mystnb', cell_metadata_key='mystnb', kernel_rgx_aliases={}, execution_mode='auto', execution_cache_path='', execution_excludepatterns=(), execution_timeout=30, execution_in_temp=False, execution_allow_errors=False, execution_raise_on_error=False, execution_show_tb=False, merge_streams=False, render_plugin='default', remove_code_source=False, remove_code_outputs=False, number_source_lines=False, output_stderr='show', render_text_lexer='myst-ansi', render_error_lexer='ipythontb', render_image_options={}, render_figure_options={}, render_markdown_format='commonmark', output_folder='build', append_css=True, metadata_to_fm=False)
Using jupyter-cache at: /home/tkloczko/rpmbuild/BUILD/sphinx-thebe-0.1.2/build/sphinx/.jupyter_cache
building [mo]: targets for 0 po files that are out of date
building [man]: all manpages
updating environment: [new config] 6 added, 0 changed, 0 removed
/home/tkloczko/rpmbuild/BUILD/sphinx-thebe-0.1.2/docs/examples/notebooks.md: Executing notebook using local CWD [mystnb]
/home/tkloczko/rpmbuild/BUILD/sphinx-thebe-0.1.2/docs/examples/notebooks.md: Executed notebook in 2.20 seconds [mystnb]
reading sources... [100%] use
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
writing... sphinxcopybutton.1 { use configure examples/notebooks contribute changelog } failed

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 329, in build
    self.builder.build_update()
  File "/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 285, in build_update
    self.build(['__all__'], to_build)
  File "/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 352, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/lib/python3.8/site-packages/sphinx/util/__init__.py", line 517, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/sphinx/builders/manpage.py", line 98, in write
    docwriter.write(largetree, destination)
  File "/usr/lib/python3.8/site-packages/docutils/writers/__init__.py", line 78, in write
    self.translate()
  File "/usr/lib/python3.8/site-packages/sphinx/writers/manpage.py", line 29, in translate
    visitor = self.builder.create_translator(self.document, self.builder)
  File "/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 122, in create_translator
    return self.app.registry.create_translator(self, *args)
  File "/usr/lib/python3.8/site-packages/sphinx/registry.py", line 347, in create_translator
    setattr(translator, 'visit_' + name, MethodType(visit, translator))
TypeError: first argument must be callable

Exception occurred:
  File "/usr/lib/python3.8/site-packages/sphinx/registry.py", line 347, in create_translator
    setattr(translator, 'visit_' + name, MethodType(visit, translator))
TypeError: first argument must be callable
The full traceback has been saved in /tmp/sphinx-err-3qmvbk_r.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
[tkloczko@devel-g2v SPECS]$ cat /tmp/sphinx-err-3qmvbk_r.log
# Sphinx version: 5.0.2
# Python version: 3.8.13 (CPython)
# Docutils version: 0.17.1 release
# Jinja2 version: 3.1.1
# Last messages:
#   done
#   writing...
#   sphinxcopybutton.1 {
#   use
#   configure
#   examples/notebooks
#   contribute
#   changelog
#   }
#   failed
# Loaded extensions:
#   sphinx.ext.mathjax (5.0.2) from /usr/lib/python3.8/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /usr/lib/python3.8/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /usr/lib/python3.8/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from /usr/lib/python3.8/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /usr/lib/python3.8/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /usr/lib/python3.8/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /usr/lib/python3.8/site-packages/alabaster/__init__.py
#   sphinx_togglebutton (0.3.2) from /usr/lib/python3.8/site-packages/sphinx_togglebutton/__init__.py
#   myst_nb (0.15.0) from /usr/lib/python3.8/site-packages/myst_nb/__init__.py
#   sphinx_copybutton (0.5.0) from /usr/lib/python3.8/site-packages/sphinx_copybutton/__init__.py
#   sphinx_panels (0.6.0) from /usr/lib/python3.8/site-packages/sphinx_panels/__init__.py
#   sphinx_thebe (0.1.2) from /home/tkloczko/rpmbuild/BUILD/sphinx-thebe-0.1.2/sphinx_thebe/__init__.py
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 329, in build
    self.builder.build_update()
  File "/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 285, in build_update
    self.build(['__all__'], to_build)
  File "/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 352, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/lib/python3.8/site-packages/sphinx/util/__init__.py", line 517, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/sphinx/builders/manpage.py", line 98, in write
    docwriter.write(largetree, destination)
  File "/usr/lib/python3.8/site-packages/docutils/writers/__init__.py", line 78, in write
    self.translate()
  File "/usr/lib/python3.8/site-packages/sphinx/writers/manpage.py", line 29, in translate
    visitor = self.builder.create_translator(self.document, self.builder)
  File "/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 122, in create_translator
    return self.app.registry.create_translator(self, *args)
  File "/usr/lib/python3.8/site-packages/sphinx/registry.py", line 347, in create_translator
    setattr(translator, 'visit_' + name, MethodType(visit, translator))
TypeError: first argument must be callable

Reproduce the bug

Run in project root directory sphinx-build -n -T -b man docs build/sphinx/man

List your environment

Package Version


ablog 0.10.26 alabaster 0.7.12 appdirs 1.4.4 asttokens 2.0.5 attrs 22.1.0.dev0 Babel 2.10.2 backcall 0.2.0 beautifulsoup4 4.10.0 Brlapi 0.8.3 build 0.8.0 charset-normalizer 2.1.0 click 8.1.2 codespell 2.1.0 commonmark 0.9.1 cssselect 1.1.0 cycler 0.11.0 debugpy 1.6.2 decorator 5.1.1 distro 1.7.0 docutils 0.17.1 entrypoints 0.4 executing 0.8.3 extended-project 1.2.3 extras 1.0.0 fastjsonschema 2.15.3 feedgen 0.9.0 fixtures 4.0.0 fonttools 4.34.4 gpg 1.17.1-unknown greenlet 1.1.2 html2text 2020.1.16 idna 3.3 imagesize 1.4.1 importlib-metadata 4.12.0 importlib-resources 5.8.0 iniconfig 1.1.1 invoke 1.7.0 ipykernel 6.15.1 ipython 8.4.0 jedi 0.18.1 Jinja2 3.1.1 jsonschema 4.7.2 jupyter-cache 0.5.0 jupyter-client 7.3.4 jupyter-core 4.11.1 kiwisolver 1.4.4 libcomps 0.1.18 louis 3.22.0 lxml 4.9.1 markdown-it-py 2.1.0 MarkupSafe 2.1.1 matplotlib 3.5.2 matplotlib-inline 0.1.3 mdit-py-plugins 0.3.0 mdurl 0.1.1 metaextract 1.0.8 myst-nb 0.15.0 myst-parser 0.17.2 nbclient 0.6.6 nbformat 5.4.0 nest-asyncio 1.5.5 nodeenv 1.7.0 numpy 1.23.1 numpydoc 1.4.0 olefile 0.46 packaging 21.3 parso 0.8.3 pbr 5.8.1 pep517 0.12.0 pep621 0.4.0 pexpect 4.8.0 pickleshare 0.7.5 Pillow 9.2.0 pip 22.0.4 pluggy 1.0.0 prompt-toolkit 3.0.29 psutil 5.9.0 ptyprocess 0.7.0 pure-eval 0.2.2 py 1.11.0 py2pack 0.8.7 Pygments 2.12.0 PyGObject 3.42.1 pyparsing 3.0.9 pypi-search 1.2.1 pyrsistent 0.18.1 pytest 7.1.2 python-dateutil 2.8.2 pytz 2022.1 PyYAML 6.0 pyzmq 23.2.0 requests 2.28.1 rich 12.5.0 rpm 4.17.0 scour 0.38.2 setuptools 63.2.0 simple-project 1.2.3 six 1.16.0 snowballstemmer 2.2.0 soupsieve 2.3.2.post1 Sphinx 5.0.2 sphinx-copybutton 0.5.0 sphinx_design 0.2.0 sphinx-examples 0.0.5 sphinx-panels 0.6.0 sphinx-tabs 3.4.1 sphinx-theme-builder 0.2.0a14 sphinx-togglebutton 0.3.2 sphinxcontrib-applehelp 1.0.2.dev20220714 sphinxcontrib-devhelp 1.0.2.dev20220714 sphinxcontrib-htmlhelp 2.0.0 sphinxcontrib-jsmath 1.0.1.dev20220712 sphinxcontrib-qthelp 1.0.3.dev20220712 sphinxcontrib-serializinghtml 1.1.5 sphinxcontrib-youtube 1.1.0 SQLAlchemy 1.4.39.dev0 stack-data 0.3.0 tabulate 0.8.9 testtools 2.5.0 tomli 2.0.1 tornado 6.1 traitlets 5.3.0 typing_extensions 4.2.0 urllib3 1.26.9 watchdog 2.1.9 wcwidth 0.2.5 wheel 0.37.1 zipp 3.8.1

welcome[bot] commented 2 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

kloczek commented 2 years ago

Looks like this module is not ready for sphinx 5.x https://github.com/executablebooks/sphinx-thebe/blob/aec1ec48a98ceac0acaad4d5ac23e86a6047498b/setup.py#L50

choldgraf commented 1 year ago

We just merged in support for Sphinx 5 and 6 in the following PR, so closing this.