@@ -3,6 +3,7 @@ package scala.cli.commands.package0
3
3
import ai .kien .python .Python
4
4
import caseapp .*
5
5
import coursier .launcher .*
6
+ import dependency .*
6
7
import packager .config .*
7
8
import packager .deb .DebianPackage
8
9
import packager .docker .DockerPackage
@@ -36,7 +37,7 @@ import scala.cli.commands.util.BuildCommandHelpers
36
37
import scala .cli .commands .{CommandUtils , ScalaCommand , WatchUtil }
37
38
import scala .cli .config .{ConfigDb , Keys }
38
39
import scala .cli .errors .ScalaJsLinkingError
39
- import scala .cli .internal .{CachedBinary , ProcUtil , ScalaJsLinker }
40
+ import scala .cli .internal .{CachedBinary , Constants , ProcUtil , ScalaJsLinker }
40
41
import scala .cli .packaging .{Library , NativeImage }
41
42
import scala .util .Properties
42
43
@@ -300,7 +301,7 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
300
301
301
302
val outputPath = packageType match {
302
303
case PackageType .Bootstrap =>
303
- value(bootstrap(build, destPath, value(mainClass), () => alreadyExistsCheck()))
304
+ value(bootstrap(build, destPath, value(mainClass), () => alreadyExistsCheck(), logger ))
304
305
destPath
305
306
case PackageType .LibraryJar =>
306
307
val content = Library .libraryJar(build)
@@ -391,7 +392,15 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
391
392
392
393
case nativePackagerType : PackageType .NativePackagerType =>
393
394
val bootstrapPath = os.temp.dir(prefix = " scala-packager" ) / " app"
394
- value(bootstrap(build, bootstrapPath, value(mainClass), () => alreadyExistsCheck()))
395
+ value {
396
+ bootstrap(
397
+ build,
398
+ bootstrapPath,
399
+ value(mainClass),
400
+ () => alreadyExistsCheck(),
401
+ logger
402
+ )
403
+ }
395
404
val sharedSettings = SharedSettings (
396
405
sourceAppPath = bootstrapPath,
397
406
version = packageOptions.packageVersion,
@@ -627,7 +636,7 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
627
636
628
637
val appPath = os.temp.dir(prefix = " scala-cli-docker" ) / " app"
629
638
build.options.platform.value match {
630
- case Platform .JVM => value(bootstrap(build, appPath, mainClass, () => Right (())))
639
+ case Platform .JVM => value(bootstrap(build, appPath, mainClass, () => Right (()), logger ))
631
640
case Platform .JS => buildJs(build, appPath, mainClass, logger)
632
641
case Platform .Native =>
633
642
val dest = value(buildNative(build, mainClass, logger))
@@ -669,7 +678,8 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
669
678
build : Build .Successful ,
670
679
destPath : os.Path ,
671
680
mainClass : String ,
672
- alreadyExistsCheck : () => Either [BuildException , Unit ]
681
+ alreadyExistsCheck : () => Either [BuildException , Unit ],
682
+ logger : Logger
673
683
): Either [BuildException , Unit ] = either {
674
684
val byteCodeZipEntries = os.walk(build.output)
675
685
.filter(os.isFile(_))
@@ -708,10 +718,41 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
708
718
.withOsKind(Properties .isWin)
709
719
.callsItself(Properties .isWin)
710
720
.withJavaOpts(build.options.javaOptions.javaOpts.toSeq.map(_.value.value))
711
- val params = Parameters .Bootstrap (Seq (loaderContent), mainClass)
721
+ val baseParams = Parameters .Bootstrap (Seq (loaderContent), mainClass)
712
722
.withDeterministic(true )
713
723
.withPreamble(preamble)
714
724
725
+ val params =
726
+ if (build.options.notForBloopOptions.doSetupPython.getOrElse(false )) {
727
+ val res = value {
728
+ Artifacts .fetch(
729
+ Positioned .none(Seq (
730
+ dep " ${Constants .pythonInterfaceOrg}: ${Constants .pythonInterfaceName}: ${Constants .pythonInterfaceVersion}"
731
+ )),
732
+ Nil ,
733
+ None ,
734
+ logger,
735
+ build.options.finalCache,
736
+ None ,
737
+ Some (_)
738
+ )
739
+ }
740
+ val entries = res.artifacts.map {
741
+ case (a, f) =>
742
+ val path = os.Path (f)
743
+ if (build.options.notForBloopOptions.packageOptions.isStandalone)
744
+ ClassPathEntry .Resource (path.last, os.mtime(path), os.read.bytes(path))
745
+ else
746
+ ClassPathEntry .Url (a.url)
747
+ }
748
+ val pythonContent = Seq (
749
+ ClassLoaderContent (entries)
750
+ )
751
+ baseParams.addExtraContent(" python" , pythonContent).withPython(true )
752
+ }
753
+ else
754
+ baseParams
755
+
715
756
value(alreadyExistsCheck())
716
757
BootstrapGenerator .generate(params, destPath.toNIO)
717
758
ProcUtil .maybeUpdatePreamble(destPath)
0 commit comments