Changeset da63656 in sasmodels for sasmodels/kerneldll.py
- Timestamp:
- May 4, 2016 9:37:42 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 24d5b30
- Parents:
- 13b99fd (diff), 47e498b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kerneldll.py
r13b99fd rda63656 48 48 import sys 49 49 import os 50 from os.path import join as joinpath, split as splitpath, realpath,splitext50 from os.path import join as joinpath, split as splitpath, splitext 51 51 import tempfile 52 52 import ctypes as ct # type: ignore … … 87 87 else: 88 88 COMPILE = " ".join((CC, LN)) 89 elif True: # Don't use mingw 89 elif True: 90 # If MSVC compiler is not available, try using mingw 90 91 # fPIC is not needed on windows 91 92 COMPILE = "gcc -shared -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" … … 93 94 COMPILE += " -fopenmp" 94 95 else: 96 # If MSVC compiler is not available, try using tinycc 95 97 from tinycc import TCC 96 98 COMPILE = TCC + " -shared -rdynamic -Wall %(source)s -o %(output)s" … … 98 100 COMPILE = "cc -shared -fPIC -fopenmp -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 99 101 100 # Assume the default location of module DLLs is in top level /models dir. 101 DLL_PATH = joinpath(splitpath(realpath(sys.argv[0]))[0], "models") 102 # Windows-specific solution 103 if os.name == 'nt': 104 # Assume the default location of module DLLs is in .sasmodels/compiled_models. 105 DLL_PATH = os.path.join(os.path.expanduser("~"), ".sasmodels", "compiled_models") 106 if not os.path.exists(DLL_PATH): 107 os.makedirs(DLL_PATH) 108 else: 109 # Set up the default path for compiled modules. 110 DLL_PATH = tempfile.gettempdir() 102 111 103 112 ALLOW_SINGLE_PRECISION_DLLS = True … … 111 120 """ 112 121 bits = 8*dtype.itemsize 113 return "sas _%s%d"%(model_info.id, bits)122 return "sas%d_%s"%(bits, model_info.id) 114 123 115 124 … … 148 157 # Note: dtype may be F128 for long double precision 149 158 150 newest = generate.timestamp(model_info)151 159 dll = dll_path(model_info, dtype) 152 if not os.path.exists(dll) or os.path.getmtime(dll) < newest: 160 161 if not os.path.exists(dll): 162 need_recompile = True 163 elif getattr(sys, 'frozen', False): 164 # TODO: don't suppress time stamp 165 # Currently suppressing recompile when running in a frozen environment 166 need_recompile = False 167 else: 168 dll_time = os.path.getmtime(dll) 169 newest_source = generate.timestamp(model_info) 170 need_recompile = dll_time < newest_source 171 if need_recompile: 153 172 basename = dll_name(model_info, dtype) + "_" 154 173 fid, filename = tempfile.mkstemp(suffix=".c", prefix=basename) … … 251 270 del dll, self._dll 252 271 self._dll = None 253 #_ctypes.FreeLibrary(libHandle)254 272 ct.windll.kernel32.FreeLibrary(libHandle) 255 273 else:
Note: See TracChangeset
for help on using the changeset viewer.