Skip to content

Commit d6e3e98

Browse files
committed
merge from master
2 parents b935225 + 6043ec7 commit d6e3e98

File tree

4 files changed

+56
-60
lines changed

4 files changed

+56
-60
lines changed

scripts/oneapi.py

Lines changed: 29 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
import common_conf
4949

5050
oneapi_spec_version = common_conf.env['oneapi_version']
51-
args = None
5251

53-
5452
sphinx_build = 'sphinx-build'
5553
source_dir = 'source'
5654
build_dir = 'build'
@@ -88,44 +86,51 @@ def log(*args, **kwargs):
8886

8987
def shell(c):
9088
log(c)
91-
if args.dry_run:
89+
if cl_args.dry_run:
9290
return
9391
subprocess.check_call(c, shell=True)
9492

9593
def rm(dir):
9694
log('rm -rf', dir)
97-
if args.dry_run:
95+
if cl_args.dry_run:
9896
return
9997
shutil.rmtree(dir, ignore_errors=True)
10098

101-
def copytree(src, dst):
99+
from distutils.dir_util import copy_tree as copy_tree_update
100+
101+
def copytree(src, dst, dirs_exist_ok=False):
102102
log('cp -r', src, dst)
103-
if args.dry_run:
103+
if cl_args.dry_run:
104104
return
105-
shutil.copytree(src, dst)
105+
# dirs_exist_ok needs python 3.8 or later, use copy_tree_update
106+
# for now
107+
if dirs_exist_ok:
108+
copy_tree_update(src, dst)
109+
else:
110+
shutil.copytree(src, dst)
106111

107112
def copy(src, dst):
108113
log('cp', src, dst)
109-
if args.dry_run:
114+
if cl_args.dry_run:
110115
return
111116
shutil.copy(src, dst)
112117

113118
def makedirs(path):
114119
log('mkdir -p', path)
115-
if args.dry_run:
120+
if cl_args.dry_run:
116121
return
117122
os.makedirs(path)
118123

119124
def sphinx(root, target):
120-
if not args.verbose:
125+
if not cl_args.verbose:
121126
os.environ['LATEXMKOPTS'] = '--silent'
122127
os.environ['LATEXOPTS'] = '-interaction=nonstopmode -halt-on-error'
123128
sphinx_args = '-N -j auto'
124-
if not args.verbose:
129+
if not cl_args.verbose:
125130
sphinx_args += ' -q'
126-
if args.a:
131+
if cl_args.a:
127132
sphinx_args += ' -a'
128-
if args.n:
133+
if cl_args.n:
129134
sphinx_args += ' -n'
130135
shell('%s -M %s %s %s %s' % (sphinx_build,
131136
target,
@@ -225,19 +230,19 @@ def site_zip():
225230
@action
226231
def ci_publish(root, target=None):
227232
root_only(root)
228-
if not args.branch:
233+
if not cl_args.branch:
229234
exit('Error: --branch <branchname> is required')
230235
if 'AWS_SECRET_ACCESS_KEY' in os.environ and os.environ['AWS_SECRET_ACCESS_KEY'] != '':
231-
shell('aws s3 sync --only-show-errors --delete site s3://%s/exclude/ci/branches/%s' % (staging_host, args.branch))
236+
shell('aws s3 sync --only-show-errors --delete site s3://%s/exclude/ci/branches/%s' % (staging_host, cl_args.branch))
232237
log('published at http://staging.spec.oneapi.com.s3-website-us-west-2.amazonaws.com/exclude/ci/branches/%s/'
233-
% (args.branch))
238+
% (cl_args.branch))
234239
else:
235240
log('Skipping publishing the site because AWS access key is not available. This is expected when building a fork')
236241

237242
@action
238243
def prod_publish(root, target=None):
239244
# sync staging to prod
240-
shell("aws s3 sync --only-show-errors --delete s3://%s/ s3://spec.oneapi.com/ --exclude 'exclude/*'" % (staging_host))
245+
shell("aws s3 sync --only-show-errors s3://%s/ s3://spec.oneapi.com/ --exclude 'exclude/*'" % (staging_host))
241246
log('published at http://spec.oneapi.com/')
242247

243248
@action
@@ -277,25 +282,7 @@ def spec_venv(root, target=None):
277282
pip = 'spec-venv\Scripts\pip' if platform.system() == 'Windows' else 'spec-venv/bin/pip'
278283
shell('%s install --quiet -r requirements.txt' % pip)
279284

280-
@action
281-
def get_tarballs(root='.', target=None):
282-
root_only(root)
283-
print('exists',os.path.exists('tarballs'))
284-
if args.dry_run or os.path.exists('tarballs'):
285-
return
286-
makedirs('tarballs')
287-
for t in tarballs:
288-
tf = join('tarballs','%s.tgz' % t)
289-
url = 'https://spec.oneapi.com/tarballs/%s.tgz' % t
290-
r = requests.get(url, stream = True)
291-
log('wget', url, end = ' ')
292-
with open(tf, 'wb') as tb:
293-
for chunk in r.iter_content(chunk_size = 4 * 1024 * 1024):
294-
if chunk:
295-
tb.write(chunk)
296-
log('.', end = '')
297-
log('.')
298-
285+
299286
@action
300287
def site(root, target=None):
301288
root_only(root)
@@ -311,32 +298,18 @@ def site(root, target=None):
311298
pdf = join('build','latex','oneAPI-spec.pdf')
312299
html = join('build','html')
313300
rm(site)
314-
copytree('site-root','site')
315301
makedirs(versions)
316302
copytree(html, versions_x)
317303
copy(pdf, versions_x)
318-
for t in tarballs:
319-
tf = join('tarballs','%s.tgz' % t)
320-
log('cd',versions_x,'&& tar zxf',tf)
321-
if not args.dry_run:
322-
with tarfile.open(tf) as tar:
323-
tar.extractall(versions_x)
324304
copytree(versions_x, join(versions, 'latest'))
305+
copytree('site-root','site', dirs_exist_ok = True)
325306

326307
def remove_elements(l, elements):
327308
for e in elements:
328309
if e in l:
329310
l.remove(e)
330311
return l
331312

332-
def purge(root, target=None):
333-
root_only(root)
334-
for (r,dirs,files) in os.walk('site', topdown=True):
335-
r = r.replace('site/','')
336-
dirs = remove_elements(dirs,['oneL0'])
337-
for file in files:
338-
print('http://spec.oneapi.com/%s/%s' % (r, file))
339-
340313
@action
341314
def sort_words(root, target=None):
342315
with open(join('source', 'spelling_wordlist.txt')) as fin:
@@ -348,11 +321,10 @@ def sort_words(root, target=None):
348321
@action
349322
def ci(root, target=None):
350323
root_only(root)
351-
get_tarballs(root)
352324
site(root)
353325
build('.', 'spelling')
354326
site_zip()
355-
if args.branch == 'publish' or args.branch == 'refs/heads/publish':
327+
if cl_args.branch == 'publish' or cl_args.branch == 'refs/heads/publish':
356328
stage_publish(root)
357329
else:
358330
ci_publish(root)
@@ -362,7 +334,6 @@ def ci(root, target=None):
362334
commands = {'ci': ci,
363335
'ci-publish': ci_publish,
364336
'clean': clean,
365-
'get-tarballs': get_tarballs,
366337
'dockerbuild': dockerbuild,
367338
'dockerpush': dockerpush,
368339
'dockerrun': dockerrun,
@@ -371,7 +342,6 @@ def ci(root, target=None):
371342
'spelling': build,
372343
'prep': prep,
373344
'prod-publish': prod_publish,
374-
'purge': purge,
375345
'site': site,
376346
'sort-words': sort_words,
377347
'spec-venv': spec_venv,
@@ -383,13 +353,12 @@ def ci(root, target=None):
383353
'oneTBB',
384354
'oneVPL',
385355
'dpcpp',
356+
'l0',
386357
'oneDPL',
387358
'oneDNN']
388359

389-
tarballs = ['oneL0']
390-
391360
def main():
392-
global args
361+
global cl_args
393362
parser = argparse.ArgumentParser(description='Build oneapi spec.')
394363
parser.add_argument('action',choices=commands.keys(), default='html', nargs='?')
395364
parser.add_argument('root', nargs='?', default='.')
@@ -398,8 +367,8 @@ def main():
398367
parser.add_argument('--dry-run', action='store_true')
399368
parser.add_argument('-a', action='store_true', help='sphinx -a (build all files)')
400369
parser.add_argument('-n', action='store_true', help='sphinx -n (nitpicky mode)')
401-
args = parser.parse_args()
370+
cl_args = parser.parse_args()
402371

403-
commands[args.action](args.root, args.action)
372+
commands[cl_args.action](cl_args.root, cl_args.action)
404373

405374
main()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>oneAPI</title>
5+
<meta http-equiv = "refresh" content = "0; url = /level-zero/0.91/index.html" />
6+
</head>
7+
<body>
8+
</body>
9+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>oneAPI</title>
5+
<meta http-equiv = "refresh" content = "0; url = /level-zero/0.91/index.html" />
6+
</head>
7+
<body>
8+
</body>
9+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>oneAPI</title>
5+
<meta http-equiv = "refresh" content = "0; url = /level-zero/latest/index.html" />
6+
</head>
7+
<body>
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)