PaloAltoNetworks / pan-os-python

The PAN-OS SDK for Python is a package to help interact with Palo Alto Networks devices (including physical and virtualized Next-generation Firewalls and Panorama). The pan-os-python SDK is object oriented and mimics the traditional interaction with the device via the GUI or CLI/API.
https://pan-os-python.readthedocs.io
ISC License
347 stars 172 forks source link

Failing `make docs` - Could not import extension m2r #552

Closed michalbil closed 5 months ago

michalbil commented 8 months ago

Describe the bug

In an environment created according to CONTRIBUTING doc, running make docs fails as below:

$ poetry run make docs
rm -fr docs/_build/
rm -fr docs/_diagrams/
make -C docs html
make[1]: Entering directory '/home/bil/projects/github.com/PaloAltoNetworks/pan-os-python/docs'
sphinx-build -b html -a -v -d _build/doctrees   . _build/html
Running Sphinx v2.4.3
WARNING: while setting up extension sphinx.addnodes: node class 'meta' is already registered, its visitors will be overridden
Original exception:
Traceback (most recent call last):
  File "/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/sphinx/registry.py", line 453, in load_extension
    mod = import_module(extname)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bil/.pyenv/versions/3.11.4/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/m2r.py", line 13, in <module>
    from docutils.core import ErrorString
ImportError: cannot import name 'ErrorString' from 'docutils.core' (/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/docutils/core.py)

Traceback (most recent call last):
  File "/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/sphinx/registry.py", line 453, in load_extension
    mod = import_module(extname)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bil/.pyenv/versions/3.11.4/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/m2r.py", line 13, in <module>
    from docutils.core import ErrorString
ImportError: cannot import name 'ErrorString' from 'docutils.core' (/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/docutils/core.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/sphinx/cmd/build.py", line 272, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/sphinx/application.py", line 245, in __init__
    self.setup_extension(extension)
  File "/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/sphinx/application.py", line 397, in setup_extension
    self.registry.load_extension(self, extname)
  File "/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/sphinx/registry.py", line 456, in load_extension
    raise ExtensionError(__('Could not import extension %s') % extname, err)
sphinx.errors.ExtensionError: Could not import extension m2r (exception: cannot import name 'ErrorString' from 'docutils.core' (/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/docutils/core.py))

Extension error:
Could not import extension m2r (exception: cannot import name 'ErrorString' from 'docutils.core' (/home/bil/.cache/pypoetry/virtualenvs/pan-os-python-UFhtxCNV-py3.11/lib/python3.11/site-packages/docutils/core.py))
make[1]: *** [Makefile:57: html] Error 2
make[1]: Leaving directory '/home/bil/projects/github.com/PaloAltoNetworks/pan-os-python/docs'
make: *** [Makefile:71: docs] Error 2

Expected behavior

Documentation is generated.

Current behavior

Docs generation fails.

Possible solution

Bump m2r to 0.3.1.

Steps to reproduce

  1. poetry install (create new env + install pkgs)
  2. poetry run make docs (generate html docs)

Context

Discovered when testing a small documentation fix.

Your Environment

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 1.12.1 :tada:

The release is available on PyPI and GitHub release

Posted by semantic-release bot