|
44 | 44 | from string import Template
|
45 | 45 | from textwrap import indent
|
46 | 46 | from time import perf_counter, sleep
|
47 |
| -from typing import Iterable |
| 47 | +from typing import Iterable, Literal |
48 | 48 | from urllib.parse import urljoin
|
49 | 49 |
|
50 | 50 | import jinja2
|
@@ -487,11 +487,16 @@ def parse_args():
|
487 | 487 | parser = ArgumentParser(
|
488 | 488 | description="Runs a build of the Python docs for various branches."
|
489 | 489 | )
|
| 490 | + parser.add_argument( |
| 491 | + "--select-output", |
| 492 | + choices=("no-html", "only-html"), |
| 493 | + help="Choose what outputs to build.", |
| 494 | + ) |
490 | 495 | parser.add_argument(
|
491 | 496 | "-q",
|
492 | 497 | "--quick",
|
493 | 498 | action="store_true",
|
494 |
| - help="Make HTML files only (Makefile rules suffixed with -html).", |
| 499 | + help="Run a quick build (only HTML files).", |
495 | 500 | )
|
496 | 501 | parser.add_argument(
|
497 | 502 | "-b",
|
@@ -589,23 +594,18 @@ class DocBuilder:
|
589 | 594 | cpython_repo: Repository
|
590 | 595 | build_root: Path
|
591 | 596 | www_root: Path
|
| 597 | + select_output: Literal["no-html", "only-html"] | None |
592 | 598 | quick: bool
|
593 | 599 | group: str
|
594 | 600 | log_directory: Path
|
595 | 601 | skip_cache_invalidation: bool
|
596 | 602 | theme: Path
|
597 | 603 |
|
598 | 604 | @property
|
599 |
| - def full_build(self): |
600 |
| - """Tell if a full build is needed. |
601 |
| -
|
602 |
| - A full build is slow; it builds pdf, txt, epub, texinfo, and |
603 |
| - archives everything. |
604 |
| -
|
605 |
| - A partial build only builds HTML and does not archive, it's |
606 |
| - fast. |
607 |
| - """ |
608 |
| - return not self.quick and not self.language.html_only |
| 605 | + def html_only(self): |
| 606 | + return ( |
| 607 | + self.select_output == "only-html" or self.quick or self.language.html_only |
| 608 | + ) |
609 | 609 |
|
610 | 610 | def run(self, http: urllib3.PoolManager) -> bool:
|
611 | 611 | """Build and publish a Python doc, for a language, and a version."""
|
@@ -698,15 +698,13 @@ def build(self):
|
698 | 698 |
|
699 | 699 | if self.version.status == "EOL":
|
700 | 700 | sphinxopts.append("-D html_context.outdated=1")
|
701 |
| - maketarget = ( |
702 |
| - "autobuild-" |
703 |
| - + ( |
704 |
| - "dev" |
705 |
| - if self.version.status in ("in development", "pre-release") |
706 |
| - else "stable" |
707 |
| - ) |
708 |
| - + ("" if self.full_build else "-html") |
709 |
| - ) |
| 701 | + |
| 702 | + if self.version.status in ("in development", "pre-release"): |
| 703 | + maketarget = "autobuild-dev" |
| 704 | + else: |
| 705 | + maketarget = "autobuild-stable" |
| 706 | + if self.html_only: |
| 707 | + maketarget += "-html" |
710 | 708 | logging.info("Running make %s", maketarget)
|
711 | 709 | python = self.venv / "bin" / "python"
|
712 | 710 | sphinxbuild = self.venv / "bin" / "sphinx-build"
|
@@ -815,28 +813,18 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
|
815 | 813 | ";",
|
816 | 814 | ]
|
817 | 815 | )
|
818 |
| - if self.full_build: |
819 |
| - run( |
820 |
| - [ |
821 |
| - "rsync", |
822 |
| - "-a", |
823 |
| - "--delete-delay", |
824 |
| - "--filter", |
825 |
| - "P archives/", |
826 |
| - str(self.checkout / "Doc" / "build" / "html") + "/", |
827 |
| - target, |
828 |
| - ] |
829 |
| - ) |
830 |
| - else: |
831 |
| - run( |
832 |
| - [ |
833 |
| - "rsync", |
834 |
| - "-a", |
835 |
| - str(self.checkout / "Doc" / "build" / "html") + "/", |
836 |
| - target, |
837 |
| - ] |
838 |
| - ) |
839 |
| - if self.full_build: |
| 816 | + run( |
| 817 | + [ |
| 818 | + "rsync", |
| 819 | + "-a", |
| 820 | + "--delete-delay", |
| 821 | + "--filter", |
| 822 | + "P archives/", |
| 823 | + str(self.checkout / "Doc" / "build" / "html") + "/", |
| 824 | + target, |
| 825 | + ] |
| 826 | + ) |
| 827 | + if not self.quick: |
840 | 828 | logging.debug("Copying dist files.")
|
841 | 829 | run(
|
842 | 830 | [
|
@@ -1201,8 +1189,17 @@ def main():
|
1201 | 1189 | args = parse_args()
|
1202 | 1190 | setup_logging(args.log_directory)
|
1203 | 1191 |
|
| 1192 | + if args.select_output is None: |
| 1193 | + build_docs_with_lock(args, "build_docs.lock") |
| 1194 | + elif args.select_output == "no-html": |
| 1195 | + build_docs_with_lock(args, "build_docs_archives.lock") |
| 1196 | + elif args.select_output == "only-html": |
| 1197 | + build_docs_with_lock(args, "build_docs_html.lock") |
| 1198 | + |
| 1199 | + |
| 1200 | +def build_docs_with_lock(args, lockfile_name): |
1204 | 1201 | try:
|
1205 |
| - lock = zc.lockfile.LockFile(HERE / "build_docs.lock") |
| 1202 | + lock = zc.lockfile.LockFile(HERE / lockfile_name) |
1206 | 1203 | except zc.lockfile.LockError:
|
1207 | 1204 | logging.info("Another builder is running... dying...")
|
1208 | 1205 | return EX_FAILURE
|
|
0 commit comments