Skip to content

Commit 10e20e4

Browse files
authoredApr 11, 2025··
Require imghdr for building Python 3.8-3.10 (#267)
1 parent bd0e222 commit 10e20e4

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed
 

‎build_docs.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -196,23 +196,30 @@ def requirements(self):
196196
See https://github.com/python/cpython/issues/91483
197197
198198
"""
199-
if self.name == "3.5":
200-
return ["jieba", "blurb", "sphinx==1.8.4", "jinja2<3.1", "docutils<=0.17.1"]
201-
if self.name in {"3.7", "3.6", "2.7"}:
202-
return ["jieba", "blurb", "sphinx==2.3.1", "jinja2<3.1", "docutils<=0.17.1"]
203-
204-
return [
199+
dependencies = [
205200
"jieba", # To improve zh search.
206201
"PyStemmer~=2.2.0", # To improve performance for word stemming.
207202
"-rrequirements.txt",
208203
]
204+
if self.as_tuple() >= (3, 11):
205+
return dependencies
206+
if self.as_tuple() >= (3, 8):
207+
# Restore the imghdr module for Python 3.8-3.10.
208+
return dependencies + ["standard-imghdr"]
209+
210+
# Requirements/constraints for Python 3.7 and older, pre-requirements.txt
211+
reqs = ["jieba", "blurb", "jinja2<3.1", "docutils<=0.17.1", "standard-imghdr"]
212+
if self.name in {"3.7", "3.6", "2.7"}:
213+
return reqs + ["sphinx==2.3.1"]
214+
if self.name == "3.5":
215+
return reqs + ["sphinx==1.8.4"]
209216

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

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

@@ -407,7 +414,7 @@ def update(self):
407414
self.clone() or self.fetch()
408415

409416

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

0 commit comments

Comments
 (0)
Please sign in to comment.