Skip to content

Commit b8a1c36

Browse files
authored
use importlib for penv_setup.py
1 parent f8c937e commit b8a1c36

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

platform.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
del _lzma
2727

2828
import fnmatch
29+
import importlib.util
2930
import json
3031
import logging
3132
import os
@@ -45,12 +46,14 @@
4546

4647

4748
# Import penv_setup functionality
48-
try:
49-
from .builder.penv_setup import setup_penv_minimal, get_executable_path
50-
except ImportError:
51-
# Fallback for standalone execution
52-
sys.path.insert(0, str(Path(__file__).parent / "builder"))
53-
from penv_setup import setup_penv_minimal, get_executable_path
49+
# Import penv_setup functionality using explicit module loading
50+
penv_setup_path = Path(__file__).parent / "builder" / "penv_setup.py"
51+
spec = importlib.util.spec_from_file_location("penv_setup", str(penv_setup_path))
52+
penv_setup_module = importlib.util.module_from_spec(spec)
53+
spec.loader.exec_module(penv_setup_module)
54+
55+
setup_penv_minimal = penv_setup_module.setup_penv_minimal
56+
get_executable_path = penv_setup_module.get_executable_path
5457

5558

5659
# Constants

0 commit comments

Comments
 (0)