@@ -538,7 +538,7 @@ def includes_html(self):
538
538
"""Does the build we are running include HTML output?"""
539
539
return self .select_output != "no-html"
540
540
541
- def run (self , http : urllib3 .PoolManager ) -> bool | None :
541
+ def run (self , http : urllib3 .PoolManager , force_build : bool ) -> bool | None :
542
542
"""Build and publish a Python doc, for a language, and a version."""
543
543
start_time = perf_counter ()
544
544
start_timestamp = dt .datetime .now (tz = dt .UTC ).replace (microsecond = 0 )
@@ -550,7 +550,7 @@ def run(self, http: urllib3.PoolManager) -> bool | None:
550
550
self .cpython_repo .switch (self .version .branch_or_tag )
551
551
if self .language .tag != "en" :
552
552
self .clone_translation ()
553
- if trigger_reason := self .should_rebuild ():
553
+ if trigger_reason := self .should_rebuild (force_build ):
554
554
self .build_venv ()
555
555
self .build ()
556
556
self .copy_build_to_webroot (http )
@@ -806,7 +806,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
806
806
"Publishing done (%s)." , format_seconds (perf_counter () - start_time )
807
807
)
808
808
809
- def should_rebuild (self ):
809
+ def should_rebuild (self , force_build : bool ):
810
810
state = self .load_state ()
811
811
if not state :
812
812
logging .info ("Should rebuild: no previous state found." )
@@ -834,6 +834,9 @@ def should_rebuild(self):
834
834
cpython_sha ,
835
835
)
836
836
return "Doc/ has changed"
837
+ if force_build :
838
+ logging .info ("Should rebuild: forced." )
839
+ return "forced"
837
840
logging .info ("Nothing changed, no rebuild needed." )
838
841
return False
839
842
@@ -956,6 +959,12 @@ def parse_args():
956
959
help = "Path where generated files will be copied." ,
957
960
default = Path ("/srv/docs.python.org" ),
958
961
)
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
+ )
959
968
parser .add_argument (
960
969
"--skip-cache-invalidation" ,
961
970
help = "Skip Fastly cache invalidation." ,
@@ -1074,7 +1083,7 @@ def build_docs(args: argparse.Namespace) -> bool:
1074
1083
builder = DocBuilder (
1075
1084
version , versions , language , languages , cpython_repo , ** vars (args )
1076
1085
)
1077
- built_successfully = builder .run (http )
1086
+ built_successfully = builder .run (http , force_build = args . force_build )
1078
1087
if built_successfully :
1079
1088
build_succeeded .add ((version .name , language .tag ))
1080
1089
elif built_successfully is not None :
0 commit comments