Skip to content

Commit f5fc763

Browse files
committed
refactor: cleanup and standardize imports across the codebase
Signed-off-by: Samuel Amen Ague <ague.samuel27@gmail.com>
1 parent 3200253 commit f5fc763

71 files changed

Lines changed: 308 additions & 290 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pycompiler_ark/Core/Compiler/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,14 @@
2323

2424
from __future__ import annotations
2525

26-
from pycompiler_ark.Core.Compiler.engine_runner import (
26+
from .engine_runner import (
2727
BuildContext,
2828
EngineRunnerError,
2929
resolve_engine_command,
3030
run_engine_compile,
3131
run_engine_compile_streaming,
3232
)
33-
from pycompiler_ark.Core.process_killer import (
34-
ProcessInfo,
35-
ProcessKiller,
36-
get_process_info,
37-
kill_process,
38-
kill_process_tree,
39-
)
40-
from pycompiler_ark.Core.Compiler.utils import (
33+
from .utils import (
4134
CommandBuilder,
4235
build_command,
4336
check_module_available,
@@ -47,7 +40,14 @@
4740
sanitize_path,
4841
validate_command,
4942
)
50-
from pycompiler_ark.Core.engine.registry import create, get_engine
43+
from ..engine.registry import create, get_engine
44+
from ..process_killer import (
45+
ProcessInfo,
46+
ProcessKiller,
47+
get_process_info,
48+
kill_process,
49+
kill_process_tree,
50+
)
5151

5252
# ============================================================================
5353
# IMPORTS LOCAUX - Core.Compiler

pycompiler_ark/Core/Compiler/engine_runner.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@
3434
from pathlib import Path
3535
from typing import Any, Callable, Optional
3636

37-
from pycompiler_ark.Core.utils.ensure_tools import ensure_tools
38-
from pycompiler_ark.Ui import output
39-
4037
# BuildContext lives in engine_sdk; imported here so callers of this module
4138
# only need to import from pycompiler_ark.Core.Compiler.
42-
from pycompiler_ark.Core.engine.build_context import BuildContext
43-
from pycompiler_ark.Core.process_security import hardened_popen_kwargs, secure_command
39+
from ..engine.build_context import BuildContext
40+
from ..process_security import hardened_popen_kwargs, secure_command
41+
from ..utils.ensure_tools import ensure_tools
42+
from pycompiler_ark.Ui import output
4443

4544

4645
class EngineRunnerError(RuntimeError):
@@ -286,7 +285,7 @@ def __init__(self, log_cb, workspace_path: Path, verbose: bool = False):
286285
@property
287286
def venv_manager(self):
288287
if self._venv_manager is None:
289-
from pycompiler_ark.Core.Venv_Manager.Manager import VenvManager
288+
from ..Venv_Manager.Manager import VenvManager
290289

291290
self._venv_manager = VenvManager(self)
292291
# Automatically load workspace preferences if available
@@ -431,7 +430,7 @@ def _read_stream(stream, callback):
431430
try:
432431
while process.poll() is None:
433432
if stop_signal and stop_signal():
434-
from pycompiler_ark.Core.process_killer import kill_process_tree
433+
from ..process_killer import kill_process_tree
435434

436435
kill_process_tree(process.pid)
437436
break

pycompiler_ark/Core/Compiler/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ def check_internet_connection(timeout: float = 3.0, retries: int = 0) -> bool:
491491
Check if internet connection is available with high certainty.
492492
Prioritizes checking connectivity to essential services like PyPI.
493493
"""
494-
import socket
495494
import http.client
495+
import socket
496496
import time
497497

498498
# Essential hosts to verify connectivity for tool installation

pycompiler_ark/Core/Locking/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import yaml
2929

30-
from pycompiler_ark.Core.globals import WORKSPACE_CONFIG_DIRNAME
30+
from ..globals import WORKSPACE_CONFIG_DIRNAME
3131

3232
from ..Configs import normalize_ark_config
3333
from ..engine.build_context import BuildContext

pycompiler_ark/Core/SystemDepsManager/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515

1616
"""Internal system dependency management package."""
1717

18-
from pycompiler_ark.Core.SystemDepsManager.detection import (
18+
from .detection import (
1919
detect_linux_package_manager,
2020
detect_macos_package_manager,
2121
get_install_command,
2222
which,
2323
)
24-
from pycompiler_ark.Core.SystemDepsManager.headless import (
24+
from .headless import (
2525
check_system_packages,
2626
install_system_packages,
2727
)
28-
from pycompiler_ark.Core.SystemDepsManager.manager import SysDependencyManager
28+
from .manager import SysDependencyManager
2929

3030
__all__ = [
3131
"SysDependencyManager",

pycompiler_ark/Core/Venv_Manager/Manager.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import pycompiler_ark.Core.deps_analyser.analyser as deps_analyser
1212
import pycompiler_ark.Core.SystemDepsManager as sys_deps
13+
1314
from ...Ui import output as output
1415
from ..globals import WORKSPACE_CONFIG_DIRNAME
1516

@@ -455,7 +456,7 @@ def _done(code, _status):
455456
def ensure_tools_installed(self, venv_root: str, tools: list[str]) -> None:
456457
"""Asynchronously check/install the provided tools list with progress dialog."""
457458
try:
458-
from pycompiler_ark.Core.Compiler.utils import check_internet_connection
459+
from ..Compiler.utils import check_internet_connection
459460

460461
if not check_internet_connection():
461462
output.error(
@@ -523,7 +524,7 @@ def ensure_tools_installed(self, venv_root: str, tools: list[str]) -> None:
523524
def ensure_tools_installed_system(self, tools: list[str]) -> None:
524525
"""Asynchronously check/install tools in system Python using pip."""
525526
try:
526-
from pycompiler_ark.Core.Compiler.utils import check_internet_connection
527+
from ..Compiler.utils import check_internet_connection
527528

528529
if not check_internet_connection():
529530
output.error(
@@ -1052,7 +1053,7 @@ def _on_venv_pkg_checked(self, process, code, status, pkg):
10521053
)
10531054
self._check_next_venv_pkg()
10541055
else:
1055-
from pycompiler_ark.Core.Compiler.utils import check_internet_connection
1056+
from ..Compiler.utils import check_internet_connection
10561057

10571058
if not check_internet_connection():
10581059
output.error(
@@ -1240,7 +1241,7 @@ def _on_timeout():
12401241
output.warn(
12411242
f"Timeout exceeded for {label} ({timeout_ms} ms). Killing process..."
12421243
)
1243-
from pycompiler_ark.Core.process_killer import (
1244+
from ..process_killer import (
12441245
kill_process_tree,
12451246
)
12461247

@@ -1830,7 +1831,7 @@ def _start_requirements_install(
18301831
use_system_python: bool = False,
18311832
):
18321833
"""Start the related asynchronous operation."""
1833-
from pycompiler_ark.Core.Compiler.utils import check_internet_connection
1834+
from ..Compiler.utils import check_internet_connection
18341835

18351836
if not check_internet_connection():
18361837
output.error(
@@ -2089,7 +2090,7 @@ def terminate_tasks(self):
20892090
proc = getattr(self, attr, None)
20902091
try:
20912092
if proc:
2092-
from pycompiler_ark.Core.process_killer import kill_process_tree
2093+
from ..process_killer import kill_process_tree
20932094

20942095
kill_process_tree(proc.processId())
20952096
except Exception:

pycompiler_ark/Core/WorkSpaceManager/WorkspaceManipulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def resolve_dropped_files(paths: list[str]) -> list[str]:
9999
"""
100100
Business logic to resolve a list of file/directory paths into a flat list of Python files.
101101
"""
102-
from pycompiler_ark.Core.WorkSpaceManager.SetupWorkspace import SetupWorkspace
102+
from .SetupWorkspace import SetupWorkspace
103103

104104
all_files = []
105105
for path in paths:

pycompiler_ark/Core/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,14 @@
2424
from __future__ import annotations
2525

2626
# Importations de allversion.py
27-
from pycompiler_ark.Core.allversion import (
27+
from .allversion import (
2828
get_bcasl_version,
2929
get_core_version,
3030
get_engine_sdk_version,
3131
)
3232

33-
# Importations de process_killer.py
34-
from pycompiler_ark.Core.process_killer import (
35-
ProcessInfo,
36-
ProcessKiller,
37-
get_process_info,
38-
kill_process,
39-
kill_process_tree,
40-
)
41-
4233
# Importations de utils.py
43-
from pycompiler_ark.Core.Compiler.utils import (
34+
from .Compiler.utils import (
4435
CommandBuilder,
4536
build_command,
4637
check_module_available,
@@ -51,8 +42,17 @@
5142
validate_command,
5243
)
5344

45+
# Importations de process_killer.py
46+
from .process_killer import (
47+
ProcessInfo,
48+
ProcessKiller,
49+
get_process_info,
50+
kill_process,
51+
kill_process_tree,
52+
)
53+
5454
# Importations de Venv_Manager/Manager.py
55-
from pycompiler_ark.Core.Venv_Manager.Manager import VenvManager
55+
from .Venv_Manager.Manager import VenvManager
5656

5757
__all__ = [
5858
"build_command",

pycompiler_ark/Core/engine/ConfigManager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
from datetime import datetime, timezone
2929
from typing import Any, Optional
3030

31-
from pycompiler_ark.Core.globals import WORKSPACE_CONFIG_DIRNAME
32-
31+
from ..globals import WORKSPACE_CONFIG_DIRNAME
3332

3433
ENGINE_CONFIG_BASENAME = "config.json"
3534
ENGINE_CONFIG_VERSION = 1

pycompiler_ark/Core/engine/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717

1818
import os
1919

20-
from .loader import _auto_discover
21-
2220
from . import registry as registry # re-export registry module
2321
from .base import CompilerEngine # re-export base type
22+
from .loader import _auto_discover
2423
from .registry import available_engines as _registry_available_engines
2524
from .registry import bind_tabs as _registry_bind_tabs
2625
from .registry import create as _registry_create

0 commit comments

Comments
 (0)