Skip to content

Commit 9cf8b58

Browse files
committed
Add --force-build to always rebuild
1 parent 2113fd7 commit 9cf8b58

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ To manually rebuild a branch, for example 3.11:
7171
ssh docs.nyc1.psf.io
7272
sudo su --shell=/bin/bash docsbuild
7373
screen -DUR # Rejoin screen session if it exists, otherwise create a new one
74-
/srv/docsbuild/venv/bin/python /srv/docsbuild/scripts/build_docs.py --branch 3.11
74+
/srv/docsbuild/venv/bin/python /srv/docsbuild/scripts/build_docs.py --force-build --branch 3.11
7575
```

build_docs.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def includes_html(self):
538538
"""Does the build we are running include HTML output?"""
539539
return self.select_output != "no-html"
540540

541-
def run(self, http: urllib3.PoolManager) -> bool | None:
541+
def run(self, http: urllib3.PoolManager, force_build: bool) -> bool | None:
542542
"""Build and publish a Python doc, for a language, and a version."""
543543
start_time = perf_counter()
544544
start_timestamp = dt.datetime.now(tz=dt.UTC).replace(microsecond=0)
@@ -550,7 +550,7 @@ def run(self, http: urllib3.PoolManager) -> bool | None:
550550
self.cpython_repo.switch(self.version.branch_or_tag)
551551
if self.language.tag != "en":
552552
self.clone_translation()
553-
if trigger_reason := self.should_rebuild():
553+
if trigger_reason := self.should_rebuild(force_build):
554554
self.build_venv()
555555
self.build()
556556
self.copy_build_to_webroot(http)
@@ -806,7 +806,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
806806
"Publishing done (%s).", format_seconds(perf_counter() - start_time)
807807
)
808808

809-
def should_rebuild(self):
809+
def should_rebuild(self, force_build: bool):
810810
state = self.load_state()
811811
if not state:
812812
logging.info("Should rebuild: no previous state found.")
@@ -834,6 +834,9 @@ def should_rebuild(self):
834834
cpython_sha,
835835
)
836836
return "Doc/ has changed"
837+
if force_build:
838+
logging.info("Should rebuild: forced.")
839+
return "forced"
837840
logging.info("Nothing changed, no rebuild needed.")
838841
return False
839842

@@ -956,6 +959,12 @@ def parse_args():
956959
help="Path where generated files will be copied.",
957960
default=Path("/srv/docs.python.org"),
958961
)
962+
parser.add_argument(
963+
"--force-build",
964+
action="store_true",
965+
help="Always build the chosen languages and versions, "
966+
"regardless of existing state.",
967+
)
959968
parser.add_argument(
960969
"--skip-cache-invalidation",
961970
help="Skip Fastly cache invalidation.",
@@ -1074,7 +1083,7 @@ def build_docs(args: argparse.Namespace) -> bool:
10741083
builder = DocBuilder(
10751084
version, versions, language, languages, cpython_repo, **vars(args)
10761085
)
1077-
built_successfully = builder.run(http)
1086+
built_successfully = builder.run(http, force_build=args.force_build)
10781087
if built_successfully:
10791088
build_succeeded.add((version.name, language.tag))
10801089
elif built_successfully is not None:

0 commit comments

Comments
 (0)