@@ -21,12 +21,14 @@ def normpath(path):
21
21
else :
22
22
return normalized
23
23
24
+
24
25
def cp (source , target ):
25
26
source = normpath (source )
26
27
target = normpath (target )
27
28
print ("cp {0} {1}" .format (source , target ))
28
29
shutil .copy (source , target )
29
30
31
+
30
32
def maybe_makedirs (path ):
31
33
path = normpath (path )
32
34
print ("mkdir -p " + path )
@@ -36,6 +38,7 @@ def maybe_makedirs(path):
36
38
if e .errno != errno .EEXIST :
37
39
raise
38
40
41
+
39
42
@contextmanager
40
43
def cd (path ):
41
44
path = normpath (path )
@@ -47,57 +50,76 @@ def cd(path):
47
50
finally :
48
51
os .chdir (cwd )
49
52
53
+
50
54
def run (command , ** kwargs ):
51
55
print (command )
52
56
subprocess .check_call (command , shell = True , ** kwargs )
53
57
58
+
54
59
def get_current_git_tag ():
55
60
out = subprocess .check_output (["git" , "tag" , "--points-at" , "HEAD" ])
56
61
return out .decode ().split ("\n " )[0 ]
57
62
63
+
58
64
def get_current_commit_hash ():
59
65
out = subprocess .check_output (["git" , "rev-parse" , "HEAD" ])
60
66
return out .decode ().split ("\n " )[0 ]
61
67
68
+
62
69
def get_current_git_branch ():
63
70
out = subprocess .check_output (["git" , "log" , "-n" , "1" , "--pretty=%d" , "HEAD" ])
64
71
m = re .search (r"release_[0-9\.]+" , out .decode ())
65
72
if not m :
66
73
raise ValueError ("Expected branch name of form release_xxx" )
67
74
return m .group (0 )
68
75
76
+
69
77
def retrieve (url , filename = None ):
70
78
print (f"{ url } -> { filename } " )
71
79
return urlretrieve (url , filename )
72
80
81
+
73
82
def main ():
74
83
parser = argparse .ArgumentParser ()
75
- parser .add_argument ("--release-version" , type = str , required = True ,
76
- help = "Version of the release being prepared" )
84
+ parser .add_argument (
85
+ "--release-version" ,
86
+ type = str ,
87
+ required = True ,
88
+ help = "Version of the release being prepared" ,
89
+ )
77
90
args = parser .parse_args ()
78
91
79
- if sys .platform != "darwin" or platform .machine () != "x86_64 " :
80
- raise NotImplementedError ("Please run this script using an Intel Mac" )
92
+ if sys .platform != "darwin" or platform .machine () != "arm64 " :
93
+ raise NotImplementedError ("Please run this script using an M1 Mac" )
81
94
82
95
version = args .release_version
83
96
expected_git_tag = "v" + version
84
97
current_git_tag = get_current_git_tag ()
85
98
if current_git_tag != expected_git_tag :
86
99
if not current_git_tag :
87
- raise ValueError (f"Expected git tag { expected_git_tag } but current HEAD has no tag. "
88
- f"Run: git checkout { expected_git_tag } " )
89
- raise ValueError (f"Expected git tag { expected_git_tag } but current HEAD is at tag "
90
- f"{ current_git_tag } . Run: git checkout { expected_git_tag } " )
100
+ raise ValueError (
101
+ f"Expected git tag { expected_git_tag } but current HEAD has no tag. "
102
+ f"Run: git checkout { expected_git_tag } "
103
+ )
104
+ raise ValueError (
105
+ f"Expected git tag { expected_git_tag } but current HEAD is at tag "
106
+ f"{ current_git_tag } . Run: git checkout { expected_git_tag } "
107
+ )
91
108
92
109
commit_hash = get_current_commit_hash ()
93
110
git_branch = get_current_git_branch ()
94
- print (f"Using commit { commit_hash } of branch { git_branch } , git tag { current_git_tag } " )
111
+ print (
112
+ f"Using commit { commit_hash } of branch { git_branch } , git tag { current_git_tag } "
113
+ )
95
114
96
115
with cd ("jvm-packages/" ):
97
116
print ("====copying pure-Python tracker====" )
98
117
for use_cuda in [True , False ]:
99
118
xgboost4j = "xgboost4j-gpu" if use_cuda else "xgboost4j"
100
- cp ("../python-package/xgboost/tracker.py" , f"{ xgboost4j } /src/main/resources" )
119
+ cp (
120
+ "../python-package/xgboost/tracker.py" ,
121
+ f"{ xgboost4j } /src/main/resources" ,
122
+ )
101
123
102
124
print ("====copying resources for testing====" )
103
125
with cd ("../demo/CLI/regression" ):
@@ -115,60 +137,98 @@ def main():
115
137
cp (file , f"{ xgboost4j_spark } /src/test/resources" )
116
138
117
139
print ("====Creating directories to hold native binaries====" )
118
- for os_ident , arch in [("linux" , "x86_64" ), ("windows" , "x86_64" ), ("macos" , "x86_64" )]:
140
+ for os_ident , arch in [
141
+ ("linux" , "x86_64" ),
142
+ ("windows" , "x86_64" ),
143
+ ("macos" , "x86_64" ),
144
+ ]:
119
145
output_dir = f"xgboost4j/src/main/resources/lib/{ os_ident } /{ arch } "
120
146
maybe_makedirs (output_dir )
121
147
for os_ident , arch in [("linux" , "x86_64" )]:
122
148
output_dir = f"xgboost4j-gpu/src/main/resources/lib/{ os_ident } /{ arch } "
123
149
maybe_makedirs (output_dir )
124
150
125
151
print ("====Downloading native binaries from CI====" )
126
- nightly_bucket_prefix = "https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds"
127
- maven_repo_prefix = "https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/release/ml/dmlc"
128
-
129
- retrieve (url = f"{ nightly_bucket_prefix } /{ git_branch } /xgboost4j_{ commit_hash } .dll" ,
130
- filename = "xgboost4j/src/main/resources/lib/windows/x86_64/xgboost4j.dll" )
152
+ nightly_bucket_prefix = (
153
+ "https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds"
154
+ )
155
+ maven_repo_prefix = (
156
+ "https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/release/ml/dmlc"
157
+ )
158
+
159
+ retrieve (
160
+ url = f"{ nightly_bucket_prefix } /{ git_branch } /libxgboost4j/xgboost4j_{ commit_hash } .dll" ,
161
+ filename = "xgboost4j/src/main/resources/lib/windows/x86_64/xgboost4j.dll" ,
162
+ )
163
+ retrieve (
164
+ url = f"{ nightly_bucket_prefix } /{ git_branch } /libxgboost4j/libxgboost4j_{ commit_hash } .dylib" ,
165
+ filename = "xgboost4j/src/main/resources/lib/macos/x86_64/libxgboost4j.dylib" ,
166
+ )
131
167
132
168
with tempfile .TemporaryDirectory () as tempdir :
133
169
# libxgboost4j.so for Linux x86_64, CPU only
134
170
zip_path = os .path .join (tempdir , "xgboost4j_2.12.jar" )
135
171
extract_dir = os .path .join (tempdir , "xgboost4j" )
136
- retrieve (url = f"{ maven_repo_prefix } /xgboost4j_2.12/{ version } /"
137
- f"xgboost4j_2.12-{ version } .jar" ,
138
- filename = zip_path )
172
+ retrieve (
173
+ url = f"{ maven_repo_prefix } /xgboost4j_2.12/{ version } /"
174
+ f"xgboost4j_2.12-{ version } .jar" ,
175
+ filename = zip_path ,
176
+ )
139
177
os .mkdir (extract_dir )
140
178
with zipfile .ZipFile (zip_path , "r" ) as t :
141
179
t .extractall (extract_dir )
142
- cp (os .path .join (extract_dir , "lib" , "linux" , "x86_64" , "libxgboost4j.so" ),
143
- "xgboost4j/src/main/resources/lib/linux/x86_64/libxgboost4j.so" )
180
+ cp (
181
+ os .path .join (extract_dir , "lib" , "linux" , "x86_64" , "libxgboost4j.so" ),
182
+ "xgboost4j/src/main/resources/lib/linux/x86_64/libxgboost4j.so" ,
183
+ )
144
184
145
185
# libxgboost4j.so for Linux x86_64, GPU support
146
186
zip_path = os .path .join (tempdir , "xgboost4j-gpu_2.12.jar" )
147
187
extract_dir = os .path .join (tempdir , "xgboost4j-gpu" )
148
- retrieve (url = f"{ maven_repo_prefix } /xgboost4j-gpu_2.12/{ version } /"
149
- f"xgboost4j-gpu_2.12-{ version } .jar" ,
150
- filename = zip_path )
188
+ retrieve (
189
+ url = f"{ maven_repo_prefix } /xgboost4j-gpu_2.12/{ version } /"
190
+ f"xgboost4j-gpu_2.12-{ version } .jar" ,
191
+ filename = zip_path ,
192
+ )
151
193
os .mkdir (extract_dir )
152
194
with zipfile .ZipFile (zip_path , "r" ) as t :
153
195
t .extractall (extract_dir )
154
- cp (os .path .join (extract_dir , "lib" , "linux" , "x86_64" , "libxgboost4j.so" ),
155
- "xgboost4j-gpu/src/main/resources/lib/linux/x86_64/libxgboost4j.so" )
156
-
196
+ cp (
197
+ os .path .join (extract_dir , "lib" , "linux" , "x86_64" , "libxgboost4j.so" ),
198
+ "xgboost4j-gpu/src/main/resources/lib/linux/x86_64/libxgboost4j.so" ,
199
+ )
157
200
158
201
print ("====Next Steps====" )
159
202
print ("1. Gain upload right to Maven Central repo." )
160
203
print ("1-1. Sign up for a JIRA account at Sonatype: " )
161
- print ("1-2. File a JIRA ticket: "
162
- "https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134. Example: "
163
- "https://issues.sonatype.org/browse/OSSRH-67724" )
164
- print ("2. Store the Sonatype credentials in .m2/settings.xml. See insturctions in "
165
- "https://central.sonatype.org/publish/publish-maven/" )
166
- print ("3. Now on a Mac machine, run:" )
204
+ print (
205
+ "1-2. File a JIRA ticket: "
206
+ "https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134. Example: "
207
+ "https://issues.sonatype.org/browse/OSSRH-67724"
208
+ )
209
+ print (
210
+ "2. Store the Sonatype credentials in .m2/settings.xml. See insturctions in "
211
+ "https://central.sonatype.org/publish/publish-maven/"
212
+ )
213
+ print (
214
+ "3. Now on a M1 Mac machine, run the following to build Scala 2.12 artifacts:"
215
+ )
167
216
print (" GPG_TTY=$(tty) mvn deploy -Prelease -DskipTests" )
168
- print ("4. Log into https://oss.sonatype.org/. On the left menu panel, click Staging "
169
- "Repositories. Visit the URL https://oss.sonatype.org/content/repositories/mldmlc-1085 "
170
- "to inspect the staged JAR files. Finally, press Release button to publish the "
171
- "artifacts to the Maven Central repository." )
217
+ print (
218
+ "4. Log into https://oss.sonatype.org/. On the left menu panel, click Staging "
219
+ "Repositories. Visit the URL https://oss.sonatype.org/content/repositories/mldmlc-xxxx "
220
+ "to inspect the staged JAR files. Finally, press Release button to publish the "
221
+ "artifacts to the Maven Central repository. The top-level metapackage should be "
222
+ "named xgboost-jvm_2.12."
223
+ )
224
+ print ("5. Remove the Scala 2.12 artifacts and build Scala 2.13 artifacts:" )
225
+ print (" rm -rf targets/" )
226
+ print (" GPG_TTY=$(tty) mvn deploy -Prelease-cpu-only,scala-2.13 -DskipTests" )
227
+ print (
228
+ "6. Go to https://oss.sonatype.org/ to release the Scala 2.13 artifacts."
229
+ "The top-level metapackage should be named xgboost-jvm_2.13."
230
+ )
231
+
172
232
173
233
if __name__ == "__main__" :
174
234
main ()
0 commit comments