Skip to content

Add --force to always rebuild #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ To manually rebuild a branch, for example 3.11:
ssh docs.nyc1.psf.io
sudo su --shell=/bin/bash docsbuild
screen -DUR # Rejoin screen session if it exists, otherwise create a new one
/srv/docsbuild/venv/bin/python /srv/docsbuild/scripts/build_docs.py --branch 3.11
/srv/docsbuild/venv/bin/python /srv/docsbuild/scripts/build_docs.py --force-build --branch 3.11
```
17 changes: 13 additions & 4 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ 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 | None:
def run(self, http: urllib3.PoolManager, force_build: bool) -> bool | None:
"""Build and publish a Python doc, for a language, and a version."""
start_time = perf_counter()
start_timestamp = dt.datetime.now(tz=dt.UTC).replace(microsecond=0)
Expand All @@ -550,7 +550,7 @@ def run(self, http: urllib3.PoolManager) -> bool | None:
self.cpython_repo.switch(self.version.branch_or_tag)
if self.language.tag != "en":
self.clone_translation()
if trigger_reason := self.should_rebuild():
if trigger_reason := self.should_rebuild(force_build):
self.build_venv()
self.build()
self.copy_build_to_webroot(http)
Expand Down Expand Up @@ -806,7 +806,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
"Publishing done (%s).", format_seconds(perf_counter() - start_time)
)

def should_rebuild(self):
def should_rebuild(self, force_build: bool):
state = self.load_state()
if not state:
logging.info("Should rebuild: no previous state found.")
Expand Down Expand Up @@ -834,6 +834,9 @@ def should_rebuild(self):
cpython_sha,
)
return "Doc/ has changed"
if force_build:
logging.info("Should rebuild: forced.")
return "forced"
logging.info("Nothing changed, no rebuild needed.")
return False

Expand Down Expand Up @@ -956,6 +959,12 @@ def parse_args():
help="Path where generated files will be copied.",
default=Path("/srv/docs.python.org"),
)
parser.add_argument(
"--force-build",
action="store_true",
help="Always build the chosen languages and versions, "
"regardless of existing state.",
)
parser.add_argument(
"--skip-cache-invalidation",
help="Skip Fastly cache invalidation.",
Expand Down Expand Up @@ -1074,7 +1083,7 @@ def build_docs(args: argparse.Namespace) -> bool:
builder = DocBuilder(
version, versions, language, languages, cpython_repo, **vars(args)
)
built_successfully = builder.run(http)
built_successfully = builder.run(http, force_build=args.force_build)
if built_successfully:
build_succeeded.add((version.name, language.tag))
elif built_successfully is not None:
Expand Down