@@ -566,7 +566,7 @@ def includes_html(self):
566
566
"""Does the build we are running include HTML output?"""
567
567
return self .select_output != "no-html"
568
568
569
- def run (self , http : urllib3 .PoolManager ) -> bool | None :
569
+ def run (self , http : urllib3 .PoolManager , force_build : bool ) -> bool | None :
570
570
"""Build and publish a Python doc, for a language, and a version."""
571
571
start_time = perf_counter ()
572
572
start_timestamp = dt .datetime .now (tz = dt .UTC ).replace (microsecond = 0 )
@@ -578,7 +578,7 @@ def run(self, http: urllib3.PoolManager) -> bool | None:
578
578
self .cpython_repo .switch (self .version .branch_or_tag )
579
579
if self .language .tag != "en" :
580
580
self .clone_translation ()
581
- if trigger_reason := self .should_rebuild ():
581
+ if trigger_reason := self .should_rebuild (force_build ):
582
582
self .build_venv ()
583
583
self .build ()
584
584
self .copy_build_to_webroot (http )
@@ -834,7 +834,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
834
834
"Publishing done (%s)." , format_seconds (perf_counter () - start_time )
835
835
)
836
836
837
- def should_rebuild (self ):
837
+ def should_rebuild (self , force : bool ):
838
838
state = self .load_state ()
839
839
if not state :
840
840
logging .info ("Should rebuild: no previous state found." )
@@ -862,6 +862,9 @@ def should_rebuild(self):
862
862
cpython_sha ,
863
863
)
864
864
return "Doc/ has changed"
865
+ if force :
866
+ logging .info ("Should rebuild: forced." )
867
+ return "forced"
865
868
logging .info ("Nothing changed, no rebuild needed." )
866
869
return False
867
870
@@ -985,6 +988,12 @@ def parse_args():
985
988
help = "Path where generated files will be copied." ,
986
989
default = Path ("/srv/docs.python.org" ),
987
990
)
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
+ )
988
997
parser .add_argument (
989
998
"--skip-cache-invalidation" ,
990
999
help = "Skip Fastly cache invalidation." ,
@@ -1128,7 +1137,7 @@ def build_docs(args: argparse.Namespace) -> bool:
1128
1137
builder = DocBuilder (
1129
1138
version , versions , language , languages , cpython_repo , ** vars (args )
1130
1139
)
1131
- built_successfully = builder .run (http )
1140
+ built_successfully = builder .run (http , force_build = args . force )
1132
1141
if built_successfully :
1133
1142
build_succeeded .add ((version .name , language .tag ))
1134
1143
elif built_successfully is not None :
0 commit comments