Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After porting to pyproject.toml, rst.linker fails with error in Sphinx #17

Closed
jaraco opened this issue Apr 17, 2024 · 8 comments
Closed

Comments

@jaraco
Copy link
Owner

jaraco commented Apr 17, 2024

In https://github.com/jaraco/tempora/actions/runs/8714844379/job/23905742259, the docs build is failing and it implicates rst.linker. Passing -v to the sphinx build provides more context:

docs: commands[0] /Users/jaraco/code/jaraco/tempora/docs> python -m sphinx -W --keep-going . /Users/jaraco/code/jaraco/tempora/build/html -v
Running Sphinx v7.3.3
loading pickled environment... done

Traceback (most recent call last):
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/sphinx/events.py", line 97, in emit
    results.append(listener.handler(self.app, *args))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/rst/linker.py", line 211, in make_links
    replacer = Replacer.from_definition(defn, config_dict(app.config))
                                              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/rst/linker.py", line 203, in config_dict
    return dict((key, getattr(config, key)) for key in config.values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/rst/linker.py", line 203, in <genexpr>
    return dict((key, getattr(config, key)) for key in config.values)
                      ^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/sphinx/config.py", line 412, in __getattr__
    return default(self)
           ^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/sphinx/builders/latex/__init__.py", line 517, in default_latex_documents
    author = texescape.escape(config.author, config.latex_engine)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/sphinx/util/texescape.py", line 110, in escape
    return s.translate(_tex_escape_map)
           ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'translate'

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

Traceback (most recent call last):
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/sphinx/cmd/build.py", line 332, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/sphinx/application.py", line 268, in __init__
    self._init_builder()
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/sphinx/application.py", line 339, in _init_builder
    self.events.emit('builder-inited')
  File "/Users/jaraco/code/jaraco/tempora/.tox/docs/lib/python3.12/site-packages/sphinx/events.py", line 108, in emit
    raise ExtensionError(
sphinx.errors.ExtensionError: Handler <function make_links at 0x104fa7ba0> for event 'builder-inited' threw an exception (exception: 'NoneType' object has no attribute 'translate')

Extension error (rst.linker):
Handler <function make_links at 0x104fa7ba0> for event 'builder-inited' threw an exception (exception: 'NoneType' object has no attribute 'translate')
docs: exit 2 (1.84 seconds) /Users/jaraco/code/jaraco/tempora/docs> python -m sphinx -W --keep-going . /Users/jaraco/code/jaraco/tempora/build/html -v pid=77376
  docs: FAIL code 2 (2.84=setup[1.01]+cmd[1.84] seconds)
  evaluation failed :( (2.88 seconds)
@jaraco
Copy link
Owner Author

jaraco commented Apr 17, 2024

The key that's causing the issue is latex_documents.

@jaraco
Copy link
Owner Author

jaraco commented Apr 17, 2024

Creating an empty setup.cfg doesn't help.

@jaraco
Copy link
Owner Author

jaraco commented Apr 17, 2024

Creating a setup.cfg with this content fixes the issue:

[metadata]
name = tempora
author = Jason R. Coombs
url = https://github.com/jaraco/tempora

Removing one of those keys but leaving others produces different obscure errors, suggesting the issue might actually be in jaraco.packaging.

@jaraco
Copy link
Owner Author

jaraco commented Apr 17, 2024

Indeed, removing jaraco.packaging and the things that rely on it also bypasses the issue, so the issue must be there.

@jaraco jaraco transferred this issue from jaraco/rst.linker Apr 17, 2024
@jaraco
Copy link
Owner Author

jaraco commented Apr 17, 2024

It seems that app.config.package_url and app.config.author (and copyright) are getting set to None.

@jaraco
Copy link
Owner Author

jaraco commented Apr 17, 2024

Aha. So switching from setup.cfg to pyproject.toml has changed the metadata.

 tempora 822773b @ pip-run build -- -c "from build import util; print(util.project_wheel_metadata('.'))" | head
Metadata-Version: 2.1
Name: tempora
Version: 5.5.2.dev11+g822773b
Summary: Objects and routines pertaining to date and time (tempora)
Home-page: https://github.com/jaraco/tempora
Author: Jason R. Coombs
Author-email: [email protected]
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
 tempora 822773b @ git checkout main
Previous HEAD position was 822773b Merge https://github.com/jaraco/skeleton
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
 tempora main @ pip-run build -- -c "from build import util; print(util.project_wheel_metadata('.'))" | head
Metadata-Version: 2.1
Name: tempora
Version: 5.5.2.dev12+ge2e8ef9
Summary: Objects and routines pertaining to date and time (tempora)
Author-email: "Jason R. Coombs" <[email protected]>
Project-URL: Homepage, https://github.com/jaraco/tempora
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3

@jaraco
Copy link
Owner Author

jaraco commented Apr 17, 2024

Man, core metadata is a mess. There's no obvious place to find the author's name nor the project URL. If I want to get a URL suitable for setting "package_url", I can't, because every URL is keyed on free-text that any package author could supply (or not).

@jaraco
Copy link
Owner Author

jaraco commented Apr 17, 2024

Half of the problem is described at pypa/packaging-problems#606. It hints that Setuptools might auto-convert some URLs, but that's apparently not the case.

The work in python/cpython#108580 would help here to have some re-usable ways to parse author/maintainer fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant