@@ -237,18 +237,49 @@ private Environment buildEnvironment(final ScriptInfo info)
237237 throws ScriptException
238238 {
239239 if (info == null ) return null ;
240- final String envRef = info .get ("env" );
241- if (envRef == null ) return null ;
242240
243- final File envFile = resolveEnvFile (envRef , info .getPath ());
241+ final String envValue = info .get ("env" );
242+ final File envFile = envValue == null ? null : resolveEnvFile (envValue , info .getPath ());
244243 final String envName = sanitizeEnvName (info .getPath ());
245244
245+ final String scheme = info .get ("scheme" );
246+ final List <String > pypi = toListOfStrings (info .get ("pypi" ));
247+ final List <String > conda = toListOfStrings (info .get ("conda" ));
248+ final String python = info .get ("python" );
249+
246250 log .info ("Building Appose environment: " + envName );
247- try {
248- String scheme = info .get ("scheme" );
249- Builder <?> builder = scheme == null ?
250- Appose .file (envFile ) : Appose .file (envFile ).scheme (scheme );
251251
252+ try {
253+ final Builder <?> builder ;
254+ if (envFile == null ) {
255+ // No environment file given -- use inline builder.
256+ if (conda .isEmpty ()) {
257+ // No conda packages required -- use uv.
258+ String [] pypiPkgs = pypi .toArray (new String [0 ]);
259+ builder = python == null ?
260+ Appose .uv ().include (pypiPkgs ) :
261+ Appose .uv ().python (python ).include (pypiPkgs );
262+ }
263+ else {
264+ // Conda packages specified -- use pixi.
265+ List <String > condaPkgList = new ArrayList <>();
266+ if (conda .stream ().anyMatch (v -> v .matches ("python\\ b.*" ))) {
267+ // Python was not included in the conda package list -- add it manually.
268+ // If python version value was given, use that, otherwise open-ended.
269+ condaPkgList .add (python != null ? "python=" + python : "python" );
270+ }
271+ condaPkgList .addAll (conda );
272+ String [] condaPkgs = condaPkgList .toArray (new String [0 ]);
273+ String [] pypiPkgs = pypi .toArray (new String [0 ]);
274+ builder = Appose .pixi ().conda (condaPkgs ).pypi (pypiPkgs );
275+ }
276+ }
277+ else {
278+ // Build with the given environment file.
279+ builder = scheme == null ?
280+ Appose .file (envFile ) :
281+ Appose .file (envFile ).scheme (scheme );
282+ }
252283 return builder .name (envName ).build ();
253284 }
254285 catch (final BuildException e ) {
@@ -259,6 +290,11 @@ private Environment buildEnvironment(final ScriptInfo info)
259290 }
260291 }
261292
293+ private List <String > toListOfStrings (String value ) {
294+ // TODO Auto-generated method stub
295+ throw new UnsupportedOperationException ("Unimplemented method 'toListOfStrings'" );
296+ }
297+
262298 /** Resolves an (optionally relative) env file path against the script path. */
263299 private static File resolveEnvFile (final String envRef ,
264300 final String scriptPath )
0 commit comments