@@ -463,7 +463,7 @@ def setup_switchers(script_content: bytes, html_root: Path) -> None:
463
463
- Cross-link various versions in a version switcher
464
464
"""
465
465
switchers_path = html_root / "_static" / "switchers.js"
466
- switchers_path .write_text (script_content , encoding = "UTF-8" )
466
+ switchers_path .write_bytes (script_content )
467
467
468
468
for file in html_root .glob ("**/*.html" ):
469
469
depth = len (file .relative_to (html_root ).parts )- 1
@@ -910,20 +910,21 @@ def _checkout_name(select_output: str | None) -> str:
910
910
return "cpython"
911
911
912
912
913
- def main ()-> None :
913
+ def main ()-> int :
914
914
"""Script entry point."""
915
915
args = parse_args ()
916
916
setup_logging (args .log_directory ,args .select_output )
917
917
load_environment_variables ()
918
918
919
919
if args .select_output is None :
920
- build_docs_with_lock (args ,"build_docs.lock" )
921
- elif args .select_output == "no-html" :
922
- build_docs_with_lock (args ,"build_docs_archives.lock" )
923
- elif args .select_output == "only-html" :
924
- build_docs_with_lock (args ,"build_docs_html.lock" )
925
- elif args .select_output == "only-html-en" :
926
- build_docs_with_lock (args ,"build_docs_html_en.lock" )
920
+ return build_docs_with_lock (args ,"build_docs.lock" )
921
+ if args .select_output == "no-html" :
922
+ return build_docs_with_lock (args ,"build_docs_archives.lock" )
923
+ if args .select_output == "only-html" :
924
+ return build_docs_with_lock (args ,"build_docs_html.lock" )
925
+ if args .select_output == "only-html-en" :
926
+ return build_docs_with_lock (args ,"build_docs_html_en.lock" )
927
+ return EX_FAILURE
927
928
928
929
929
930
def parse_args ()-> argparse .Namespace :
@@ -1072,12 +1073,12 @@ def build_docs_with_lock(args: argparse.Namespace, lockfile_name: str) -> int:
1072
1073
return EX_FAILURE
1073
1074
1074
1075
try :
1075
- return EX_OK if build_docs (args )else EX_FAILURE
1076
+ return build_docs (args )
1076
1077
finally :
1077
1078
lock .close ()
1078
1079
1079
1080
1080
- def build_docs (args :argparse .Namespace )-> bool :
1081
+ def build_docs (args :argparse .Namespace )-> int :
1081
1082
"""Build all docs (each language and each version)."""
1082
1083
logging .info ("Full build start." )
1083
1084
start_time = perf_counter ()
@@ -1160,7 +1161,7 @@ def build_docs(args: argparse.Namespace) -> bool:
1160
1161
1161
1162
logging .info ("Full build done (%s)." ,format_seconds (perf_counter ()- start_time ))
1162
1163
1163
- return any_build_failed
1164
+ return EX_FAILURE if any_build_failed else EX_OK
1164
1165
1165
1166
1166
1167
def parse_versions_from_devguide (http :urllib3 .PoolManager )-> Versions :
@@ -1404,4 +1405,4 @@ def purge_surrogate_key(http: urllib3.PoolManager, surrogate_key: str) -> None:
1404
1405
1405
1406
1406
1407
if __name__ == "__main__" :
1407
- sys . exit (main ())
1408
+ raise SystemExit (main ())