forked from shadaj/scalapy-tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
129 lines (113 loc) · 4.93 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import sbt.Keys.libraryDependencies
import scala.sys.process._
import sbtcrossproject.CrossPlugin.autoImport.{ CrossType, crossProject }
lazy val scala211Version = "2.11.12"
lazy val scala212Version = "2.12.11"
lazy val scala213Version = "2.13.2"
lazy val dottyVersion = "0.26.0-RC1"
organization in ThisBuild := "me.shadaj"
scalaVersion in ThisBuild := scala212Version
resolvers in ThisBuild += "jitpack" at "https://jitpack.io"
addCommandAlias(
"publishSignedAll",
(scalaPyTensorFlow: ProjectDefinition[ProjectReference])
.aggregate
.map(p => s"+ ${p.asInstanceOf[LocalProject].project}/publishSigned")
.mkString(";", ";", "")
)
lazy val scalaPyTensorFlow = project
.in(file("."))
.aggregate(
scalaPyTensorFlowJVM,
scalaPyTensorFlowExamplesJVM,
scalaPyTensorFlowNative,
scalaPyTensorFlowExamplesNative,
dottyTensorFlow,
dottyTensorFlowExamples
).settings(
name := "scalapy-tensorflow",
publish / skip := true,
scalacOptions ++= Seq(
"-language:implicitConversions"
)
)
lazy val dottyTensorFlow = project
.in(file("dotty-tensorflow"))
.settings(
name := "dotty-tensorflow",
scalaVersion := dottyVersion,
libraryDependencies += "com.github.VirtuslabRnD.scalapy" % "scalapy-core_2.13" % "b3d8ddc81753a72d11e46601f7a9ad719e452e5c",
fork := true,
javaOptions += s"-Djna.library.path=${"python3-config --prefix".!!.trim}/lib",
projectDependencies ~=(_.map(_.withDottyCompat(dottyVersion))),
)
.dependsOn(scalaPyTensorFlowJVM)
lazy val dottyTensorFlowExamples = project
.in(file("dotty-tensorflow-examples"))
.settings(
name := "dotty-tensorflow-examples",
scalaVersion := dottyVersion,
javaOptions += s"-Djna.library.path=${"python3-config --prefix".!!.trim}/lib",
fork := true,
publish / skip := true
)
.dependsOn(dottyTensorFlow)
lazy val scalaPyTensorFlowCross = crossProject(JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("tensorflow"))
.settings(
name := "scalapy-tensorflow-cross",
// scalapy-core version will replace the one in scalapy-numpy (maintaining binary compatibility)
libraryDependencies += "com.github.VirtuslabRnD.scalapy" %%% "scalapy-core" % "b3d8ddc81753a72d11e46601f7a9ad719e452e5c",
libraryDependencies += "com.github.VirtuslabRnD.scalapy-numpy" %%% "scalapy-numpy" % "8a85b7068e9a377ba4b97e2cf9b7bbe008066202" exclude("me.shadaj", "scalapy-core"),
projectDependencies ~=(_.map(_.withDottyCompat(dottyVersion))),
).jvmSettings(
scalaVersion := scala213Version,
fork in Test := true,
projectDependencies ~=(_.map(_.withDottyCompat(dottyVersion))),
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.3" % Test,
fork := true,
javaOptions += s"-Djna.library.path=${"python3-config --prefix".!!.trim}/lib",
javaOptions in Test += s"-Djna.library.path=${"python3-config --prefix".!!.trim}/lib"
).nativeSettings(
// We need to stick to Scala 2.11 here since scalapy-core and scalapy-numpy are only provided for scala-native (0.3) under Scala 2.11
scalaVersion := scala211Version,
libraryDependencies += "com.github.lolgab" %%% "scalacheck" % "1.14.1" % Test,
nativeLinkStubs := true,
nativeLinkingOptions ++= {
import scala.sys.process._
Seq(
"-rpath", s"${"python3-config --prefix".!!.trim}/lib",
s"-L${"python3-config --prefix".!!.trim}/lib",
) ++ "python3-config --ldflags".!!.split(' ').map(_.trim).filter(_.nonEmpty).toSeq
}
)
lazy val scalaPyTensorFlowJVM = scalaPyTensorFlowCross.jvm.settings(name := "scalapy-tensorflow-jvm")
lazy val scalaPyTensorFlowNative = scalaPyTensorFlowCross.native.settings(name := "scalapy-tensorflow-native")
lazy val scalaPyTensorFlowExamplesCross = crossProject(JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("tensorflow-examples"))
.settings(
name := "tensorflow-examples-cross",
publish / skip := true
).jvmSettings(
scalaVersion := scala213Version,
javaOptions += s"-Djna.library.path=${"python3-config --prefix".!!.trim}/lib",
javaOptions in Test += s"-Djna.library.path=${"python3-config --prefix".!!.trim}/lib",
fork := true
).nativeSettings(
scalaVersion := scala211Version,
nativeLinkStubs := true,
nativeLinkingOptions ++= {
import scala.sys.process._
Seq(
"-rpath", s"${"python3-config --prefix".!!.trim}/lib",
s"-L${"python3-config --prefix".!!.trim}/lib",
) ++ "python3-config --ldflags".!!.split(' ').map(_.trim).filter(_.nonEmpty).toSeq
}
)
.dependsOn(scalaPyTensorFlowCross)
lazy val scalaPyTensorFlowExamplesJVM = scalaPyTensorFlowExamplesCross.jvm.settings(name := "tensorflow-example-jvm")
lazy val scalaPyTensorFlowExamplesNative = scalaPyTensorFlowExamplesCross.native.settings(name := "tensorflow-example-native")
// To make sure that changes to project structure are picked up by sbt without an explicit `reload`
Global / onChangedBuildSource := ReloadOnSourceChanges