Changeset da63656 in sasmodels for sasmodels/kerneldll.py


Ignore:
Timestamp:
May 4, 2016 9:37:42 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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.
Message:

Merge branch 'master' into polydisp

Conflicts:

sasmodels/generate.py
sasmodels/kerneldll.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    r13b99fd rda63656  
    4848import sys 
    4949import os 
    50 from os.path import join as joinpath, split as splitpath, realpath, splitext 
     50from os.path import join as joinpath, split as splitpath, splitext 
    5151import tempfile 
    5252import ctypes as ct  # type: ignore 
     
    8787        else: 
    8888            COMPILE = " ".join((CC, LN)) 
    89     elif True:  # Don't use mingw 
     89    elif True: 
     90        # If MSVC compiler is not available, try using mingw 
    9091        # fPIC is not needed on windows 
    9192        COMPILE = "gcc -shared -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 
     
    9394            COMPILE += " -fopenmp" 
    9495    else: 
     96        # If MSVC compiler is not available, try using tinycc 
    9597        from tinycc import TCC 
    9698        COMPILE = TCC + " -shared -rdynamic -Wall %(source)s -o %(output)s" 
     
    98100    COMPILE = "cc -shared -fPIC -fopenmp -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 
    99101 
    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 
     103if 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) 
     108else: 
     109    # Set up the default path for compiled modules. 
     110    DLL_PATH = tempfile.gettempdir() 
    102111 
    103112ALLOW_SINGLE_PRECISION_DLLS = True 
     
    111120    """ 
    112121    bits = 8*dtype.itemsize 
    113     return "sas_%s%d"%(model_info.id, bits) 
     122    return "sas%d_%s"%(bits, model_info.id) 
    114123 
    115124 
     
    148157    # Note: dtype may be F128 for long double precision 
    149158 
    150     newest = generate.timestamp(model_info) 
    151159    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: 
    153172        basename = dll_name(model_info, dtype) + "_" 
    154173        fid, filename = tempfile.mkstemp(suffix=".c", prefix=basename) 
     
    251270            del dll, self._dll 
    252271            self._dll = None 
    253             #_ctypes.FreeLibrary(libHandle) 
    254272            ct.windll.kernel32.FreeLibrary(libHandle) 
    255273        else:     
Note: See TracChangeset for help on using the changeset viewer.