diff --git a/src/icmtoolchain/fetch.py b/src/icmtoolchain/fetch.py index e35ad39..d457e31 100644 --- a/src/icmtoolchain/fetch.py +++ b/src/icmtoolchain/fetch.py @@ -7,7 +7,6 @@ from typing import IO, Callable, Optional from urllib.error import URLError from urllib.response import addinfourl -from . import GLOBALS from .shell import pretty_print_failure, pretty_print_success, warn from .utils import ensure_file, name_to_identifier @@ -101,6 +100,7 @@ def create_download_request(url: str, data: Optional[bytes] = None, /, placehold content_size, responce = retrieve_fetch_request(url, data, timeout=timeout, seconds_between_requests=seconds_between_requests, attempts=attempts) def fetch(output_path: Optional[str] = None, /, progress_handler: Optional[Callable[[int, int], None]] = None): if not output_path: + from . import GLOBALS temporary_directory = GLOBALS.TOOLCHAIN_CONFIG.get_relative_path("temp") output_path = join(temporary_directory, name_to_identifier(placeholder, "-")) ensure_file(output_path) diff --git a/src/icmtoolchain/import_project.py b/src/icmtoolchain/import_project.py index aa7ead1..fdbb360 100644 --- a/src/icmtoolchain/import_project.py +++ b/src/icmtoolchain/import_project.py @@ -4,7 +4,6 @@ import sys from os.path import basename, exists, isdir, isfile, join, relpath from typing import Any, Dict, List, Optional, Tuple -from . import GLOBALS from .config import Config from .hglob import glob from .shell import abort, confirm_prompt, debug, pretty_print, warn @@ -213,6 +212,7 @@ def import_project(path: Optional[str] = None, destination: Optional[str] = None destination_may_changed = not destination toolchain = None if destination_may_changed: + from . import GLOBALS toolchain = GLOBALS.TOOLCHAIN_CONFIG.directory destination = get_project_folder_by_name(toolchain, basename(path)) if not destination: diff --git a/src/icmtoolchain/java_build.py b/src/icmtoolchain/java_build.py index 70826ec..5af0ba3 100644 --- a/src/icmtoolchain/java_build.py +++ b/src/icmtoolchain/java_build.py @@ -9,7 +9,6 @@ from typing import (Collection, Dict, Iterable, List, MutableSequence, from zipfile import ZipFile from . import GLOBALS, PROPERTIES -from .component import install_components from .config import Config from .language import MakeJavaData from .output_directory import expand_paths @@ -556,6 +555,7 @@ def compile_java(tool: str = "gradle") -> int: GLOBALS.MOD_STRUCTURE.cleanup_build_target("java") if not exists(GLOBALS.TOOLCHAIN_CONFIG.get_relative_path("bin/r8")): + from .component import install_components install_components("java") if not exists(GLOBALS.TOOLCHAIN_CONFIG.get_relative_path("bin/r8")): abort("Component 'java' is required for compilation, nothing to do.") diff --git a/src/icmtoolchain/parser.py b/src/icmtoolchain/parser.py index 2de8e0c..905a42b 100644 --- a/src/icmtoolchain/parser.py +++ b/src/icmtoolchain/parser.py @@ -6,8 +6,7 @@ from types import (BuiltinMethodType, ClassMethodDescriptorType, DynamicClassAttribute) from typing import Any, Callable, List, Mapping, Optional, Tuple -from . import GLOBALS, PROPERTIES -from .shell import pretty_print, stringify +from .shell import pretty_print, stringify, warn from .task import Task MAGICS = ( @@ -329,7 +328,7 @@ def parse_callable_arguments(argv: List[str], callable: Callable, signature: ins def apply_environment_properties(ignore_config: bool = False) -> None: if ignore_config: return - from .shell import warn + from . import GLOBALS environ = GLOBALS.TOOLCHAIN_CONFIG.get_value("environment", None) if isinstance(environ, dict): for key in environ: @@ -339,7 +338,7 @@ def apply_environment_properties(ignore_config: bool = False) -> None: warn(f"Environment variable {key!r} expected to be string, please check your 'environment' property in 'toolchain.json'!") def apply_properties(**kwargs) -> int: - global PROPERTIES + from . import PROPERTIES for name, value in kwargs.items(): if value is not None: PROPERTIES.set_value(name, value) @@ -347,6 +346,7 @@ def apply_properties(**kwargs) -> int: return 0 def parse_arguments(argv: List[str], mappings: Mapping[str, Task], fallback: Optional[Callable[[str, Callable, List[NamedCallable]], None]] = None) -> List[NamedCallable]: + from . import GLOBALS callables = list() while True: diff --git a/src/icmtoolchain/utils.py b/src/icmtoolchain/utils.py index bc66d2d..098ac58 100644 --- a/src/icmtoolchain/utils.py +++ b/src/icmtoolchain/utils.py @@ -8,8 +8,6 @@ from typing import (Any, Callable, Dict, Iterable, List, Optional, TextIO, Union, overload) from zipfile import ZipFile, ZipInfo -from . import GLOBALS - DEVNULL = open(os.devnull, "w") @@ -250,6 +248,7 @@ def shortcodes(source: str) -> str: return source def request_tool(name: str) -> Optional[str]: + from . import GLOBALS path = GLOBALS.TOOLCHAIN_CONFIG.get_value(f"tools.{name}") if path: path = GLOBALS.TOOLCHAIN_CONFIG.get_path(path) @@ -264,6 +263,7 @@ def request_typescript(only_check: bool = False) -> Optional[str]: """ Utility to check and install tsc with npm. """ + from . import GLOBALS if GLOBALS.TOOLCHAIN_CONFIG.get_value("denyTypeScript"): return None from .shell import confirm_prompt, error, info