-
Notifications
You must be signed in to change notification settings - Fork 2k
/
build.gradle
88 lines (72 loc) · 2.63 KB
/
build.gradle
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
import org.apache.tools.ant.taskdefs.condition.Os
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
import java.util.zip.GZIPOutputStream
import static java.nio.file.StandardCopyOption.*;
defaultTasks 'build_python'
description = "H2O Python Package"
dependencies {
compile project(":h2o-assembly")
}
def getOS() {
String os = [Os.FAMILY_WINDOWS, Os.FAMILY_MAC, Os.FAMILY_UNIX].find {String family -> Os.isFamily(family) }
return os
}
def getOsSpecificCommandLine(args) { return Os.isFamily(Os.FAMILY_WINDOWS) ? [ 'cmd', '/c' ] + args : args }
def bv = new H2OBuildVersion(rootDir, version)
ext {
PROJECT_VERSION = bv.getProjectVersion()
T = getProjectDir().toString()
}
task setProjectVersion << {
File INIT = new File([T, "h2o", "__init__.py"].join(File.separator))
print INIT.path
def txt=""
txt = INIT.text
txt = txt.replaceAll("SUBST_PROJECT_VERSION", PROJECT_VERSION)
INIT.write(txt)
}
task resetProjectVersion << {
File INIT = new File([T, "h2o", "__init__.py"].join(File.separator))
print INIT.path
def txt=""
txt = INIT.text
txt = txt.replaceAll(PROJECT_VERSION, "SUBST_PROJECT_VERSION")
INIT.write(txt)
}
task upgradeOrInstallTabulate(type: Exec) {
commandLine getOsSpecificCommandLine(["pip", "install", "tabulate", "--user", "--upgrade"])
}
task upgradeOrInstallWheel(type: Exec) {
commandLine getOsSpecificCommandLine(["pip", "install", "wheel", "--user", "--upgrade"])
}
task buildDist(type: Exec) {
commandLine getOsSpecificCommandLine(["python", "setup.py", "bdist_wheel"])
}
def testsPath = new File("./tests")
task smokeTest(type: Exec) {
dependsOn build
println "PyUnit smoke test (run.py --wipeall --testsize s)..."
workingDir testsPath
commandLine 'pwd'
commandLine 'python', '../../scripts/run.py', '--wipeall', '--testsize', 's'
}
task cleanUpSmokeTest << {
new File([T, "tests/results"].join(File.separator)).deleteDir()
}
task cleaner << {
println "Cleaning..."
getProjectDir().toString()
new File([getProjectDir().toString(), "dist"].join(File.separator)).deleteDir()
new File([getProjectDir().toString(), "h2o.egg-info"].join(File.separator)).deleteDir()
new File([getProjectDir().toString(), " build/"].join(File.separator)).deleteDir()
}
clean.dependsOn cleaner, cleanUpSmokeTest
upgradeOrInstallWheel.dependsOn cleaner
// buildDist.dependsOn upgradeOrInstallTabulate
// buildDist.dependsOn upgradeOrInstallWheel
buildDist.dependsOn setProjectVersion
resetProjectVersion.dependsOn buildDist
task build_python(dependsOn: resetProjectVersion)
build.dependsOn build_python