Changeset 5a91c6b in sasmodels


Ignore:
Timestamp:
May 4, 2016 7:29:22 PM (9 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:
3832f27
Parents:
6ce9048
Message:

reinstate timestamp test unless running in a frozen distribution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    r3ecf034 r5a91c6b  
    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 
    5353from ctypes import c_void_p, c_int, c_longdouble, c_double, c_float 
    54 import _ctypes 
    5554 
    5655import numpy as np 
     
    7978        else: 
    8079            COMPILE = " ".join((CC, LN)) 
    81     elif True:  # Don't use mingw 
     80    elif True: 
     81        # If MSVC compiler is not available, try using mingw 
    8282        # fPIC is not needed on windows 
    8383        COMPILE = "gcc -shared -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 
     
    8585            COMPILE = COMPILE + " -fopenmp" 
    8686    else: 
     87        # If MSVC compiler is not available, try using tinycc 
    8788        from tinycc import TCC 
    8889        COMPILE = TCC + " -shared -rdynamic -Wall %(source)s -o %(output)s" 
     
    151152        tempfile_prefix = 'sas_' + model_info['name'] + '128_' 
    152153  
    153     source = generate.convert_type(source, dtype) 
    154     source_files = generate.model_sources(model_info) + [model_info['filename']] 
    155154    dll = dll_path(model_info, dtype) 
    156155 
    157     #newest = max(os.path.getmtime(f) for f in source_files) 
    158     #if not os.path.exists(dll) or os.path.getmtime(dll) < newest: 
    159156    if not os.path.exists(dll): 
    160         # Replace with a proper temp file 
     157        need_recompile = True 
     158    elif getattr(sys, 'frozen', False): 
     159        # TODO: don't suppress time stamp 
     160        # Currently suppressing recompile when running in a frozen environment 
     161        need_recompile = False 
     162    else: 
     163        dll_time = os.path.getmtime(dll) 
     164        source_files = generate.model_sources(model_info) + [model_info['filename']] 
     165        newest_source = max(os.path.getmtime(f) for f in source_files) 
     166        need_recompile = dll_time < newest_source 
     167    if need_recompile: 
    161168        fid, filename = tempfile.mkstemp(suffix=".c", prefix=tempfile_prefix) 
     169        source = generate.convert_type(source, dtype) 
    162170        os.fdopen(fid, "w").write(source) 
    163171        command = COMPILE%{"source":filename, "output":dll} 
     
    258266            del dll, self.dll 
    259267            self.dll = None 
    260             #_ctypes.FreeLibrary(libHandle) 
    261268            ct.windll.kernel32.FreeLibrary(libHandle) 
    262269        else:     
Note: See TracChangeset for help on using the changeset viewer.