forked from h2oai/h2o-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
109 lines (91 loc) · 3.38 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import org.apache.commons.io.output.ByteArrayOutputStream
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 makeOutputDir(type: Exec) {
if(Os.isFamily(Os.FAMILY_WINDOWS)){
commandLine getOsSpecificCommandLine(['if not exist "build\\tmp" mkdir', 'build\\tmp'])
} else {
commandLine getOsSpecificCommandLine(['mkdir', '-p', 'build/tmp'])
}
}
task setProjectVersion << {
File INIT = new File([T, "h2o", "__init__.py"].join(File.separator))
println " INIT.path = " + 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))
println " INIT.path = " + 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", "--ignore-installed"])
}
task buildDist(type: Exec, dependsOn: makeOutputDir) {
doFirst {
standardOutput = new FileOutputStream("build/tmp/h2o-py_buildDist.out")
}
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'
def args = ['python', '../../scripts/run.py', '--wipeall', '--testsize', 's']
if (project.hasProperty("jacocoCoverage")) {
args << '--jacoco'
}
commandLine args
}
task cleanUpSmokeTest << {
new File([T, "tests/results"].join(File.separator)).deleteDir()
}
task cleanCoverageData(type: Delete) {
delete files("${testsPath}/results/jacoco")
}
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()
delete fileTree(dir: "$projectDir/h2o" , include: '**/*.pyc')
}
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