Changeset 9545
- Timestamp:
- Jan 29, 2015, 5:22:37 PM (10 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/__init__.py
r9500 r9545 20 20 21 21 #Add path of package to PYTHONPATH to allow C-extensions to be loaded 22 import sys23 sys.path += __path__22 #import sys 23 #sys.path += __path__ 24 24 25 25 … … 28 28 #----------------------------------------------------- 29 29 30 from numpy.testing import Tester 31 test = Tester().test 30 32 31 33 from anuga.__metadata__ import __version__, __date__, __author__ -
trunk/anuga_core/source/anuga/parallel/setup.py
r9541 r9545 3 3 import os 4 4 import sys 5 import commands 6 import shlex 7 import string 5 8 6 9 from os.path import join 7 10 8 11 #================================================= 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 #================================================= 39 14 40 41 def _get_mpi_cmd(): 15 def getoutput_mpicc(): 42 16 """Returns the output of the command used to compile using 43 17 mpicc.""" 44 18 # LAM/OPENMPI/MPICH2 45 output = _run_command('mpicc -show') + ' -fPIC'19 output = commands.getoutput('mpicc -show') + ' -fPIC' 46 20 47 21 if output: 48 22 return output 49 23 50 # FIXME: If appears that MPICH actually needs these hacks.51 52 24 # MPICH 53 25 # 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') 55 27 if output: 56 28 return output 57 29 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) 30 def parse_command(output): 31 # Now get the include, library dirs and the libs to link. 105 32 flags = shlex.split(output) 106 flags = uniq_arr(flags) # Remove repeated values.33 #flags = uniq_arr(flags) # Remove repeated values. 107 34 inc_dirs = [] 108 35 lib_dirs = [] … … 130 57 131 58 59 132 60 def configuration(parent_package='',top_path=None): 133 61 … … 135 63 from numpy.distutils.system_info import get_info 136 64 137 mpi_flags = get_mpi_flags()65 mpi_flags = parse_command(getoutput_mpicc()) 138 66 139 print(mpi_flags)67 #print(mpi_flags) 140 68 141 69 config = Configuration('parallel', parent_package, top_path)
Note: See TracChangeset
for help on using the changeset viewer.