4242import subprocess
4343import tarfile
4444import venv
45+ from zipfile import ZipFile
4546
4647sys .path .insert (0 , os .path .abspath (join ('source' ,'conf' )))
4748import common_conf
4849
4950args = None
5051
5152
52- sphinx_opts = '-q'
5353sphinx_build = 'sphinx-build'
5454source_dir = 'source'
5555build_dir = 'build'
@@ -116,13 +116,14 @@ def makedirs(path):
116116 os .makedirs (path )
117117
118118def sphinx (root , target ):
119- os .environ ['LATEXMKOPTS' ] = '--silent'
120- os .environ ['LATEXOPTS' ] = '-interaction=nonstopmode -halt-on-error'
119+ if not args .verbose :
120+ os .environ ['LATEXMKOPTS' ] = '--silent'
121+ os .environ ['LATEXOPTS' ] = '-interaction=nonstopmode -halt-on-error'
121122 shell ('%s -M %s %s %s %s' % (sphinx_build ,
122123 target ,
123124 join (root ,source_dir ),
124125 join (root ,build_dir ),
125- sphinx_opts ))
126+ '' if args . verbose else '-q' ))
126127
127128def get_env (var ):
128129 return os .environ [var ] if var in os .environ else ''
@@ -151,11 +152,15 @@ def dockerpush(root, target=None):
151152def dockerrun (root , target = None ):
152153 root_only (root )
153154 shell ('docker run --rm -it'
155+ ' -e http_proxy=%s'
156+ ' -e https_proxy=%s'
157+ ' -e no_proxy=%s'
154158 ' --user %s:%s'
155159 ' --volume=%s:/build'
156160 ' --workdir=/build'
157161 ' rscohn2/oneapi-spec'
158- % (os .getuid (), os .getgid (), os .getcwd ()))
162+ % (get_env ('http_proxy' ), get_env ('https_proxy' ), get_env ('no_proxy' ),
163+ os .getuid (), os .getgid (), os .getcwd ()))
159164
160165@action
161166def clean (root , target = None ):
@@ -203,9 +208,16 @@ def build(root, target):
203208@action
204209def ci_publish (root , target = None ):
205210 root_only (root )
211+ with ZipFile ('site.zip' , 'w' ) as site_zip :
212+ for r , dirs , files in os .walk ('site' , topdown = True ):
213+ # Exclude DAL API because it is 1.7G
214+ if os .path .basename (r ) == 'oneDAL' :
215+ dirs = remove_elements (dirs , ['api' , '_sources' ])
216+ for file in files :
217+ site_zip .write (join (r , file ))
206218 if not args .branch :
207219 exit ('Error: --branch <branchname> is required' )
208- if 'AWS_SECRET_ACCESS_KEY' in os .environ :
220+ if 'AWS_SECRET_ACCESS_KEY' in os .environ and os . environ [ 'AWS_SECRET_ACCESS_KEY' ] != '' :
209221 shell ('aws s3 sync --only-show-errors --delete site s3://%s/exclude/ci/branches/%s' % (staging_host , args .branch ))
210222 log ('published at http://staging.spec.oneapi.com.s3-website-us-west-2.amazonaws.com/exclude/ci/branches/%s/'
211223 % (args .branch ))
@@ -311,15 +323,24 @@ def purge(root, target=None):
311323 root_only (root )
312324 for (r ,dirs ,files ) in os .walk ('site' , topdown = True ):
313325 r = r .replace ('site/' ,'' )
314- dirs = remove_elements (dirs ,['oneDAL' , ' oneL0' , 'oneMKL ' ])
326+ dirs = remove_elements (dirs ,['oneL0' ])
315327 for file in files :
316328 print ('http://spec.oneapi.com/%s/%s' % (r , file ))
317329
330+ @action
331+ def sort_words (root , target = None ):
332+ with open (join ('source' , 'spelling_wordlist.txt' )) as fin :
333+ lines = fin .readlines ()
334+ with open (join ('source' , 'spelling_wordlist.txt' ), 'w' ) as fout :
335+ for l in sorted (list (set (lines ))):
336+ fout .write (l )
337+
318338@action
319339def ci (root , target = None ):
320340 root_only (root )
321341 get_tarballs (root )
322342 site (root )
343+ build ('.' , 'spelling' )
323344 if args .branch == 'publish' or args .branch == 'refs/heads/publish' :
324345 stage_publish (root )
325346 else :
@@ -336,10 +357,12 @@ def ci(root, target=None):
336357 'dockerrun' : dockerrun ,
337358 'html' : build ,
338359 'latexpdf' : build ,
360+ 'spelling' : build ,
339361 'prep' : prep ,
340362 'prod-publish' : prod_publish ,
341363 'purge' : purge ,
342364 'site' : site ,
365+ 'sort-words' : sort_words ,
343366 'spec-venv' : spec_venv ,
344367 'stage-publish' : stage_publish }
345368
@@ -352,16 +375,15 @@ def ci(root, target=None):
352375 'oneDPL' ,
353376 'oneDNN' ]
354377
355- tarballs = ['oneMKL' ,
356- 'oneL0' ,
357- 'oneDAL' ]
378+ tarballs = ['oneL0' ]
358379
359380def main ():
360381 global args
361382 parser = argparse .ArgumentParser (description = 'Build oneapi spec.' )
362- parser .add_argument ('action' ,choices = commands .keys ())
383+ parser .add_argument ('action' ,choices = commands .keys (), default = 'html' , nargs = '?' )
363384 parser .add_argument ('root' , nargs = '?' , default = '.' )
364385 parser .add_argument ('--branch' )
386+ parser .add_argument ('--verbose' , action = 'store_true' )
365387 parser .add_argument ('--dry-run' , action = 'store_true' )
366388 args = parser .parse_args ()
367389
0 commit comments