File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
modules/cli/src/main/scala/scala/cli/commands Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -365,19 +365,22 @@ object Run extends ScalaCommand[RunOptions] with BuildCommandHelpers {
365
365
value(res)
366
366
case Platform .Native =>
367
367
val setupPython = build.options.notForBloopOptions.doSetupPython.getOrElse(false )
368
- val pythonLibraryPaths =
368
+ val (pythonExecutable, pythonLibraryPaths) =
369
369
if (setupPython)
370
370
value {
371
- val python = Python ()
372
- val pathsOrError = python.nativeLibraryPaths
373
- logger.debug(s " Python native library paths: $pathsOrError" )
374
- pathsOrError.orPythonDetectionError
371
+ val python = Python ()
372
+ val pythonPropertiesOrError = for {
373
+ paths <- python.nativeLibraryPaths
374
+ executable <- python.executable
375
+ } yield (Some (executable), paths)
376
+ logger.debug(s " Python executable and native library paths: $pythonPropertiesOrError" )
377
+ pythonPropertiesOrError.orPythonDetectionError
375
378
}
376
379
else
377
- Nil
380
+ ( None , Nil )
378
381
// seems conda doesn't add the lib directory to LD_LIBRARY_PATH (see conda/conda#308),
379
382
// which prevents apps from finding libpython for example, so we update it manually here
380
- val extraEnv =
383
+ val libraryPathsEnv =
381
384
if (pythonLibraryPaths.isEmpty) Map .empty
382
385
else {
383
386
val prependTo =
@@ -397,6 +400,9 @@ object Run extends ScalaCommand[RunOptions] with BuildCommandHelpers {
397
400
Map (prependTo -> newValue)
398
401
}
399
402
}
403
+ val programNameEnv =
404
+ pythonExecutable.fold(Map .empty)(py => Map (" SCALAPY_PYTHON_PROGRAMNAME" -> py))
405
+ val extraEnv = libraryPathsEnv ++ programNameEnv
400
406
val maybeResult = withNativeLauncher(
401
407
build,
402
408
mainClass,
You can’t perform that action at this time.
0 commit comments