Skip to content

Commit

Permalink
Only run HTML-specific tasks in builds that output HTML (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner authored Oct 1, 2024
1 parent 992d2df commit caa4a29
Showing 1 changed file with 60 additions and 52 deletions.
112 changes: 60 additions & 52 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import logging.handlers
from functools import total_ordering
from os import readlink
import platform
import re
import shlex
import shutil
Expand Down Expand Up @@ -630,6 +629,11 @@ def html_only(self):
self.select_output == "only-html" or self.quick or self.language.html_only
)

@property
def includes_html(self):
"""Does the build we are running include HTML output?"""
return self.select_output != "no-html"

def run(self, http: urllib3.PoolManager) -> bool:
"""Build and publish a Python doc, for a language, and a version."""
start_time = perf_counter()
Expand Down Expand Up @@ -737,20 +741,18 @@ def build(self):
python = self.venv / "bin" / "python"
sphinxbuild = self.venv / "bin" / "sphinx-build"
blurb = self.venv / "bin" / "blurb"
# Disable CPython switchers, we handle them now:

def is_mac():
return platform.system() == "Darwin"

run(
["sed", "-i"]
+ ([""] if is_mac() else [])
+ ["s/ *-A switchers=1//", self.checkout / "Doc" / "Makefile"]
)
self.version.setup_indexsidebar(
self.versions,
self.checkout / "Doc" / "tools" / "templates" / "indexsidebar.html",
)
if self.includes_html:
# Disable CPython switchers, we handle them now:
run(
["sed", "-i"]
+ ([""] if sys.platform == "darwin" else [])
+ ["s/ *-A switchers=1//", self.checkout / "Doc" / "Makefile"]
)
self.version.setup_indexsidebar(
self.versions,
self.checkout / "Doc" / "tools" / "templates" / "indexsidebar.html",
)
run_with_logging(
[
"make",
Expand All @@ -767,9 +769,10 @@ def is_mac():
)
run(["mkdir", "-p", self.log_directory])
run(["chgrp", "-R", self.group, self.log_directory])
setup_switchers(
self.versions, self.languages, self.checkout / "Doc" / "build" / "html"
)
if self.includes_html:
setup_switchers(
self.versions, self.languages, self.checkout / "Doc" / "build" / "html"
)
logging.info("Build done (%s).", format_seconds(perf_counter() - start_time))

def build_venv(self):
Expand Down Expand Up @@ -817,42 +820,47 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
except subprocess.CalledProcessError as err:
logging.warning("Can't change group of %s: %s", target, str(err))

changed = changed_files(self.checkout / "Doc" / "build" / "html", target)
logging.info("Copying HTML files to %s", target)
run(
[
"chown",
"-R",
":" + self.group,
self.checkout / "Doc" / "build" / "html/",
]
)
run(["chmod", "-R", "o+r", self.checkout / "Doc" / "build" / "html"])
run(
[
"find",
self.checkout / "Doc" / "build" / "html",
"-type",
"d",
"-exec",
"chmod",
"o+x",
"{}",
";",
]
)
run(
[
"rsync",
"-a",
"--delete-delay",
"--filter",
"P archives/",
str(self.checkout / "Doc" / "build" / "html") + "/",
target,
]
)
changed = []
if self.includes_html:
# Copy built HTML files to webroot (default /srv/docs.python.org)
changed = changed_files(self.checkout / "Doc" / "build" / "html", target)
logging.info("Copying HTML files to %s", target)
run(
[
"chown",
"-R",
":" + self.group,
self.checkout / "Doc" / "build" / "html/",
]
)
run(["chmod", "-R", "o+r", self.checkout / "Doc" / "build" / "html"])
run(
[
"find",
self.checkout / "Doc" / "build" / "html",
"-type",
"d",
"-exec",
"chmod",
"o+x",
"{}",
";",
]
)
run(
[
"rsync",
"-a",
"--delete-delay",
"--filter",
"P archives/",
str(self.checkout / "Doc" / "build" / "html") + "/",
target,
]
)

if not self.quick:
# Copy archive files to /archives/
logging.debug("Copying dist files.")
run(
[
Expand Down

0 comments on commit caa4a29

Please sign in to comment.