supports both JVM and/or Scala Native projects
-
Add the plugin to
project/plugins.sbt
addSbtPlugin("ai.kien" % "sbt-scalapy" % "<version>")
-
Enable the plugin for your ScalaPy project in
build.sbt
enablePlugins(ScalaPyPlugin)
sbt-scalapy
would then configure the project to use thepython
in your current environment. If you want to use another Python version, set thescalapyPythonExecutable
key 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
PATH
scalapyPythonExecutable := "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