executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx
https://myst-nb.readthedocs.io
BSD 3-Clause "New" or "Revised" License
211 stars 84 forks source link

Update needed for Sphinx 8.0 #619

Closed WarrenWeckesser closed 2 months ago

WarrenWeckesser commented 3 months ago

Describe the bug

The CI build of the SciPy docs is failing with the recently updated Sphinx 8.0.2. Initially the problem was coming from jupyterlite_sphinx (see https://github.com/jupyterlite/jupyterlite-sphinx/issues/197). A current pull request there fixes the error that occurs in jupyterlite_sphinx, but the build of the SciPy docs fails again in myst_nb code:

[...snip...]
reading sources... [ 96%] tutorial/interpolate/interp_transition_guide
Traceback (most recent call last):
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/cmd/build.py", line 337, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/application.py", line 378, in build
    self.builder.build_update()
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 296, in build_update
    self.build(to_build,
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 317, in build
    updated_docnames = set(self.read())
                           ^^^^^^^^^^^
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 424, in read
    self._read_serial(docnames)
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 476, in _read_serial
    self.read_doc(docname)
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 535, in read_doc
    publisher.publish()
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/docutils/core.py", line 234, in publish
    self.document = self.reader.read(self.source, self.parser,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/io.py", line 106, in read
    self.parse()
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/myst_nb/sphinx_.py", line 85, in parse
    nb_reader = create_nb_reader(document_path, md_config, nb_config, inputstring)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/myst_nb/core/read.py", line 71, in create_nb_reader
    if path.endswith(suffix):
       ^^^^^^^^^^^^^
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/util/_pathlib.py", line 96, in __getattr__
    warnings.warn(_MSG, RemovedInSphinx90Warning, stacklevel=2)
sphinx.deprecation.RemovedInSphinx90Warning: Sphinx 9 will drop support for representing paths as strings. Use "pathlib.Path" or "os.fspath" instead.

Exception occurred:
  File "/home/warren/py3.12.4/lib/python3.12/site-packages/sphinx/util/_pathlib.py", line 96, in __getattr__
    warnings.warn(_MSG, RemovedInSphinx90Warning, stacklevel=2)
sphinx.deprecation.RemovedInSphinx90Warning: Sphinx 9 will drop support for representing paths as strings. Use "pathlib.Path" or "os.fspath" instead.
The full traceback has been saved in /tmp/sphinx-err-1o84nyhg.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!
make: *** [Makefile:114: html-build] Error 2

The error occurs in 'core/read.py' at line 71:

https://github.com/executablebooks/MyST-NB/blob/6ce30cd41fa82543e0f315ac8bbee82669b0cc82/myst_nb/core/read.py#L71

If I follow the example of the jupyterlite_sphinx pull request, and change that line to:

         if path.suffix == suffix:

the build of the SciPy docs completes successfully.

Reproduce the bug

See above.

List your environment

No response

agoose77 commented 3 months ago

Thanks for this report. Will try and get a fix out today (we have been slow to test Sphinx 8).

WarrenWeckesser commented 3 months ago

Thanks @agoose77. For now, we are sticking with Sphinx 7.4.7 in CI, so we're not blocked.

bsipocz commented 3 months ago

I've run into this issue, too for some tutorial CIs.

Naively went ahead and opened the PR as it looked all good locally.

raphaelquast commented 3 months ago

Hey, any updates on this one? Just noticed the warning after updating to sphinx v8...