supports both JVM and/or Scala Native projects
-
Add the plugin to
project/plugins.sbtaddSbtPlugin("ai.kien" % "sbt-scalapy" % "<version>")
-
Enable the plugin for your ScalaPy project in
build.sbtenablePlugins(ScalaPyPlugin)sbt-scalapywould then configure the project to use thepythonin your current environment. If you want to use another Python version, set thescalapyPythonExecutablekey to the interpreter executable,could be the absolute path
scalapyPythonExecutable := "/absolute/path/to/python"
or just the name of the executable if it's already in
PATHscalapyPythonExecutable := "python3.9"
ScalaPy for JVM requries the name and location of libpython. You can set these manually instead of letting the plugin automatically figure it out,
scalapyPythonNativeLibrary := "python3.9m"
scalapyPythonNativeLibraryPaths := Seq(
"/first/directory/to/look/for/libpython",
"/second/directory/to/look/for/libpython"
)ScalaPy for Scala Native requries the linker flags for embedding Python. You can set this manually instead of letting the plugin automatically figure it out,
scalapyLinkingOptions := Seq("-l...", "-l...")To use a virtualenv Python, you can either activate the virtualenv then start sbt or set scalapyPythonExecutable to the virtualenv Python executable.
For Scala Native, you also need to set the SCALAPY_PYTHON_PROGRAMNAME environment variable to the virtualenv Python executable,
SCALAPY_PYTHON_PROGRAMNAME="/path/to/python" sbt