How to use __setup method in pyatom

Best Python code snippet using pyatom_python

products.py

Source:products.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# ==============================================================================3# COPYRIGHT (C) 1991 - 2003 EDF R&D WWW.CODE-ASTER.ORG4# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY5# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY6# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR7# (AT YOUR OPTION) ANY LATER VERSION.8#9# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT10# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF11# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU12# GENERAL PUBLIC LICENSE FOR MORE DETAILS.13#14# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE15# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,16# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.17# ==============================================================================18"""This module defines SETUP instances for each products.19Functions are named : setup_`product`,20and have two main arguments : DEPENDENCIES and SUMMARY objects,21and additionnal arguments through 'kargs'.22"""23# Of course the order is not important... but it's easier to understand24# dependencies in the right order !25import sys26import os27import os.path as osp28import shutil29import re30import multiprocessing31from glob import glob32from __pkginfo__ import dict_prod, dict_prod_param33from products_data import (34 shell_escape,35 waf_template,36 mfront_env_template37)38from as_setup import (39 SETUP,40 GetSitePackages,41 less_than_version,42 export_parameters,43 relative_symlink,44 SetupInstallError,45 unexpandvars,46)47# ----- differ messages translation48def _(mesg): return mesg49# set/unset a value in a dict (cfg)50def set_cfg(setup_object, dico, var, value, **kargs):51 if not type(var) in (list, tuple):52 var = [var,]53 if not type(value) in (list, tuple):54 value = [value,]55 assert len(var) == len(value), 'ERROR in set_var : %r / %r' % (var, value)56 for k, v in zip(var, value):57 dico[k] = v58 setup_object._print('Setting %s=%s' % (k, v))59def add_flags(cfg, options):60 """Add compilation flags corresponding to the options."""61 if not type(options) in (list, tuple):62 options = [options,]63 _cmp_opts = ('CFLAGS', 'F90FLAGS',)64 _all_opts = _cmp_opts + ('LDFLAGS',)65 for opt in options:66 assert opt in ('OPENMP', 'I8'), "unsupported option!"67 for flag in _all_opts:68 flopt = flag + '_' + opt69 cfg[flag] = (cfg[flag] + ' ' + cfg.get(flopt, '')).strip()70 for flag in _cmp_opts:71 fldbg = flag + '_DBG'72 flopt = flag + '_' + opt73 cfg[fldbg] = (cfg[fldbg] + ' ' + cfg.get(flopt, '')).strip()74 for var in _all_opts:75 os.environ[var] = cfg[var]76def lib64_symlink(self, **kwargs):77 """Create a symlink lib to lib64."""78 if not osp.exists('lib'):79 relative_symlink('lib64', 'lib')80#-------------------------------------------------------------------------------81# 40. ----- Metis (standard version)82def setup_metis(dep, summary, **kargs):83 cfg=dep.cfg84 product='metis'85 version = dict_prod[product]86 pkg_name = '%s-%s' % (product, version)87 # ----- add (and check) product dependencies88 dep.Add(product,89 req=['ASTER_ROOT',],90 set=['HOME_METIS','LIB_METIS','D_METIS',],91 )92 cfg['HOME_METIS'] = osp.join(cfg['ASTER_ROOT'], 'public', pkg_name)93 cfg['LIB_METIS'] = "-lmetis"94 cfg['D_METIS'] = "-Dmetis"95 # metis596 actions = (97 ('IsInstalled', { 'filename' :98 [osp.join('__setup.installdir__', 'lib', 'libmetis.a'),99 osp.join('__setup.installdir__', 'include', 'metis.h'), ]100 } ),101 ('Extract' , {}),102 ('Configure', {103 'command': 'make -j 4 config prefix=%(dest)s openmp=openmp' % { 'dest' : cfg['HOME_METIS'] },104 }),105 ('Make' , { 'nbcpu' : max(multiprocessing.cpu_count(),kargs['find_tools'].nbcpu) }),106 ('Install' , {}),107 ('Clean', {}),108 )109 # metis4110 if version.startswith('4'):111 actions = (112 ('IsInstalled', { 'filename' :113 [osp.join('__setup.installdir__', 'lib', 'libmetis.a'),114 osp.join('__setup.installdir__', 'include', 'metis.h'), ]115 } ),116 ('Extract' , {}),117 ('ChgFiles' , {118 'files' : ['Makefile.in'],119 'dtrans' : cfg,120 }),121 ('Make' , { 'nbcpu' : max(multiprocessing.cpu_count(),kargs['find_tools'].nbcpu) }),122 ('Install' , {123 'command' : 'make -j 8 install prefix=%(dest)s ; ' \124 'cp Makefile.in %(dest)s' \125 % { 'dest' : cfg['HOME_METIS'] },126 }),127 ('Clean', {}),128 )129 # ----- setup instance130 setup=SETUP(131 product=product,132 version=version,133 description="""METIS is a software package for partitioning unstructured graphs,134 partitioning meshes, and computing fill-reducing orderings of sparse matrices.135 This version is for MUMPS needs.""",136 depend=dep,137 system=kargs['system'],138 log=kargs['log'],139 reinstall=kargs['reinstall'],140 actions=actions,141 installdir = cfg['HOME_METIS'],142 sourcedir = cfg['SOURCEDIR'],143 )144 return setup145# 40. ----- Metis (standard version)146def setup_parmetis(dep, summary, **kargs):147 cfg=dep.cfg148 product='parmetis'149 version = dict_prod[product]150 pkg_name = '%s-%s' % (product, version)151 # ----- add (and check) product dependencies152 dep.Add(product,153 req=['ASTER_ROOT',],154 set=['HOME_METIS','LIB_METIS','D_METIS'],155 )156 cfg['HOME_METIS'] = osp.join(cfg['ASTER_ROOT'], 'public', pkg_name)157 cfg['LIB_METIS'] = "-lparmetis -lmetis"158 cfg['D_METIS'] = "-Dmetis -Dparmetis"159 # metis5160 actions = (161 ('IsInstalled', { 'filename' :162 [#osp.join('__setup.installdir__', 'lib', 'libmetis.a'),163 osp.join('__setup.installdir__', 'lib', 'libparmetis.a'),164 # osp.join('__setup.installdir__', 'include', 'metis.h'),165 osp.join('__setup.installdir__', 'include', 'parmetis.h'), ]166 } ),167 ('Extract' , {}),168 ('Configure', {169 'command': 'make -j 8 config prefix=%(dest)s' % { 'dest' : cfg['HOME_METIS'] },170 }),171 ('Make' , { 'nbcpu' : max(multiprocessing.cpu_count(),kargs['find_tools'].nbcpu) }),172 ('Install' , {}),173 ('Clean', {}),174 )175 # metis4176 if version.startswith('4'):177 actions = (178 ('IsInstalled', { 'filename' :179 [osp.join('__setup.installdir__', 'lib', 'libmetis.a'),180 osp.join('__setup.installdir__', 'lib', 'libparmetis.a'),181 osp.join('__setup.installdir__', 'include', 'metis.h'),182 osp.join('__setup.installdir__', 'include', 'parmetis.h'), ]183 } ),184 ('Extract' , {}),185 ('Configure', {186 'command': 'make -j %(nbcpu)s config cc=%(CC)s cxx=%(CXX)s openmp=openmp prefix=%(dest)s'\187 % { 'nbcpu' : multiprocessing.cpu_count(),'CC' : cfg['CC'] ,188 'CXX' : cfg['CXX'] ,'dest' : cfg['HOME_METIS'] },189 }),190 # ('Make' , { 'nbcpu' : max(multiprocessing.cpu_count(),kargs['find_tools'].nbcpu) }),191 ('Install' , {192 'command' : 'make -j %(nbcpu)s install prefix=%(dest)s ;'193 'cp $(find $PWD -iname metis.h) %(dest)s/include;'194 'cp $(find $PWD -iname *libmetis.*) %(dest)s/lib' \195 % { 'nbcpu' : multiprocessing.cpu_count(),'dest' : cfg['HOME_METIS'] },196 }),197 ('Clean', {}),198 )199 # ----- setup instance200 setup=SETUP(201 product=product,202 version=version,203 description="""METIS is a software package for partitioning unstructured graphs,204 partitioning meshes, and computing fill-reducing orderings of sparse matrices.205 This version is for MUMPS needs.""",206 depend=dep,207 system=kargs['system'],208 log=kargs['log'],209 reinstall=kargs['reinstall'],210 actions=actions,211 installdir = cfg['HOME_METIS'],212 sourcedir = cfg['SOURCEDIR'],213 )214 return setup215#-------------------------------------------------------------------------------216# 43. ----- scotch217def setup_scotch(dep, summary, **kargs):218 cfg=dep.cfg219 product='scotch'220 version = dict_prod[product]221 pkg_name = '%s-%s' % (product, version)222 # ----- add (and check) product dependencies223 dep.Add(product,224 req=['ASTER_ROOT', 'FLEX', 'RANLIB', 'YACC'],225 set=['HOME_SCOTCH','LIB_SCOTCH','D_SCOTCH',],226 )227 cfg['HOME_SCOTCH'] =osp.join(cfg['ASTER_ROOT'], 'public', pkg_name)228 cfg['LIB_SCOTCH'] ="-lesmumps -lscotch -lscotcherr"229 cfg['D_SCOTCH'] ="-Dscotch"230 scotch_cfg = {}.fromkeys(['CC', 'CFLAGS', 'FLEX', 'RANLIB', 'YACC'], '')231 scotch_cfg.update(cfg)232 if cfg['PLATFORM'] != 'darwin':233 scotch_cfg['CFLAGS'] += ' -Wl,--no-as-needed'234 else:235 # OS X linker does not support '--no-as-needed'236 # plus it does not provide some *NIX clock timing and we must use an old timing method in Scotch (as used in Make.inc/Makefile.inc.i686_mac_darwin10)237 scotch_cfg['CFLAGS'] += ' -DCOMMON_TIMING_OLD -DCOMMON_PTHREAD_BARRIER'238 # ----- setup instance239 setup=SETUP(240 product=product,241 version=version,242 description="""Static mapping, graph partitioning, and sparse matrix block ordering package.""",243 depend=dep,244 system=kargs['system'],245 log=kargs['log'],246 reinstall=kargs['reinstall'],247 actions=(248 ('IsInstalled', { 'filename' :249 [osp.join('__setup.installdir__', 'lib', 'libesmumps.a'),250 osp.join('__setup.installdir__', 'lib', 'libscotch.a'),251 osp.join('__setup.installdir__', 'lib', 'libscotcherr.a'),252 osp.join('__setup.installdir__', 'lib', 'libscotcherrexit.a'),253 osp.join('__setup.installdir__', 'lib', 'libscotchmetis.a'),254 osp.join('__setup.installdir__', 'include', 'scotchf.h'),255 osp.join('__setup.installdir__', 'include', 'scotch.h') ]256 } ),257 ('Extract', {}),258 ('Configure', {259 'command': 'mv src/Makefile.inc src/Makefile.inc.orig ; '260 'cp src/Makefile.aster_full src/Makefile.inc',261 }),262 ('ChgFiles', {263 'files' : [osp.join('src', 'Makefile.inc'), ],264 'dtrans' : scotch_cfg,265 }),266 # remove librt on darwin267 cfg['PLATFORM'] != 'darwin' and (None, None) or \268 ('ChgFiles', {269 'files' : [osp.join('src', 'Makefile.inc'), ],270 'delimiter' : '',271 'dtrans' : { re.escape('-lrt'): ''},272 }),273 ('Make', {274 'path' : osp.join('__setup.workdir__', '__setup.content__', 'src'),275 'nbcpu' : multiprocessing.cpu_count(),#1, # seems not support "-j NBCPU" option276 }),277 # only if version >= 6278 version.startswith('5') and (None, None) or \279 ('Make', {280 'command': 'make esmumps',281 'path' : osp.join('__setup.workdir__', '__setup.content__', 'src'),282 # 'nbcpu' : multiprocessing.cpu_count(),#1, # seems not support "-j NBCPU" option283 }),284 ('Install', {'command' : 'make install prefix=%s' % cfg['HOME_SCOTCH'],285 'path' : osp.join('__setup.workdir__', '__setup.content__', 'src') }),286 ('Clean', {}),287 ),288 installdir = cfg['HOME_SCOTCH'],289 sourcedir = cfg['SOURCEDIR'],290 )291 return setup292#-------------------------------------------------------------------------------293# 43.2 ----- ptscotch294def setup_ptscotch(dep, summary, **kargs):295 cfg=dep.cfg296 product='scotch'297 version = dict_prod[product]298 pkg_name = '%s-%s' % (product, version)299 # ----- add (and check) product dependencies300 dep.Add(product,301 req=['ASTER_ROOT', 'FLEX', 'RANLIB', 'YACC'],302 set=['HOME_SCOTCH','LIB_SCOTCH','D_SCOTCH',],303 )304 cfg['HOME_SCOTCH']=osp.join(cfg['ASTER_ROOT'], 'public', pkg_name)305 cfg['LIB_SCOTCH'] ="-lptesmumps -lscotch -lptscotch -lptscotcherr"306 cfg['D_SCOTCH'] ="-Dscotch -Dptscotch"307 scotch_cfg = {}.fromkeys(['CC', 'CFLAGS', 'FLEX', 'RANLIB', 'YACC'], '')308 scotch_cfg.update(cfg)309 if cfg['PLATFORM'] != 'darwin':310 scotch_cfg['CFLAGS'] += ' -Wl,--no-as-needed'311 else:312 # OS X linker does not support '--no-as-needed'313 # plus it does not provide some *NIX clock timing and we must use an old timing method in Scotch (as used in Make.inc/Makefile.inc.i686_mac_darwin10)314 scotch_cfg['CFLAGS'] += ' -DCOMMON_TIMING_OLD -DCOMMON_PTHREAD_BARRIER'315 # ----- setup instance316 setup=SETUP(317 product=product,318 version=version,319 description="""Static mapping, graph partitioning, and sparse matrix block ordering package.""",320 depend=dep,321 system=kargs['system'],322 log=kargs['log'],323 reinstall=kargs['reinstall'],324 actions=(325 ('IsInstalled', { 'filename' :326 [osp.join('__setup.installdir__', 'lib', 'libptesmumps.a'),327 osp.join('__setup.installdir__', 'lib', 'libesmumps.a'),328 osp.join('__setup.installdir__', 'lib', 'libscotch.a'),329 osp.join('__setup.installdir__', 'lib', 'libptscotch.a'),330 osp.join('__setup.installdir__', 'lib', 'libptscotcherr.a'),331 osp.join('__setup.installdir__', 'lib', 'libscotcherrexit.a'),332 osp.join('__setup.installdir__', 'lib', 'libptscotcherrexit.a'),333 osp.join('__setup.installdir__', 'lib', 'libscotchmetis.a'),334 osp.join('__setup.installdir__', 'lib', 'libptscotchparmetis.a'),335 osp.join('__setup.installdir__', 'include', 'scotchf.h'),336 osp.join('__setup.installdir__', 'include', 'ptscotchf.h'),337 osp.join('__setup.installdir__', 'include', 'scotch.h'),338 osp.join('__setup.installdir__', 'include', 'ptscotch.h') ]339 } ),340 ('Extract', {}),341 ('Configure', {342 'command': 'mv src/Makefile.inc src/Makefile.inc.orig ; '343 'cp src/Makefile.aster_full src/Makefile.inc',344 }),345 ('ChgFiles', {346 'files' : [osp.join('src', 'Makefile.inc'), ],347 'dtrans' : scotch_cfg,348 }),349 # remove librt on darwin350 cfg['PLATFORM'] != 'darwin' and (None, None) or \351 ('ChgFiles', {352 'files' : [osp.join('src', 'Makefile.inc'), ],353 'delimiter' : '',354 'dtrans' : { re.escape('-lrt'): ''},355 }),356 ('Make', {357 'path' : osp.join('__setup.workdir__', '__setup.content__', 'src'),358 'nbcpu' : 2, # seems not support "-j NBCPU" option359 }),360 # only if version >= 6361 version.startswith('5') and (None, None) or \362 ('Make', {363 'command': 'make ptesmumps',364 'path' : osp.join('__setup.workdir__', '__setup.content__', 'src'),365 # 'nbcpu' : 8, # seems not support "-j NBCPU" option366 }),367 ('Install', {'command' : 'make install prefix=%s' % cfg['HOME_SCOTCH'],368 'path' : osp.join('__setup.workdir__', '__setup.content__', 'src') }),369 ('Clean', {}),370 ),371 installdir = cfg['HOME_SCOTCH'],372 sourcedir = cfg['SOURCEDIR'],373 )374 return setup375#-------------------------------------------------------------------------------376def benchcfg(cfg):377 bench_cfg = {}.fromkeys(['CC', 'FCFLAGS', 'CFLAGS', 'RANLIB'378 ,'HOME_METIS', 'HOME_SCOTCH','HOME_MUMPS'379 ,'LIB_SCOTCH','LIB_METIS','D_SCOTCH','D_METIS'], '')380 bench_cfg.update(cfg)381 bench_cfg['AR']='ar'382 bench_cfg['ARFLAGS']='vr'383 bench_cfg['LINK_FC']=bench_cfg['FC']384 bench_cfg['STLIB_METIS']=""385 bench_cfg['STLIB_SCOTCH']=""386 return bench_cfg387# 44. ----- mumps388def setup_mumps(dep, summary, **kargs):389 cfg=dep.cfg390 product='mumps'391 version = dict_prod[product]392 pkg_name = '%s-%s' % (product, version)393 # ----- add (and check) product dependencies394 dep.Add(product,395 req=['ASTER_ROOT', 'CC', 'F90', 'LD', 'INCLUDE_MUMPS', 'MATHLIB', 'OTHERLIB'],396 set=['HOME_MUMPS',],397 )398 cfg['HOME_MUMPS']=osp.join(cfg['ASTER_ROOT'], 'public', pkg_name)399 bench_cfg=benchcfg(cfg)400 # ----- setup instance401 setup=SETUP(402 product=product,403 version=version,404 description="""MUMPS: a MUltifrontal Massively Parallel sparse direct Solver.""",405 depend=dep,406 system=kargs['system'],407 log=kargs['log'],408 reinstall=kargs['reinstall'],409 actions=(410 ('IsInstalled', { 'filename' :411 [osp.join('__setup.installdir__', 'lib', 'libcmumps.a'),412 osp.join('__setup.installdir__', 'lib', 'libdmumps.a'),413 osp.join('__setup.installdir__', 'lib', 'libmpiseq.a'),414 osp.join('__setup.installdir__', 'lib', 'libmumps_common.a'),415 osp.join('__setup.installdir__', 'lib', 'libpord.a'),416 osp.join('__setup.installdir__', 'lib', 'libsmumps.a'),417 osp.join('__setup.installdir__', 'lib', 'libzmumps.a')]418 } ),419 ('Extract' , {}),420 ('Configure', {421 'command': 'cp Make/Makefile%(ext)s Makefile.inc'%{'ext':cfg['make_extension']},422 }),423 ('ChgFiles', {424 'files' : ['Makefile.inc'],425 'dtrans' : bench_cfg,426 }),427 ('Make' , {428 'command' : 'make alllib',429 'capturestderr' : False,430 }),431 ('Install', {432 'command' : 'cp -r include/ lib/ libseq/ PORD/ Makefile.inc %(dest)s' % {'dest':cfg['HOME_MUMPS']}433 ,434 'capturestderr' : False,435 }),436 ('Clean', {}),437 ),438 clean_actions=(439 ('Configure', { # to force 'ld' temporarily to null440 'external' : set_cfg,441 'dico' : cfg,442 'var' : 'HOME_MUMPS',443 'value' : '',444 }),445 ),446 installdir = cfg['HOME_MUMPS'],447 sourcedir = cfg['SOURCEDIR'],448 )449 return setup450#-------------------------------------------------------------------------------451# 45. ----- mumps benchmark452def setup_mumps_benchmark(dep, summary, **kargs):453 cfg=dep.cfg454 product='mumps_benchmark'455 version = dict_prod[product]456 pkg_name = '%s-%s' % (product, version)457 # ----- add (and check) product dependencies458 dep.Add(product,459 req=['ASTER_ROOT', 'CC', 'F90', 'LD', 'INCLUDE_MUMPS', 'MATHLIB', 'OTHERLIB',460 'HOME_MPI','HOME_MUMPS'],461 set=['HOME_MUMPS_BENCH',],462 )463 cfg['HOME_MUMPS_BENCH']=osp.join(cfg['ASTER_ROOT'], 'public', pkg_name)464 bench_cfg=benchcfg(cfg)465 instruct="cp Make/Makefile.in Makefile"466 # ----- setup instance467 setup=SETUP(468 product=product,469 version=version,470 description="""MUMPS Solver Benchmarks.""",471 depend=dep,472 system=kargs['system'],473 log=kargs['log'],474 reinstall=kargs['reinstall'],475 actions=(476 ('Extract' , {}),477 ('Configure', {478 'command':instruct,479 }),480 ('ChgFiles', {481 'files' : ['Makefile'],482 'dtrans' : bench_cfg,483 }),484 ('Install', {485 'command' : 'cp -r Matrices/ dsimpletest.F *.f '486 'save_sparse.py Makefile %(dest)s/'487 %{'dest':cfg['HOME_MUMPS_BENCH']} ,488 # 'capturestderr' : False,489 }),490 ('Clean', {}),491 ('Make' , {492 'path' : cfg['HOME_MUMPS_BENCH'] ,493 'capturestderr' : False,494 }),495 ),496 clean_actions=(497 ('Configure', { # to force 'ld' temporarily to null498 'external' : set_cfg,499 'dico' : cfg,500 'var' : 'HOME_MUMPS_BENCH',501 'value' : '',502 }),503 ),504 installdir = cfg['HOME_MUMPS_BENCH'],505 sourcedir = cfg['SOURCEDIR'],506 )507 return setup508#-------------------------------------------------------------------------------509# 50. ----- Code_Aster510def write_waf_cfg(self, filename, config, template, **kwargs):511 """Fille and write template into filename"""512 # remove mumps includes513 if config['ASTER_VERSION'].startswith('12.'):514 lines = [i for i in template.splitlines() \515 if not '%(HOME_MUMPS)s/include' in i]516 template = os.linesep.join(lines)517 open(filename, 'wb').write(template % config)518def write_aster_conf(self, filename, config, **kwargs):519 """Write the version info"""520 template = 'vers : %(ASTER_VERSION)s:%(ASTER_VERSION_DIR)s/share/aster\n'521 open(filename, 'wb').write(template % config)522def setup_aster(dep, summary, **kargs):523 cfg=dep.cfg524 product='aster'525 version = dict_prod[product]526 pkg_name = '%s-%s' % (product, version)527 short_version = '.'.join(version.split('.')[:2])528 # ----- add (and check) product dependencies529 dep.Add(product,530 req=['ASTER_ROOT', 'ASTER_VERSION',531 'HOME_PYTHON', 'PYTHON_EXE', 'PYTHONLIB',532 'HOME_MUMPS', 'HOME_MPI', 'INCLUDE_MUMPS', 'HOME_METIS',533 # 'HOME_MED', 'HOME_HDF', 'HOME_MFRONT',534 #'HOME_GMSH', 'HOME_HOMARD', optional535 'LD', 'CC', 'F90', 'CXXLIB', 'OTHERLIB', 'SYSLIB', ],536 reqobj=['file:?ASTER_ROOT?/bin/as_run',537 'file:?ASTER_ROOT?/etc/codeaster/profile.sh'],538 )539 cfg['ASTER_VERSION_DIR'] = osp.join(cfg['ASTER_ROOT'], cfg['ASTER_VERSION'])540 os.environ['ASTER_VERSION_DIR'] = cfg['ASTER_VERSION_DIR']541 cfg['OPT_ENV'] = cfg.get('OPT_ENV', '')542 ftools=kargs['find_tools']543 unexpanded_cfg = unexpandvars(cfg,544 vars=('ASTER_VERSION_DIR', 'ASTER_ROOT'))545 # ensure not to automatically load additional environment in waf546 os.environ['DEVTOOLS_COMPUTER_ID'] = 'aster_full'547 # for external programs (see data/wscript)548 os.environ['METISDIR'] = cfg['HOME_METIS']549 # optional paths550 if cfg.get('HOME_GMSH'):551 os.environ['GMSH_BIN_DIR'] = osp.join(cfg['HOME_GMSH'], 'bin')552 if cfg.get('HOME_HOMARD'):553 os.environ['HOMARD_ASTER_ROOT_DIR'] = cfg['HOME_HOMARD']554 # ----- setup instance555 setup=SETUP(556 product=product,557 version=version,558 description="""Code_Aster finite element method solver.""",559 depend=dep,560 system=kargs['system'],561 log=kargs['log'],562 reinstall=kargs['reinstall'],563 actions=(564 ('IsInstalled', { 'filename' :565 [osp.join('__setup.installdir__', cfg['ASTER_VERSION'], 'bin', 'aster'),566 osp.join('__setup.installdir__', cfg['ASTER_VERSION'], 'include', 'aster', 'aster.h'),567 osp.join('__setup.installdir__', cfg['ASTER_VERSION'], 'lib', 'aster', 'aster_core.py'),568 osp.join('__setup.installdir__', cfg['ASTER_VERSION'], 'share', 'aster', 'config.txt'), ]569 } ),570 ('Extract' , {}),571 ('Configure', {572 'external' : write_waf_cfg,573 'template' : waf_template,574 'filename' : 'wafcfg/aster_full_config.py',575 'config' : cfg,576 }),577 ('Configure', {578 'command' : './waf configure --use-config=aster_full_config '579 ' --install-tests --prefix=%(ASTER_VERSION_DIR)s' % cfg,580 'capturestderr' : False,581 }),582 ('Make' , {583 'command' : './waf build',584 'capturestderr' : False,585 }),586 ('Install' , {587 'command' : './waf install',588 'capturestderr' : False,589 }),590 ('Configure', {591 'external' : write_waf_cfg,592 'template' : waf_template,593 'filename' : osp.join(cfg['ASTER_VERSION_DIR'], 'share', 'aster',594 'aster_full_config.py'),595 'config' : cfg,596 }),597 ('Configure', {598 'external' : write_waf_cfg,599 'template' : mfront_env_template,600 'filename' : osp.join(cfg['ASTER_VERSION_DIR'], 'share', 'aster',601 'profile_mfront.sh'),602 'config' : cfg,603 }),604 # remove version with same name605 ('ChgFiles' , {606 'files' : ['aster'],607 'path' : osp.join(cfg['ASTER_ROOT'],'etc','codeaster'),608 'dtrans' : {'^ *vers : %s(|:.*)\n' % cfg['ASTER_VERSLABEL'] : '',609 },610 'delimiter' : '',611 'keep' : True,612 'ext' : '.install_'+cfg['ASTER_VERSION'],613 }),614 # add testing/stable version in the aster version file615 ('ChgFiles' , {616 'files' : ['aster'],617 'path' : osp.join(cfg['ASTER_ROOT'],'etc','codeaster'),618 'dtrans' : {619 re.escape('?vers : VVV?') : \620 '?vers : VVV?\n'621 'vers : %(ASTER_VERSLABEL)s:%(ASTER_VERSION_DIR)s/share/aster' % cfg,622 },623 'delimiter' : '', # that's why some ? have been added above624 'keep' : False,625 }),626 # add numbered version in the aster.conf file627 ('ChgFiles' , {628 'external' : write_aster_conf,629 'filename' : osp.join(cfg['ASTER_VERSION_DIR'], 'aster.conf'),630 'config' : cfg,631 }),632 ('Clean', {}),633 ),634 installdir = cfg['ASTER_ROOT'],635 sourcedir = cfg['SOURCEDIR'],636 )...

Full Screen

Full Screen

ArduinoBoardManager.py

Source:ArduinoBoardManager.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# MLC (Machine Learning Control): A genetic algorithm library to solve chaotic problems3# Copyright (C) 2015-2017, Thomas Duriez (thomas.duriez@gmail.com)4# Copyright (C) 2015, Adrian Durán (adrianmdu@gmail.com)5# Copyright (C) 2015-2017, Ezequiel Torres Feyuk (ezequiel.torresfeyuk@gmail.com)6# Copyright (C) 2016-2017, Marco Germano Zbrun (marco.germano@intraway.com)7# Copyright (C) 2016-2017, Raúl Lopez Skuba (raulopez0@gmail.com)8#9# This program is free software: you can redistribute it and/or modify10# it under the terms of the GNU General Public License as published by11# the Free Software Foundation, either version 3 of the License, or12# (at your option) any later version.13#14# This program is distributed in the hope that it will be useful,15# but WITHOUT ANY WARRANTY; without even the implied warranty of16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17# GNU General Public License for more details.18#19# You should have received a copy of the GNU General Public License20# along with this program. If not, see <http://www.gnu.org/licenses/>21from ArduinoBench import ArduinoBench22from MLC.GUI.Experiment.ArduinoConfigManager.ArduinoStatsDialog import ArduinoStatsDialog23from MLC.GUI.Experiment.ArduinoConfigManager.BoardConfigurationWindow import BoardConfigurationWindow24from MLC.arduino import boards25from MLC.arduino.connection.serialconnection import SerialConnection, SerialConnectionConfig26from MLC.arduino.protocol import ProtocolConfig, init_interface27from MLC.arduino.connection.base import ConnectionException, ConnectionTimeoutException28from PyQt5.QtWidgets import QMessageBox29import serial30import threading31class ArduinoBoardManager:32 def __init__(self, protocol_config, serial_config, close_handler, parent_win=None):33 self.__setup = protocol_config34 self.__connection_config = serial_config35 self.__main_window = BoardConfigurationWindow(self, boards.types, self.__setup, parent=parent_win)36 self.__connectino_status = None37 self.PARITY_BITS = [serial.PARITY_NONE, serial.PARITY_EVEN,38 serial.PARITY_EVEN, serial.PARITY_MARK, serial.PARITY_SPACE]39 self.STOP_BITS = [serial.STOPBITS_ONE, serial.STOPBITS_ONE_POINT_FIVE, serial.STOPBITS_TWO]40 self.BYTE_SIZE = [serial.EIGHTBITS, serial.FIVEBITS, serial.SIXBITS, serial.SEVENBITS]41 # FIXME the connection with the handler shold be made by a method of the window42 self.__main_window.on_close_signal.connect(close_handler)43 def get_protocol_config(self):44 return self.__setup45 def get_connection_config(self):46 current_setup = self.__main_window.checkout_connection_config()47 config = SerialConnectionConfig(port=current_setup["port"],48 baudrate=current_setup["baudrate"],49 parity=self.PARITY_BITS[current_setup["parity"]],50 stopbits=self.STOP_BITS[current_setup["stopbits"]],51 bytesize=self.BYTE_SIZE[current_setup["bytesize"]])52 return config53 def start_connection(self):54 # TODO Este metodo debe estar enlazado a la opcion de conexion serie55 self.__connection_config = self.get_connection_config()56 return SerialConnection(**self.__connection_config._asdict())57 def start(self):58 self.__main_window.show()59 def insert_digital_pin(self, pin_index, pin, type_idx):60 if pin_index < 0:61 return62 current = self.__main_window.get_current_board()["DIGITAL_PINS"] if type_idx != 2 else \63 self.__main_window.get_current_board()["PWM_PINS"]64 target_pin = self.__setup.digital_input_pins if type_idx == 0 else \65 self.__setup.digital_output_pins if type_idx == 1 else self.__setup.pwm_pins66 if pin in current and pin not in self.__setup.digital_input_pins and pin not in self.__setup.digital_output_pins \67 and pin not in self.__setup.pwm_pins:68 target_pin.append(pin)69 self.__main_window.addDigitalPin(pin_index, type_idx)70 else:71 self.show_error(72 "Error", "Assign error", "Could not set pin %s with the selected type" % (pin),73 QMessageBox.Critical, QMessageBox.Ok)74 # Mover a la vista75 def show_error(self, title, text, info, icon, buttons):76 msg = QMessageBox()77 msg.setIcon(icon)78 msg.setText(text)79 msg.setInformativeText(info)80 msg.setWindowTitle(title)81 msg.setStandardButtons(buttons)82 return msg.exec_()83 def remove_digital_pin(self, pin):84 if pin in self.__setup.digital_input_pins:85 self.__setup.digital_input_pins.remove(pin)86 if pin in self.__setup.digital_output_pins:87 self.__setup.digital_output_pins.remove(int(pin))88 if pin in self.__setup.pwm_pins:89 self.__setup.pwm_pins.remove(int(pin))90 def insert_analog_pin(self, pin_index, pin, type_idx):91 if pin_index < 0:92 return93 current = self.__main_window.get_current_board()["ANALOG_PINS"]94 target_pin = self.__setup.analog_input_pins if type_idx == 0 else self.__setup.analog_output_pins95 if pin in current and pin not in self.__setup.analog_input_pins and pin not in self.__setup.analog_output_pins:96 target_pin.append(pin)97 self.__main_window.addAnalogPin(pin_index, type_idx)98 else:99 self.show_error(100 "Error", "Assign error", "Could not set pin %d with the selected type" % (pin),101 QMessageBox.Critical, QMessageBox.Ok)102 def remove_analog_pin(self, pin):103 if pin in self.__setup.analog_input_pins:104 self.__setup.analog_input_pins.remove(pin)105 if pin in self.__setup.analog_output_pins:106 self.__setup.analog_output_pins.remove(pin)107 def check_connection(self):108 self.__connection_status = self.__main_window.create_connection_dialog()109 conn = self.start_connection()110 conn_checker = threading.Thread(target=self.conn_check, args=[conn])111 conn_checker.start()112 self.__connection_status.exec_()113 conn.wake_up()114 conn_checker.join()115 def conn_check(self, conn):116 try:117 config = ProtocolConfig(conn)118 arduino_if = init_interface(config)119 version = arduino_if.get_version()120 self.__connection_status.set_ok()121 except ConnectionTimeoutException:122 self.__connection_status.set_error("Error: connection timeout")123 except ConnectionException:124 self.__connection_status.set_error("Error: Board unreachable")125 except ValueError, err:126 self.__connection_status.set_error("Error: {0}".format(err))127 def board_changed(self, new_idx, old_idx):128 ret = QMessageBox.Yes129 if self.__setup.digital_input_pins or self.__setup.digital_output_pins or \130 self.__setup.analog_input_pins or self.__setup.analog_output_pins or self.__setup.pwm_pins:131 ret = self.show_error(132 "Warning", "Configuration reset", "Changing the board will reset all I/O pins configuration! Continue?",133 QMessageBox.Critical, QMessageBox.Yes | QMessageBox.No)134 if ret == QMessageBox.Yes:135 del self.__setup.digital_input_pins[:]136 del self.__setup.digital_output_pins[:]137 del self.__setup.analog_input_pins[:]138 del self.__setup.analog_output_pins[:]139 del self.__setup.pwm_pins[:]140 self.__setup = self.__setup._replace(board_type=boards.types[new_idx],141 analog_resolution=boards.types[new_idx]["ANALOG_DEFAULT_RESOLUTION"])142 self.__main_window.set_board(new_idx)143 self.__main_window.update(self.__setup)144 return new_idx145 else:146 self.__main_window.set_board(old_idx)147 return old_idx148 def start_bench(self):149 try:150 self.__setup = self.__setup._replace(connection=self.start_connection(),151 **self.__main_window.checkout_board_setup())152 except SerialConnectionException:153 self.show_error(154 "Error", "Connection failure", "Could not start connection to board",155 QMessageBox.Critical, QMessageBox.Ok)156 return157 bench = ArduinoBench()158 stats = ArduinoStatsDialog(bench)159 stats.connect_to_reset(bench)160 bench.add_observer(stats)161 bench.start(self.__setup)162 stats.exec_()163 bench.stop()164 def autodetect_board(self):165 board_id = boards.detect_board()166 if board_id and board_id != self.__main_window.current_board_idx():167 self.board_changed(board_id, self.__main_window.current_board_idx())168 return board_id169 def update_analog_resolution(self, value):170 self.__setup = self.__setup._replace(analog_resolution=value)171class EventScheduler:172 def __init__(self):173 self.stopped = False174 self.queue = []175 self.tasks_presents = threading.Condition()176 def start(self):177 self.thread = threading.Thread(target=self.svc)178 self.thread.start()179 def svc(self):180 while not self.stopped:181 with self.tasks_presents:182 if not self.queue and not self.stopped:183 self.tasks_presents.wait()184 else:185 for i in self.queue:186 i()187 del self.queue[:]188 def push_task(self, task):189 with self.tasks_presents:190 self.queue.append(task)191 self.tasks_presents.notify()192 def stop(self):193 with self.tasks_presents:194 self.stopped = True195 self.tasks_presents.notify()...

Full Screen

Full Screen

accelerate_fft_build.py

Source:accelerate_fft_build.py Github

copy

Full Screen

1from cffi import FFI2ffibuilder = FFI()3# cdef() expects a single string declaring the C types, functions and4# globals needed to use the shared object. It must be in valid C syntax.5ffibuilder.cdef(""" 6 7typedef unsigned long vDSP_Length;8typedef long long vDSP_Stride;9typedef struct DSPComplex {10 float real;11 float imag;12} DSPComplex;13typedef struct DSPDoubleComplex {14 double real;15 double imag;16} DSPDoubleComplex;17typedef struct DSPSplitComplex {18 float * realp;19 float * imagp;20} DSPSplitComplex;21typedef struct DSPDoubleSplitComplex {22 double * realp;23 double * imagp;24} DSPDoubleSplitComplex;25typedef int FFTDirection;26typedef int FFTRadix;27enum {28 kFFTDirection_Forward = +1,29 kFFTDirection_Inverse = -130};31enum {32 kFFTRadix2 = 0,33 kFFTRadix3 = 1,34 kFFTRadix5 = 235};36enum {37 vDSP_HALF_WINDOW = 1,38 vDSP_HANN_DENORM = 0,39 vDSP_HANN_NORM = 240};41 42typedef struct OpaqueFFTSetup *FFTSetup;43typedef struct OpaqueFFTSetupD *FFTSetupD;44extern FFTSetup vDSP_create_fftsetup(45 vDSP_Length __Log2n,46 FFTRadix __Radix)47 ;48void vDSP_destroy_fftsetup( FFTSetup __setup)49 ;50FFTSetupD vDSP_create_fftsetupD(vDSP_Length __Log2n, FFTRadix __Radix);51void vDSP_destroy_fftsetupD(FFTSetupD __setup);52extern void vDSP_ctoz(53 const DSPComplex *__C,54 vDSP_Stride __IC,55 const DSPSplitComplex *__Z,56 vDSP_Stride __IZ,57 vDSP_Length __N)58 ;59extern void vDSP_ztoc(60 const DSPSplitComplex *__Z,61 vDSP_Stride __IZ,62 DSPComplex *__C,63 vDSP_Stride __IC,64 vDSP_Length __N)65 ;66void vDSP_ctozD(const DSPDoubleComplex *__C, vDSP_Stride __IC, const DSPDoubleSplitComplex *__Z, vDSP_Stride __IZ, vDSP_Length __N);67void vDSP_ztocD(const DSPDoubleSplitComplex *__Z, vDSP_Stride __IZ, DSPDoubleComplex *__C, vDSP_Stride __IC, vDSP_Length __N);68void vDSP_fft_zipt(FFTSetup __Setup, const DSPSplitComplex *__C, vDSP_Stride __IC, const DSPSplitComplex *__Buffer, vDSP_Length __Log2N, FFTDirection __Direction);69void vDSP_fft_ziptD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC, const DSPDoubleSplitComplex *__Buffer, vDSP_Length __Log2N, FFTDirection __Direction);70void vDSP_fft_zrip(FFTSetup __Setup, const DSPSplitComplex *__C, vDSP_Stride __IC, vDSP_Length __Log2N, FFTDirection __Direction);71void vDSP_fft_zripD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC, vDSP_Length __Log2N, FFTDirection __Direction);72void vDSP_fft_zip(FFTSetup __Setup, const DSPSplitComplex *__C, vDSP_Stride __IC, vDSP_Length __Log2N, FFTDirection __Direction);73void vDSP_fft_zipD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC, vDSP_Length __Log2N, FFTDirection __Direction);74void vDSP_fft2d_zip(FFTSetup __Setup, const DSPSplitComplex *__C, vDSP_Stride __IC0, vDSP_Stride __IC1, vDSP_Length __Log2N0, vDSP_Length __Log2N1, FFTDirection __Direction);75void vDSP_fft2d_zipD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC0, vDSP_Stride __IC1, vDSP_Length __Log2N0, vDSP_Length __Log2N1, FFTDirection __Direction);76 77extern void vDSP_fft_zop(78 FFTSetup __Setup,79 const DSPSplitComplex *__A,80 vDSP_Stride __IA,81 const DSPSplitComplex *__C,82 vDSP_Stride __IC,83 vDSP_Length __Log2N,84 FFTDirection __Direction);85extern void vDSP_fft_zopD(86 FFTSetupD __Setup,87 const DSPDoubleSplitComplex *__A,88 vDSP_Stride __IA,89 const DSPDoubleSplitComplex *__C,90 vDSP_Stride __IC,91 vDSP_Length __Log2N,92 FFTDirection __Direction);93 94void vDSP_fft2d_zripD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC0, vDSP_Stride __IC1, vDSP_Length __Log2N0, vDSP_Length __Log2N1, FFTDirection __flag);95void vDSP_fft2d_zrip(FFTSetup __Setup, const DSPSplitComplex *__C, vDSP_Stride __IC0, vDSP_Stride __IC1, vDSP_Length __Log2N0, vDSP_Length __Log2N1, FFTDirection __Direction);96void vDSP_fft2d_zop(FFTSetup __Setup, const DSPSplitComplex *__A, vDSP_Stride __IA0, vDSP_Stride __IA1, const DSPSplitComplex *__C, vDSP_Stride __IC0, vDSP_Stride __IC1, vDSP_Length __Log2N0, vDSP_Length __Log2N1, FFTDirection __Direction);97void vDSP_fft2d_zopD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__A, vDSP_Stride __IA0, vDSP_Stride __IA1, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC0, vDSP_Stride __IC1, vDSP_Length __Log2N0, vDSP_Length __Log2N1, FFTDirection __Direction);98void vDSP_fft2d_zrop(FFTSetup __Setup, const DSPSplitComplex *__A, vDSP_Stride __IA0, vDSP_Stride __IA1, const DSPSplitComplex *__C, vDSP_Stride __IC0, vDSP_Stride __IC1, vDSP_Length __Log2N0, vDSP_Length __Log2N1, FFTDirection __Direction);99void vDSP_fft2d_zropD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__A, vDSP_Stride __IA0, vDSP_Stride __IA1, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC0, vDSP_Stride __IC1, vDSP_Length __Log2N0, vDSP_Length __Log2N1, FFTDirection __Direction);100void vDSP_fftm_zip(FFTSetup __Setup, const DSPSplitComplex *__C, vDSP_Stride __IC, vDSP_Stride __IM, vDSP_Length __Log2N, vDSP_Length __M, FFTDirection __Direction);101void vDSP_fftm_zipD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC, vDSP_Stride __IM, vDSP_Length __Log2N, vDSP_Length __M, FFTDirection __Direction);102void vDSP_fftm_zop(FFTSetup __Setup, const DSPSplitComplex *__A, vDSP_Stride __IA, vDSP_Stride __IMA, const DSPSplitComplex *__C, vDSP_Stride __IC, vDSP_Stride __IMC, vDSP_Length __Log2N, vDSP_Length __M, FFTDirection __Direction);103void vDSP_fftm_zopD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__A, vDSP_Stride __IA, vDSP_Stride __IMA, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC, vDSP_Stride __IMC, vDSP_Length __Log2N, vDSP_Length __M, FFTDirection __Direction);104void vDSP_fftm_zrip(FFTSetup __Setup, const DSPSplitComplex *__C, vDSP_Stride __IC, vDSP_Stride __IM, vDSP_Length __Log2N, vDSP_Length __M, FFTDirection __Direction);105void vDSP_fftm_zripD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC, vDSP_Stride __IM, vDSP_Length __Log2N, vDSP_Length __M, FFTDirection __Direction);106void vDSP_fftm_zrop(FFTSetup __Setup, const DSPSplitComplex *__A, vDSP_Stride __IA, vDSP_Stride __IMA, const DSPSplitComplex *__C, vDSP_Stride __IC, vDSP_Stride __IMC, vDSP_Length __Log2N, vDSP_Length __M, FFTDirection __Direction);107void vDSP_fftm_zropD(FFTSetupD __Setup, const DSPDoubleSplitComplex *__A, vDSP_Stride __IA, vDSP_Stride __IMA, const DSPDoubleSplitComplex *__C, vDSP_Stride __IC, vDSP_Stride __IMC, vDSP_Length __Log2N, vDSP_Length __M, FFTDirection __Direction);108 """)109ffibuilder.set_source("_accelerate_fft_cffi",110"""111 #include <Accelerate/Accelerate.h> // the C header of the library112"""113#,extra_link_args=["-framework Accelerate"]114#,115 #,libraries=['framework Accelerate']116 ) # library name, for the linker117if __name__ == "__main__":118 ffibuilder.compile(verbose=True)119 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful