Changeset 9545


Ignore:
Timestamp:
Jan 29, 2015, 5:22:37 PM (10 years ago)
Author:
steve
Message:

Added numpy type test to anuga

Location:
trunk/anuga_core/source/anuga
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/__init__.py

    r9500 r9545  
    2020
    2121#Add path of package to PYTHONPATH to allow C-extensions to be loaded
    22 import sys
    23 sys.path += __path__
     22#import sys
     23#sys.path += __path__
    2424
    2525
     
    2828#-----------------------------------------------------
    2929
     30from numpy.testing import Tester
     31test = Tester().test
    3032
    3133from anuga.__metadata__ import __version__, __date__, __author__
  • trunk/anuga_core/source/anuga/parallel/setup.py

    r9541 r9545  
    33import os
    44import sys
     5import commands
     6import shlex
     7import string
    58
    69from os.path import join
    710
    811#=================================================
    9 # Code taken from pypar
    10 #=================================================
    11 
    12 
    13 import string
    14 import tempfile
    15 import shlex
    16 
    17 def uniq_arr(arr):
    18     """Remove repeated values from an array and return new array."""
    19     ret = []
    20     for i in arr:
    21         if i not in ret:
    22             ret.append(i)
    23     return ret
    24 
    25 def _run_command(cmd):
    26     import subprocess
    27 
    28     #print('running ' + cmd)
    29     try:
    30         #FIXME SR: The following only works for python 2.7!
    31         #output = subprocess.check_output(cmd, shell=True)
    32         #FIXME SR: This works for python 2.6
    33         output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
    34 
    35     except:
    36         output = ''
    37 
    38     return output
     12# Code taken from pysph
     13#=================================================   
    3914   
    40 
    41 def _get_mpi_cmd():
     15def getoutput_mpicc():
    4216    """Returns the output of the command used to compile using
    4317    mpicc."""
    4418    # LAM/OPENMPI/MPICH2
    45     output = _run_command('mpicc -show') + ' -fPIC'
     19    output = commands.getoutput('mpicc -show') + ' -fPIC'
    4620
    4721    if output:
    4822        return output
    4923
    50     # FIXME: If appears that MPICH actually needs these hacks.
    51 
    5224    # MPICH
    5325    # works with MPICH version 1.2.1 (on Debian)
    54     output = _run_command('mpicc -compile_info -link_info')
     26    output = commands.getoutput('mpicc -compile_info -link_info')
    5527    if output:
    5628        return output
    5729
    58     # Old version of MPICH needs this hack.
    59     tmp_base = tempfile.mktemp()
    60     tmp_c = tmp_base + ".c"
    61     tmp_o = tmp_base + ".o"
    62     tmp_file = open(tmp_c, "w")
    63     tmp_file.write('#include "mpi.h"\nint main(){return 0;}\n')
    64     tmp_file.close()
    65     output = _run_command("mpicc -show;"\
    66                           "mpicc -echo -c %s -o %s"%(tmp_c, tmp_o))
    67     os.remove(tmp_c)
    68     if os.path.exists(tmp_o):
    69         os.remove(tmp_o)
    70     if output:
    71         return output
    72     else:
    73         return ''
    74 
    75 
    76 def get_mpi_flags():
    77     output = _get_mpi_cmd()
    78     print(output)
    79     if not output:
    80         if sys.platform=='win32': # From Simon Frost
    81             #this didn't work on my machine (Vladimir Lazunin on April 7, 2009)
    82             #output = "gcc -L$MPICH_DIR\SDK.gcc\lib -lmpich -I$MPICH_DIR\SDK.gcc\include"
    83 
    84             #"MPICH_DIR" must be set manually in environment variables
    85             mpi_dir = os.getenv("MPICH_DIR")
    86             if mpi_dir == None:
    87                 print('MPICH_DIR environment variable must be set')
    88                 exit()
    89 
    90             #for MPICH2
    91             sdk_prefix = mpi_dir
    92             lib_name = 'mpi'
    93 
    94             #for MPICH1
    95             if os.path.exists(sdk_prefix + '\\SDK'):
    96                 sdk_prefix += '\\SDK'
    97                 lib_name = 'mpich'
    98             output = 'gcc -L"%(sdk_prefix)s\lib" -l"%(lib_name)s" -I"%(sdk_prefix)s\include"' % {'sdk_prefix' : sdk_prefix, 'lib_name' : lib_name}
    99         else:
    100             output = 'cc -L/usr/opt/mpi -lmpi -lelan'
    101 
    102 
    103     # Now get the include, library dirs and the libs to link with.
    104     #flags = string.split(output)
     30def parse_command(output):
     31    # Now get the include, library dirs and the libs to link.
    10532    flags = shlex.split(output)
    106     flags = uniq_arr(flags) # Remove repeated values.
     33    #flags = uniq_arr(flags) # Remove repeated values.
    10734    inc_dirs = []
    10835    lib_dirs = []
     
    13057
    13158
     59
    13260def configuration(parent_package='',top_path=None):
    13361   
     
    13563    from numpy.distutils.system_info import get_info
    13664   
    137     mpi_flags = get_mpi_flags()
     65    mpi_flags = parse_command(getoutput_mpicc())
    13866   
    139     print(mpi_flags)
     67    #print(mpi_flags)
    14068   
    14169    config = Configuration('parallel', parent_package, top_path)
Note: See TracChangeset for help on using the changeset viewer.