Changeset 4446 for anuga_core/source/anuga/mesh_engine/compile.py
- Timestamp:
- May 16, 2007, 11:26:11 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/mesh_engine/compile.py
r4435 r4446 7 7 import compile 8 8 compile.compile(<filename>,..) 9 10 SPECIAL VERSION FOR TRIANGLE !11 9 12 10 Ole Nielsen, Oct 2001 … … 26 24 """ 27 25 26 27 28 28 import os, string, sys, types 29 29 … … 155 155 # 156 156 if sys.platform == 'win32': #Windows 157 include = os.path.join(sys.exec_prefix, 'include')157 python_include = os.path.join(sys.exec_prefix, 'include') 158 158 else: 159 include = os.path.join(os.path.join(sys.exec_prefix, 'include'),160 'python'+version)159 python_include = os.path.join(os.path.join(sys.exec_prefix, 'include'), 160 'python' + version) 161 161 162 162 # Check existence of Python.h 163 163 # 164 headerfile = include + os.sep +'Python.h'164 headerfile = python_include + os.sep + 'Python.h' 165 165 try: 166 166 open(headerfile, 'r') … … 170 170 In debian linux, for example, you need to install a 171 171 package called something like python2.3-dev""" %headerfile 172 173 174 175 #Add Python path + utilities to includelist (see ticket:31) 176 #Assume there is only one 'utilities' dir under path dirs 177 178 utilities_include_dir = None 179 for pathdir in sys.path: 180 181 utilities_include_dir = pathdir + os.sep + 'utilities' 182 #print pathdir 183 #print utilities_include_dir 184 try: 185 os.stat(utilities_include_dir) 186 except OSError: 187 pass 188 else: 189 #print 'Found %s to be used as include dir' %utilities_include_dir 190 break 191 192 # This is hacky since it 193 # assumes the location of the compile_all that determines buildroot 194 try: 195 utilities_include_dir = buildroot + os.sep + "source" + os.sep + "anuga" \ 196 + os.sep + 'utilities' 197 except: 198 # This will make compile work locally 199 utilities_include_dir = '.' 200 201 202 203 try: 204 os.stat(utilities_include_dir) 205 except OSError: 206 utilities_include_dir = buildroot + os.sep + 'utilities' 207 172 208 173 209 … … 183 219 184 220 try: 185 open(FN, 'r')186 except: 221 open(FN, 'r') 222 except: 187 223 raise Exception, "Could not open: " + FN 188 224 … … 193 229 # Compile 194 230 # 195 s = "%s -c %s -I%s -o %s.o -O3 -DTRILIBRARY=1 -DNO_TIMER=1" %(compiler, FN, include, root) 231 if utilities_include_dir is None: 232 s = '%s -c %s -I"%s" -o "%s.o" -Wall -O3'\ 233 %(compiler, FN, python_include, root) 234 else: 235 if FN == "triangle.c" or FN == "mesh_engine_c_layer.c": 236 s = '%s -c %s -I"%s" -I"%s" -o "%s.o" -O3 -DTRILIBRARY=1 -DNO_TIMER=1'\ 237 %(compiler, FN, python_include, utilities_include_dir, root) 238 else: 239 s = '%s -c %s -I"%s" -I"%s" -o "%s.o" -Wall -O3'\ 240 %(compiler, FN, python_include, utilities_include_dir, root) 196 241 197 242 if os.name == 'posix' and os.uname()[4] == 'x86_64': 198 243 #Extra flags for 64 bit architectures 244 #Second clause will always fail on Win32 because uname is UNIX specific 245 #but won't get past first clause 199 246 200 247 #FIXME: Which one? … … 217 264 218 265 # Make shared library (*.so or *.dll) 219 220 s = "%s -%s %s -o %s.%s %s -lm" %(loader, sharedflag, object_files, root1, libext, libs) 266 if libs is "": 267 s = '%s -%s %s -o %s.%s -lm' %(loader, sharedflag, object_files, root1, libext) 268 else: 269 s = '%s -%s %s -o %s.%s "%s" -lm' %(loader, sharedflag, object_files, root1, libext, libs) 221 270 if verbose: 222 271 print s … … 312 361 except: 313 362 pass 314 if filename == 'mesh_engine.c': # not part of ANUGA 315 continue 316 print '--------------- Trying to compile c-extension %s' %filename 363 364 print '--------------------------------------' 365 print 'Trying to compile c-extension %s in %s'\ 366 %(filename, os.getcwd()) 317 367 try: 318 368 if filename == 'triang.c': 319 print "********** Manually doing dependencies **************"320 369 compile(['triang.c','triangle.c']) 321 370 elif filename == 'mesh_engine_c_layer.c': 322 #print "********** Manually doing dependencies **************"323 371 compile(['mesh_engine_c_layer.c','triangle.c']) 324 325 372 else: 326 373 compile(filename) 327 except :328 print 'Could not compile C extension %s' %filename 374 except Exception, e: 375 print 'Could not compile C extension %s' %filename 329 376 else: 330 377 print 'C extension %s OK' %filename
Note: See TracChangeset
for help on using the changeset viewer.