@@ -3,23 +3,9 @@ import sbt.Keys.`package`
33
44enablePlugins(SparkPackagePlugin , AssemblyPlugin )
55
6- lazy val pyZip = taskKey[File ](" Create a minimal pyrasterframes zip distribution." )
7-
8- val pysparkCmd = taskKey[Unit ](" Builds pyspark package and emits command string for running pyspark with package" )
9-
10- lazy val pyTest = taskKey[Unit ](" Run pyrasterframes tests." )
11-
12- lazy val pyExamples = taskKey[Unit ](" Run pyrasterframes examples." )
13-
14- lazy val pyEgg = taskKey[Unit ](" Creates a Python .egg file" )
15-
16- lazy val spJarFile = Def .taskDyn {
17- if (spShade.value) {
18- Def .task((assembly in spPackage).value)
19- } else {
20- Def .task(spPackage.value)
21- }
22- }
6+ // --------------------------------------------------------------------
7+ // Spark Packages Plugin
8+ // --------------------------------------------------------------------
239
2410spName := " io.astraea/pyrasterframes"
2511sparkVersion := rfSparkVersion.value
@@ -64,15 +50,70 @@ spPublishLocal := {
6450 spPublishLocal.value
6551}
6652
67- pyZip := {
53+ // --------------------------------------------------------------------
54+ // Python Build
55+ // --------------------------------------------------------------------
56+
57+ lazy val pythonSource = settingKey[File ](" Default Python source directory." )
58+ pythonSource := baseDirectory.value / " python"
59+
60+ val Python = config(" Python" )
61+
62+ Python / target := target.value / " python-dist"
63+
64+ // Alias
65+ lazy val pyZip = Python / packageBin
66+
67+ Python / packageBin / artifact := {
68+ val java = (Compile / packageBin / artifact).value
69+ java.withType(" zip" ).withClassifier(Some (" python" )).withExtension(" zip" )
70+ }
71+
72+ Python / packageBin / artifactPath := {
73+ val dir = (Python / target).value
74+ val art = (Python / packageBin / artifact).value
75+ val ver = version.value
76+ dir / s " ${art.name}-python- $ver.zip "
77+ }
78+
79+ // Python / packageBin / crossVersion := CrossVersion.disabled
80+
81+ // artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
82+ // // Couldn't figure out how to config scope this, so having to handle for whole module
83+ // artifact.classifier match {
84+ // case Some("python") ⇒
85+ // val ver = version.value
86+ // s"${artifact.name}-python-${ver}.${artifact.extension}"
87+ // case _ ⇒ artifactName.value(sv, module, artifact)
88+ // }
89+ // }
90+
91+ addArtifact(Python / packageBin / artifact, Python / packageBin)
92+
93+ val pysparkCmd = taskKey[Unit ](" Builds pyspark package and emits command string for running pyspark with package" )
94+
95+ lazy val pyTest = taskKey[Unit ](" Run pyrasterframes tests." )
96+
97+ lazy val pyExamples = taskKey[Unit ](" Run pyrasterframes examples." )
98+
99+ lazy val pyEgg = taskKey[Unit ](" Creates a Python .egg file" )
100+
101+ lazy val spJarFile = Def .taskDyn {
102+ if (spShade.value) {
103+ Def .task((assembly in spPackage).value)
104+ } else {
105+ Def .task(spPackage.value)
106+ }
107+ }
108+
109+ Python / packageBin := {
68110 val jar = (`package` in Compile ).value
69- val license = baseDirectory .value / " python " / " LICENSE.md"
70- val pyDir = baseDirectory .value / " python " / " pyrasterframes"
111+ val license = pythonSource .value / " LICENSE.md"
112+ val pyDir = pythonSource .value / " pyrasterframes"
71113 val files = (IO .listFiles(pyDir, GlobFilter (" *.py" ) | GlobFilter (" *.rst" )) ++ Seq (jar, license))
72114 .map(f => (f, " pyrasterframes/" + f.getName))
73- val zipFile = target.value / " python-dist " / " pyrasterframes.zip "
115+ val zipFile = ( Python / packageBin / artifactPath).value
74116 IO .zip(files, zipFile)
75-
76117 zipFile
77118}
78119
@@ -86,27 +127,24 @@ pysparkCmd := {
86127
87128ivyPaths in pysparkCmd := ivyPaths.value.withIvyHome(target.value / " ivy" )
88129
89- // credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
90-
91130pyTest := {
92131 val _ = spPublishLocal.value
93132 val s = streams.value
94- val wd = baseDirectory .value / " python "
133+ val wd = pythonSource .value
95134 Process (" python setup.py test" , wd) ! s.log
96135}
97136
98137Test / test := (Test / test).dependsOn(pyTest).value
99138
100139pyEgg := {
101140 val s = streams.value
102- val wd = baseDirectory .value / " python "
141+ val wd = pythonSource .value
103142 Process (" python setup.py bdist_egg" , wd) ! s.log
104143}
105144
106145pyExamples := {
107146 val _ = spPublishLocal.value
108147 val s = streams.value
109- val wd = baseDirectory .value / " python "
148+ val wd = pythonSource .value
110149 Process (" python setup.py examples" , wd) ! s.log
111150}
112-
0 commit comments