sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.58k stars 2.12k forks source link

Running `make gettext` fails with `AttributeError` #11976

Closed charlesbvll closed 9 months ago

charlesbvll commented 9 months ago

Describe the bug

When running make gettext the command fails due to nativepath being None in line 39 of sphinx/util/osutil.py. Running make html works without any issue. I have also tested the command on the same sources on an empty docker machine and got the same results. Note that the build/gettext directory is created with a sphinx.pot file inside it (alongside a _static_design_static/ folder and a _video_thumbnail/ folder).

How to Reproduce

To reproduce this you can clone the Flower repo git clone https://github.com/adap/flower, install poetry and run poetry install, and then go to doc/ and run poetry run make gettext (with Pandoc installed on the system).

Environment Information

# Platform:         darwin; (macOS-14.2.1-arm64-arm-64bit)
# Sphinx version:   6.2.1
# Python version:   3.10.13 (CPython)
# Docutils version: 0.19
# Jinja2 version:   3.1.2
# Pygments version: 2.17.2

# Last messages:
#   writing output... [ 95%] tutorial-quickstart-tensorflow
#   writing output... [ 96%] tutorial-quickstart-xgboost
#   writing output... [ 96%] tutorial-series-build-a-strategy-from-scratch-pytorch
#   writing output... [ 97%] tutorial-series-customize-the-client-pytorch
#   writing output... [ 98%] tutorial-series-get-started-with-flower-pytorch
#   writing output... [ 99%] tutorial-series-use-a-federated-learning-strategy-pytorch
#   writing output... [100%] tutorial-series-what-is-federated-learning
#   
#   writing message catalogs... [ 50%] sphinx
#   writing message catalogs... [100%] framework-docs

# Loaded extensions:
#   sphinx.ext.mathjax (6.2.1)
#   alabaster (0.7.13)
#   sphinxcontrib.applehelp (1.0.4)
#   sphinxcontrib.devhelp (1.0.2)
#   sphinxcontrib.htmlhelp (2.0.1)
#   sphinxcontrib.serializinghtml (1.1.10)
#   sphinxcontrib.qthelp (1.0.3)
#   sphinx.ext.autodoc.preserve_defaults (6.2.1)
#   sphinx.ext.autodoc.type_comment (6.2.1)
#   sphinx.ext.autodoc.typehints (6.2.1)
#   sphinx.ext.autodoc (6.2.1)
#   sphinx.ext.napoleon (6.2.1)
#   sphinx.ext.autosummary (6.2.1)
#   sphinx.ext.viewcode (6.2.1)
#   sphinx.ext.graphviz (6.2.1)
#   sphinxarg.ext (0.2.5)
#   myst_parser (1.0.0)
#   sphinx_copybutton (0.5.2)
#   sphinx_design (0.5.0)
#   sphinxcontrib.mermaid (6.2.1)
#   sphinxcontrib.youtube (1.4.1)
#   sphinx_reredirects (unknown version)
#   nbsphinx (0.9.3)

# Traceback:
Traceback (most recent call last):
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/cmd/build.py", line 285, in build_main
    app.build(args.force_all, args.filenames)
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/application.py", line 353, in build
    self.builder.build_update()
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 311, in build_update
    self.build(to_build,
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/builders/gettext.py", line 263, in build
    super().build(docnames, summary, method)
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 381, in build
    self.finish()
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/builders/gettext.py", line 286, in finish
    content = GettextRenderer(outdir=self.outdir).render('message.pot_t', context)
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/builders/gettext.py", line 106, in render
    return super().render(filename, context)
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/util/template.py", line 28, in render
    return self.env.get_template(template_name).render(context)
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/templates/gettext/message.pot_t", line 21, in top-level template code
    #: {{ relpath(source) }}:{{ line }}
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/builders/gettext.py", line 103, in _relpath
    return canon_path(relpath(s, self.outdir))
  File "/Users/main/.pyenv/versions/flower-3.10/lib/python3.10/site-packages/sphinx/util/osutil.py", line 39, in canon_path
    return nativepath.replace(path.sep, SEP)
AttributeError: 'NoneType' object has no attribute 'replace'

Sphinx extensions

No response

Additional context

No response

picnixz commented 9 months ago

Can you try whether the issue persists in 7.2.6? we unfortunately don't do backports...

charlesbvll commented 9 months ago

Updating indeed fixes the issue, there are a few version conflicts, but we should be able to resolve those, thanks!