@@ -2,6 +2,19 @@ import scalapb.compiler.Version.grpcJavaVersion
22import scalapb .compiler .Version .scalapbVersion
33import sys .process .*
44
5+ val hnswLibVersion = " 1.2.1"
6+ val sparkVersion = settingKey[String ](" Spark version" )
7+ val venvFolder = settingKey[String ](" Venv folder" )
8+ val pythonVersion = settingKey[String ](" Python version" )
9+
10+ lazy val createVirtualEnv = taskKey[Unit ](" Create venv" )
11+ lazy val pyTest = taskKey[Unit ](" Run the python tests" )
12+ lazy val black = taskKey[Unit ](" Run the black code formatter" )
13+ lazy val blackCheck = taskKey[Unit ](" Run the black code formatter in check mode" )
14+ lazy val flake8 = taskKey[Unit ](" Run the flake8 style enforcer" )
15+ lazy val pyPackage = taskKey[Unit ](" Package python code" )
16+ lazy val pyPublish = taskKey[Unit ](" Publish python code" )
17+
518ThisBuild / organization := " com.github.jelmerk"
619ThisBuild / scalaVersion := " 2.13.16"
720
@@ -42,6 +55,18 @@ ThisBuild / scalacOptions ++= Seq(
4255
4356ThisBuild / versionScheme := Some (" early-semver" )
4457
58+ ThisBuild / sparkVersion := sys.props.get(" sparkVersion" ).orElse(sys.env.get(" SPARK_VERSION" )).getOrElse(" 3.5.5" )
59+
60+ ThisBuild / pythonVersion := " python3.9"
61+
62+ ThisBuild / crossScalaVersions := {
63+ if (sparkVersion.value >= " 4.0.0" ) {
64+ Seq (" 2.13.16" )
65+ } else {
66+ Seq (" 2.12.20" , " 2.13.16" )
67+ }
68+ }
69+
4570ThisBuild / resolvers += " Local Maven Repository" at " file://" + Path .userHome.absolutePath + " /.m2/repository"
4671
4772ThisBuild / scapegoatIgnoredFiles := Seq (" .*/src_managed/.*" )
@@ -72,18 +97,6 @@ lazy val publishSettings = Seq(
7297lazy val noPublishSettings =
7398 publish / skip := true
7499
75- val hnswLibVersion = " 1.2.1"
76- val sparkVersion = settingKey[String ](" Spark version" )
77- val venvFolder = settingKey[String ](" Venv folder" )
78- val pythonVersion = settingKey[String ](" Python version" )
79-
80- lazy val createVirtualEnv = taskKey[Unit ](" Create venv" )
81- lazy val pyTest = taskKey[Unit ](" Run the python tests" )
82- lazy val black = taskKey[Unit ](" Run the black code formatter" )
83- lazy val blackCheck = taskKey[Unit ](" Run the black code formatter in check mode" )
84- lazy val flake8 = taskKey[Unit ](" Run the flake8 style enforcer" )
85- lazy val pyPackage = taskKey[Unit ](" Package python code" )
86- lazy val pyPublish = taskKey[Unit ](" Publish python code" )
87100
88101lazy val root = (project in file(" ." ))
89102 .aggregate(uberJar, cosmetic)
@@ -93,13 +106,6 @@ lazy val uberJar = (project in file("hnswlib-spark"))
93106 .settings(
94107 name := s " hnswlib-spark-uberjar_ ${sparkVersion.value.split('.' ).take(2 ).mkString(" _" )}" ,
95108 noPublishSettings,
96- crossScalaVersions := {
97- if (sparkVersion.value >= " 4.0.0" ) {
98- Seq (" 2.13.16" )
99- } else {
100- Seq (" 2.12.20" , " 2.13.16" )
101- }
102- },
103109 autoScalaLibrary := false ,
104110 Compile / unmanagedResourceDirectories += baseDirectory.value / " src" / " main" / " python" ,
105111 Compile / unmanagedResources / includeFilter := {
@@ -154,9 +160,7 @@ lazy val uberJar = (project in file("hnswlib-spark"))
154160 Compile / PB .targets := Seq (
155161 scalapb.gen() -> (Compile / sourceManaged).value / " scalapb"
156162 ),
157- sparkVersion := sys.props.getOrElse(" sparkVersion" , " 3.5.5" ),
158163 venvFolder := s " ${baseDirectory.value}/.venv " ,
159- pythonVersion := " python3.9" ,
160164 createVirtualEnv := {
161165 val ret = (
162166 s " ${pythonVersion.value} -m venv ${venvFolder.value}" #&&
@@ -243,13 +247,5 @@ lazy val cosmetic = project
243247 Compile / packageDoc := (uberJar / Compile / packageDoc).value,
244248 Compile / packageSrc := (uberJar / Compile / packageSrc).value,
245249 autoScalaLibrary := false ,
246- crossScalaVersions := {
247- if (sparkVersion.value >= " 4.0.0" ) {
248- Seq (" 2.13.16" )
249- } else {
250- Seq (" 2.12.20" , " 2.13.16" )
251- }
252- },
253- sparkVersion := sys.props.getOrElse(" sparkVersion" , " 3.5.5" ),
254250 publishSettings
255251 )
0 commit comments