Skip to content

Support scala native #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
python-version: ${{ matrix.python }}
- name: Test
run: sbtn +test
run: sbtn +root/test
shell: bash
publish:
runs-on: ubuntu-20.04
Expand Down
33 changes: 19 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,27 @@ lazy val scala3 = "3.0.2"
ThisBuild / scalaVersion := scala213
ThisBuild / scalafixDependencies += organizeImports

lazy val root = project
lazy val root = crossProject(JVMPlatform, NativePlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("."))
.settings(
name := "Python Native Libs",
crossScalaVersions := Seq(scala212, scala213, scala3),
name := "Python Native Libs",
libraryDependencies ++= Seq(
scalaCollectionCompat,
scalapy % Test,
scalaTest % Test
),
Test / fork := true
"org.scala-lang.modules" %%% "scala-collection-compat" % scalaCollectionCompatVersion,
"org.scalatest" %%% "scalatest" % scalaTestVersion % Test,
"me.shadaj" %%% "scalapy-core" % scalapyVersion % Test
)
)
.settings(
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
)
.jvmSettings(
crossScalaVersions := Seq(scala212, scala213, scala3),
Test / fork := true,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
scalacOptions += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => "-Wunused:imports"
Expand All @@ -46,9 +52,8 @@ lazy val root = project
}
}
)
.settings(
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
.nativeSettings(
crossScalaVersions := Seq(scala212, scala213)
)

lazy val docs = project
Expand All @@ -59,4 +64,4 @@ lazy val docs = project
"PYTHON" -> "/usr/bin/python3"
)
)
.dependsOn(root)
.dependsOn(root.jvm)
8 changes: 4 additions & 4 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sbt._

object Dependencies {
lazy val scalaCollectionCompat =
"org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0"
lazy val scalapy = "me.shadaj" %% "scalapy-core" % "0.5.2"
lazy val scalaTest = "org.scalatest" %% "scalatest" % "3.2.11"
lazy val scalapyVersion = "0.5.2"
lazy val scalaCollectionCompatVersion = "2.5.0"
lazy val scalaTestVersion = "3.2.10"

lazy val organizeImports = "com.github.liancheng" %% "organize-imports" % "0.6.0"
}
8 changes: 5 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0")
2 changes: 1 addition & 1 deletion src/test/scala/ai/kien/python/PythonTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.scalatest.funsuite.AnyFunSuite
class PythonTest extends AnyFunSuite {
Python().scalapyProperties.get.foreach { case (k, v) => System.setProperty(k, v) }

test("ScalaPy runs successfully") {
test("ScalaPy actually runs") {
py.Dynamic.global.list(Seq(1, 2, 3).toPythonCopy)
py"'Hello from ScalaPy!'"
}
Expand Down