Skip to content

Require imghdr for building Python 3.8-3.10 #267

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

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,30 @@
See https://github.com/python/cpython/issues/91483

"""
if self.name == "3.5":
return ["jieba", "blurb", "sphinx==1.8.4", "jinja2<3.1", "docutils<=0.17.1"]
if self.name in {"3.7", "3.6", "2.7"}:
return ["jieba", "blurb", "sphinx==2.3.1", "jinja2<3.1", "docutils<=0.17.1"]

return [
dependencies = [

Check warning on line 178 in build_docs.py

View check run for this annotation

Codecov / codecov/patch

build_docs.py#L178

Added line #L178 was not covered by tests
"jieba", # To improve zh search.
"PyStemmer~=2.2.0", # To improve performance for word stemming.
"-rrequirements.txt",
]
if self.as_tuple() >= (3, 11):
return dependencies
if self.as_tuple() >= (3, 8):

Check warning on line 185 in build_docs.py

View check run for this annotation

Codecov / codecov/patch

build_docs.py#L183-L185

Added lines #L183 - L185 were not covered by tests
# Restore the imghdr module for Python 3.8-3.10.
return dependencies + ["standard-imghdr"]

Check warning on line 187 in build_docs.py

View check run for this annotation

Codecov / codecov/patch

build_docs.py#L187

Added line #L187 was not covered by tests

# Requirements/constraints for Python 3.7 and older, pre-requirements.txt
reqs = ["jieba", "blurb", "jinja2<3.1", "docutils<=0.17.1", "standard-imghdr"]
if self.name in {"3.7", "3.6", "2.7"}:
return reqs + ["sphinx==2.3.1"]
if self.name == "3.5":
return reqs + ["sphinx==1.8.4"]

Check warning on line 194 in build_docs.py

View check run for this annotation

Codecov / codecov/patch

build_docs.py#L190-L194

Added lines #L190 - L194 were not covered by tests

@property
def changefreq(self):
"""Estimate this version change frequency, for the sitemap."""
return {"EOL": "never", "security-fixes": "yearly"}.get(self.status, "daily")

def as_tuple(self):
def as_tuple(self) -> tuple[int, ...]:
"""This version name as tuple, for easy comparisons."""
return version_to_tuple(self.name)

Expand Down Expand Up @@ -386,7 +393,7 @@
self.clone() or self.fetch()


def version_to_tuple(version):
def version_to_tuple(version) -> tuple[int, ...]:
"""Transform a version string to a tuple, for easy comparisons."""
return tuple(int(part) for part in version.split("."))

Expand Down