@@ -566,7 +566,7 @@ def includes_html(self):
566566 """Does the build we are running include HTML output?"""
567567 return self .select_output != "no-html"
568568
569- def run (self , http : urllib3 .PoolManager ) -> bool | None :
569+ def run (self , http : urllib3 .PoolManager , force_build : bool ) -> bool | None :
570570 """Build and publish a Python doc, for a language, and a version."""
571571 start_time = perf_counter ()
572572 start_timestamp = dt .datetime .now (tz = dt .UTC ).replace (microsecond = 0 )
@@ -578,7 +578,7 @@ def run(self, http: urllib3.PoolManager) -> bool | None:
578578 self .cpython_repo .switch (self .version .branch_or_tag )
579579 if self .language .tag != "en" :
580580 self .clone_translation ()
581- if trigger_reason := self .should_rebuild ():
581+ if trigger_reason := self .should_rebuild (force_build ):
582582 self .build_venv ()
583583 self .build ()
584584 self .copy_build_to_webroot (http )
@@ -834,7 +834,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
834834 "Publishing done (%s)." , format_seconds (perf_counter () - start_time )
835835 )
836836
837- def should_rebuild (self ):
837+ def should_rebuild (self , force : bool ):
838838 state = self .load_state ()
839839 if not state :
840840 logging .info ("Should rebuild: no previous state found." )
@@ -862,6 +862,9 @@ def should_rebuild(self):
862862 cpython_sha ,
863863 )
864864 return "Doc/ has changed"
865+ if force :
866+ logging .info ("Should rebuild: forced." )
867+ return "forced"
865868 logging .info ("Nothing changed, no rebuild needed." )
866869 return False
867870
@@ -985,6 +988,12 @@ def parse_args():
985988 help = "Path where generated files will be copied." ,
986989 default = Path ("/srv/docs.python.org" ),
987990 )
991+ parser .add_argument (
992+ "--force" ,
993+ action = "store_true" ,
994+ help = "Always build the chosen languages and versions, "
995+ "regardless of existing state." ,
996+ )
988997 parser .add_argument (
989998 "--skip-cache-invalidation" ,
990999 help = "Skip Fastly cache invalidation." ,
@@ -1128,7 +1137,7 @@ def build_docs(args: argparse.Namespace) -> bool:
11281137 builder = DocBuilder (
11291138 version , versions , language , languages , cpython_repo , ** vars (args )
11301139 )
1131- built_successfully = builder .run (http )
1140+ built_successfully = builder .run (http , force_build = args . force )
11321141 if built_successfully :
11331142 build_succeeded .add ((version .name , language .tag ))
11341143 elif built_successfully is not None :
0 commit comments