@@ -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