@@ -46,17 +46,17 @@ def resolve_engine_command(
4646 engine_id : str ,
4747 context : BuildContext ,
4848 engine_config : dict [str , Any ] | None = None ,
49- ) -> tuple [str , list [str ]]:
49+ ) -> tuple [str , list [str ], dict [ str , str ] ]:
5050 """
51- Load *engine_id* and derive the (program, args) pair for *context*.
51+ Load *engine_id* and derive (program, args, env) for *context*.
5252
5353 Args:
5454 engine_id: Registered engine identifier (e.g. ``"pyinstaller"``).
5555 context: BuildContext describing the project.
5656 engine_config: Optional per-engine config overrides.
5757
5858 Returns:
59- A ``(program, args)`` tuple ready to be passed to subprocess.
59+ A ``(program, args, env )`` tuple ready to be passed to subprocess.
6060
6161 Raises:
6262 EngineRunnerError: When the engine cannot be loaded, does not support
@@ -76,11 +76,11 @@ def resolve_engine_command(
7676 pass
7777
7878 try :
79- resolved = engine .program_and_args_from_context (context )
80- except NotImplementedError as exc :
79+ resolved = engine .program_and_args (context )
80+ except NotImplementedError :
8181 raise EngineRunnerError (
82- f"Engine '{ engine_id } ' does not support BuildContext builds "
83- ) from exc
82+ f"Engine '{ engine_id } ' does not implement build_command "
83+ )
8484 except Exception as exc :
8585 raise EngineRunnerError (
8686 f"Engine '{ engine_id } ' failed to build command: { exc } "
@@ -90,7 +90,16 @@ def resolve_engine_command(
9090 raise EngineRunnerError (f"Engine '{ engine_id } ' returned no command" )
9191
9292 program , args = resolved
93- return str (program ), list (args )
93+
94+ # Retrieve engine-specific environment
95+ try :
96+ env = engine .environment () if hasattr (engine , "environment" ) else {}
97+ if env is None :
98+ env = {}
99+ except Exception :
100+ env = {}
101+
102+ return str (program ), list (args ), dict (env )
94103
95104
96105def run_engine_compile (
@@ -138,16 +147,20 @@ def run_engine_compile(
138147 f"Entrypoint missing or obsolete: { context .entry_point } "
139148 )
140149
141- # ── 2. Resolve (program, args) from engine ───── ──────────────────────────
150+ # ── 2. Resolve (program, args, env ) from engine ──────────────────────────
142151 try :
143- program , args = resolve_engine_command (engine_id , context , engine_config )
152+ program , args , engine_env = resolve_engine_command (engine_id , context , engine_config )
144153 except EngineRunnerError as exc :
145154 return _failure (str (exc ))
146155
147156 # ── 3. Security hardening ────────────────────────────────────────────────
148157 try :
158+ # Merge engine env with mandatory ARK variables
159+ full_env = dict (engine_env )
160+ full_env ["ARK_WORKSPACE" ] = str (workspace )
161+
149162 safe_program , safe_args , safe_env = secure_command (
150- program , args , { "ARK_WORKSPACE" : str ( workspace )}
163+ program , args , full_env
151164 )
152165 except Exception as exc :
153166 return _failure (f"Unsafe compile command blocked: { exc } " )
0 commit comments