@@ -927,30 +927,7 @@ def main():
927
927
"""Script entry point."""
928
928
args = parse_args ()
929
929
setup_logging (args .log_directory , args .select_output )
930
-
931
- ENV_CONF_FILE = None
932
- _user_config_path = user_config_path ("docsbuild-scripts" )
933
- _site_config_path = site_config_path ("docsbuild-scripts" )
934
- if _user_config_path .is_file ():
935
- ENV_CONF_FILE = _user_config_path
936
- elif _site_config_path .is_file ():
937
- ENV_CONF_FILE = _site_config_path
938
-
939
- if ENV_CONF_FILE :
940
- logging .info (f"Reading environment variables from { ENV_CONF_FILE } " )
941
- if ENV_CONF_FILE == _site_config_path :
942
- logging .info (f"You can override settings in { _user_config_path } " )
943
- elif _site_config_path .is_file ():
944
- logging .info (f"Overriding { _site_config_path } " )
945
- with open (ENV_CONF_FILE , "r" ) as f :
946
- for key , value in tomlkit .parse (f .read ()).get ("env" , {}).items ():
947
- logging .debug (f"Setting { key } in environment" )
948
- os .environ [key ] = value
949
- else :
950
- logging .info (
951
- "No environment variables configured. "
952
- f"Configure in { _site_config_path } or { _user_config_path } "
953
- )
930
+ load_environment_variables ()
954
931
955
932
if args .select_output is None :
956
933
build_docs_with_lock (args , "build_docs.lock" )
@@ -1067,6 +1044,31 @@ def setup_logging(log_directory: Path, select_output: str | None):
1067
1044
logging .getLogger ().setLevel (logging .DEBUG )
1068
1045
1069
1046
1047
+ def load_environment_variables () -> None :
1048
+ _user_config_path = user_config_path ("docsbuild-scripts" )
1049
+ _site_config_path = site_config_path ("docsbuild-scripts" )
1050
+ if _user_config_path .is_file ():
1051
+ ENV_CONF_FILE = _user_config_path
1052
+ elif _site_config_path .is_file ():
1053
+ ENV_CONF_FILE = _site_config_path
1054
+ else :
1055
+ logging .info (
1056
+ "No environment variables configured. "
1057
+ f"Configure in { _site_config_path } or { _user_config_path } ."
1058
+ )
1059
+ return
1060
+
1061
+ logging .info (f"Reading environment variables from { ENV_CONF_FILE } ." )
1062
+ if ENV_CONF_FILE == _site_config_path :
1063
+ logging .info (f"You can override settings in { _user_config_path } ." )
1064
+ elif _site_config_path .is_file ():
1065
+ logging .info (f"Overriding { _site_config_path } ." )
1066
+ with open (ENV_CONF_FILE , "r" ) as f :
1067
+ for key , value in tomlkit .parse (f .read ()).get ("env" , {}).items ():
1068
+ logging .debug (f"Setting { key } in environment." )
1069
+ os .environ [key ] = value
1070
+
1071
+
1070
1072
def build_docs_with_lock (args : argparse .Namespace , lockfile_name : str ) -> int :
1071
1073
try :
1072
1074
lock = zc .lockfile .LockFile (HERE / lockfile_name )
0 commit comments