3434import os .path
3535from os .path import join
3636import platform
37+ import requests
3738import shutil
3839from string import Template
3940import stat
@@ -82,7 +83,7 @@ def __exit__(self, etype, value, traceback):
8283 os .chdir (self .savedPath )
8384
8485def log (* args , ** kwargs ):
85- print (indent * ' ' + ' ' .join (map (str ,args )), ** kwargs )
86+ print (indent * ' ' + ' ' .join (map (str ,args )), flush = True , ** kwargs )
8687
8788def shell (c ):
8889 log (c )
@@ -204,9 +205,12 @@ def ci_publish(root, target=None):
204205 root_only (root )
205206 if not args .branch :
206207 exit ('Error: --branch <branchname> is required' )
207- shell ('aws s3 sync --only-show-errors --delete site s3://%s/exclude/ci/branches/%s' % (staging_host , args .branch ))
208- log ('published at http://staging.spec.oneapi.com.s3-website-us-west-2.amazonaws.com/exclude/ci/branches/%s/'
209- % (args .branch ))
208+ if 'AWS_SECRET_ACCESS_KEY' in os .environ :
209+ shell ('aws s3 sync --only-show-errors --delete site s3://%s/exclude/ci/branches/%s' % (staging_host , args .branch ))
210+ log ('published at http://staging.spec.oneapi.com.s3-website-us-west-2.amazonaws.com/exclude/ci/branches/%s/'
211+ % (args .branch ))
212+ else :
213+ log ('Skipping publishing the site because AWS access key is not available. This is expected when building a fork' )
210214
211215@action
212216def prod_publish (root , target = None ):
@@ -252,18 +256,23 @@ def spec_venv(root, target=None):
252256 shell ('%s install --quiet -r requirements.txt' % pip )
253257
254258@action
255- def clones (root = '.' , target = None ):
259+ def get_tarballs (root = '.' , target = None ):
256260 root_only (root )
257- # defer loading this so script can be invoked without installing packages
258- from git import Repo
259- for repo_base in repos :
260- dir = join ('repos' ,repo_base )
261- if os .path .exists (dir ):
262- continue
263- uri = '%s/%s.git' % (os .environ ['EXTRA_REPOS' ], repo_base )
264- log ('clone:' , uri )
265- if not args .dry_run :
266- Repo .clone_from (uri , dir , multi_options = ['--depth' ,'1' ])
261+ print ('exists' ,os .path .exists ('tarballs' ))
262+ if args .dry_run or os .path .exists ('tarballs' ):
263+ return
264+ makedirs ('tarballs' )
265+ for t in tarballs :
266+ tf = join ('tarballs' ,'%s.tgz' % t )
267+ url = 'https://spec.oneapi.com/tarballs/%s.tgz' % t
268+ r = requests .get (url , stream = True )
269+ log ('wget' , url , end = ' ' )
270+ with open (tf , 'wb' ) as tb :
271+ for chunk in r .iter_content (chunk_size = 4 * 1024 * 1024 ):
272+ if chunk :
273+ tb .write (chunk )
274+ log ('.' , end = '' )
275+ log ('.' )
267276
268277@action
269278def site (root , target = None ):
@@ -285,7 +294,7 @@ def site(root, target=None):
285294 copytree (html , versions_x )
286295 copy (pdf , versions_x )
287296 for t in tarballs :
288- tf = join ('repos' , 'oneapi-spec-tarballs' , ' tarballs' ,'%s.tgz' % t )
297+ tf = join ('tarballs' ,'%s.tgz' % t )
289298 log ('cd' ,versions_x ,'&& tar zxf' ,tf )
290299 if not args .dry_run :
291300 with tarfile .open (tf ) as tar :
@@ -295,9 +304,9 @@ def site(root, target=None):
295304@action
296305def ci (root , target = None ):
297306 root_only (root )
298- clones (root )
307+ get_tarballs (root )
299308 site (root )
300- if args .branch == 'publish' :
309+ if args .branch == 'publish' or args . branch == 'refs/heads/publish' :
301310 stage_publish (root )
302311 else :
303312 ci_publish (root )
@@ -307,7 +316,7 @@ def ci(root, target=None):
307316commands = {'ci' : ci ,
308317 'ci-publish' : ci_publish ,
309318 'clean' : clean ,
310- 'clones ' : clones ,
319+ 'get-tarballs ' : get_tarballs ,
311320 'dockerbuild' : dockerbuild ,
312321 'dockerpush' : dockerpush ,
313322 'dockerrun' : dockerrun ,
@@ -332,10 +341,6 @@ def ci(root, target=None):
332341 'oneL0' ,
333342 'oneDAL' ]
334343
335- repos = ['onetbb-spec' ,
336- 'oneapi-spec-tarballs' ]
337-
338-
339344def main ():
340345 global args
341346 parser = argparse .ArgumentParser (description = 'Build oneapi spec.' )
0 commit comments