-
Notifications
You must be signed in to change notification settings - Fork 18
/
install_xgboost.py
66 lines (56 loc) · 2.4 KB
/
install_xgboost.py
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
"""
Builds the JVM bindings for the latest xgboost.
Environment variables:
* XGBOOST_BASE_VERSION # The new version to use
* SCALA_VERSION
* SPARK_VERSION
"""
from __future__ import print_function, unicode_literals
import os
import re
from _internal import run, sed_inplace
if __name__ == "__main__":
os.chdir("xgboost")
xgboost_dir = os.getcwd()
# Compute DMLC xgboost version, i.e: 1.1.0
xgboost_version = os.environ["XGBOOST_BASE_VERSION"]
[dmlc_version] = re.findall(r"^(.*?)-criteo", xgboost_version)
os.chdir("jvm-packages")
run("mvn -q -B versions:set -DnewVersion=" + xgboost_version)
# versions:update-property only updates properties which define
# artifact versions, therefore we have to resort to sed.
scala_version = os.environ["SCALA_VERSION"]
[scala_binary_version] = re.findall(r"^(2\.1[012])\.\d+", scala_version)
sed_inplace("pom.xml",
"<scala.binary.version>[^<]+",
"<scala.binary.version>" + scala_binary_version, regex=True)
sed_inplace("pom.xml",
"<scala.version>[^<]+",
"<scala.version>" + scala_version, regex=True)
sed_inplace("pom.xml",
"<spark.version>[^<]+",
"<spark.version>" + os.environ["SPARK_VERSION"], regex=True)
sed_inplace("pom.xml",
"<artifactId>xgboost-jvm_[^<]+",
"<artifactId>xgboost-jvm_" + scala_binary_version, regex=True)
# HACK: build release.
sed_inplace("create_jni.py",
"cmake ..",
"cmake .. -DCMAKE_BUILD_TYPE=Release ")
os.chdir("xgboost4j")
sed_inplace("pom.xml",
"<artifactId>xgboost-jvm_[^<]+",
"<artifactId>xgboost-jvm_" + scala_binary_version, regex=True)
sed_inplace("pom.xml",
"<artifactId>xgboost4j_[^<]+",
"<artifactId>xgboost4j_" + scala_binary_version, regex=True)
os.chdir("../xgboost4j-spark")
sed_inplace("pom.xml",
"<artifactId>xgboost-jvm_[^<]+",
"<artifactId>xgboost-jvm_" + scala_binary_version, regex=True)
sed_inplace("pom.xml",
"<artifactId>xgboost4j-spark_[^<]+",
"<artifactId>xgboost4j-spark_" + scala_binary_version, regex=True)
sed_inplace("pom.xml",
"<version>" + dmlc_version + "</version>",
"<version>" + xgboost_version + "</version>", regex=True)