Skip to content

Commit b51916a

Browse files
committed
Use a specific venv for specific sphinx versions.
1 parent 0f1296e commit b51916a

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

build_docs.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@
7070
class Version:
7171
STATUSES = {"EOL", "security-fixes", "stable", "pre-release", "in development"}
7272

73-
def __init__(self, name, branch, status):
73+
def __init__(self, name, branch, status, sphinx_version=None):
7474
if status not in self.STATUSES:
7575
raise ValueError(
7676
"Version status expected to be in {}".format(", ".join(self.STATUSES))
7777
)
7878
self.name = name
7979
self.branch = branch
8080
self.status = status
81+
self.sphinx_version = sphinx_version
8182

8283
@property
8384
def url(self):
@@ -96,7 +97,7 @@ def title(self):
9697
# from the list.
9798
VERSIONS = [
9899
Version("2.7", "2.7", "EOL"),
99-
Version("3.5", "3.5", "security-fixes"),
100+
Version("3.5", "3.5", "security-fixes", sphinx_version="1.8.4"),
100101
Version("3.6", "3.6", "security-fixes"),
101102
Version("3.7", "3.7", "stable"),
102103
Version("3.8", "3.8", "stable"),
@@ -455,6 +456,29 @@ def build_one(
455456
logging.info("Build done for version: %s, language: %s", version.name, language.tag)
456457

457458

459+
def build_venv(build_root, version):
460+
"""Build a venv for the specific version.
461+
This is used to pin old Sphinx versions to old cpython branches.
462+
"""
463+
requirements = ["blurb", "jieba", "python-docs-theme"]
464+
venv_path = os.path.join(build_root, "venv-" + version.sphinx_version)
465+
shell_out(["python3", "-m", "venv", venv_path])
466+
shell_out(
467+
[os.path.join(venv_path, "bin", "python"), "-m", "pip", "install"]
468+
+ requirements
469+
)
470+
shell_out(
471+
[
472+
os.path.join(venv_path, "bin", "python"),
473+
"-m",
474+
"pip",
475+
"install",
476+
"sphinx=={}".format(version.sphinx_version),
477+
]
478+
)
479+
return venv_path
480+
481+
458482
def copy_build_to_webroot(
459483
build_root,
460484
version,
@@ -691,7 +715,7 @@ def main():
691715
if args.www_root:
692716
args.www_root = os.path.abspath(args.www_root)
693717
setup_logging(args.log_directory)
694-
venv = os.path.join(args.build_root, "venv")
718+
default_venv = os.path.join(args.build_root, "venv")
695719
if args.branch:
696720
versions_to_build = [
697721
version
@@ -720,6 +744,10 @@ def main():
720744
scope.set_tag("version", version.name)
721745
scope.set_tag("language", language.tag)
722746
try:
747+
if version.sphinx_version:
748+
venv = build_venv(args.build_root, version)
749+
else:
750+
venv = default_venv
723751
build_one(
724752
version,
725753
args.quick,

0 commit comments

Comments
 (0)