Add standard-imghdr to requirements #271
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the
standard-imghdrdependency torequirements.txtto make build compatible in newer (>3.13) Python environments while at the same time abiding to thesphinx==5.0.When building the Sphinx documentation with the sphinxdoc/sphinx Docker image (same happens when using the latest Python image) I noticed errors stating that a Python module was missing:
This error does not appear in CI because the Github build pipeline uses an older version of Python:
The module
imghdrhas been deprecated in Python 3.11 and completely removed in Python 3.13 (see Removed Modules and PEP 0594.Reproducing the error
To reproduce the issue:
Navigate to the
docsdirectory and start the Python (or Sphinx) Docker container (for Sphinx replacepython:3withsphinxdoc/sphinx):docker run -it -v `pwd`:/docs --rm python:3 /bin/bashThen, inside the Docker, install the dependencies:
Finally, try building the documentation with (you're already in the
docsdirectory):The result should be the following error
Then, manually try manually installing
standard-imghdr:Try rebuilding now and the error is gone.
Backwards compatibility
To test backwards compatibility, checkout this branch that adds
standard-imghdrto therequirements.txtfile. Then, repeat the process described above with an older version of Python. For instance, use the image for Python 3.8:docker run -it -v `pwd`:/docs --rm python:3.8 /bin/bashAdditional note
This error arises mainly due to defining relatively old versions of both Sphinx (
==5.0) and Python (==3.8). I also tested building the documentation with a newer version of Sphinx and did not notice any build errors. However, I think that addingstandard-imghdrto therequirements.txtis a smaller change and less likely to disrupt anything.