Changes in sasmodels/kerneldll.py [9eb3632:739aad4] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    r9eb3632 r739aad4  
    5757import numpy as np  # type: ignore 
    5858 
     59try: 
     60    import tinycc 
     61except ImportError: 
     62    tinycc = None 
     63 
    5964from . import generate 
    6065from .kernel import KernelModel, Kernel 
     
    7075    pass 
    7176 
    72 if os.name == 'nt': 
    73     ARCH = "" if sys.maxint > 2**32 else "x86"  # maxint=2**31-1 on 32 bit 
    74     # Windows compiler; check if TinyCC is available 
    75     try: 
    76         import tinycc 
    77     except ImportError: 
    78         tinycc = None 
    79     # call vcvarsall.bat before compiling to set path, headers, libs, etc. 
     77if "SAS_COMPILER" in os.environ: 
     78    compiler = os.environ["SAS_COMPILER"] 
     79elif os.name == 'nt': 
     80    # If vcvarsall.bat has been called, then VCINSTALLDIR is in the environment 
     81    # and we can use the MSVC compiler.  Otherwise, if tinycc is available 
     82    # the use it.  Otherwise, hope that mingw is available. 
    8083    if "VCINSTALLDIR" in os.environ: 
    81         # MSVC compiler is available, so use it.  OpenMP requires a copy of 
    82         # vcomp90.dll on the path.  One may be found here: 
    83         #       C:/Windows/winsxs/x86_microsoft.vc90.openmp*/vcomp90.dll 
    84         # Copy this to the python directory and uncomment the OpenMP COMPILE 
    85         # TODO: remove intermediate OBJ file created in the directory 
    86         # TODO: maybe don't use randomized name for the c file 
    87         # TODO: maybe ask distutils to find MSVC 
    88         CC = "cl /nologo /Ox /MD /W3 /GS- /DNDEBUG".split() 
    89         if "SAS_OPENMP" in os.environ: 
    90             CC.append("/openmp") 
    91         LN = "/link /DLL /INCREMENTAL:NO /MANIFEST".split() 
    92         def compile_command(source, output): 
    93             return CC + ["/Tp%s"%source] + LN + ["/OUT:%s"%output] 
     84        compiler = "msvc" 
    9485    elif tinycc: 
    95         # TinyCC compiler. 
    96         CC = [tinycc.TCC] + "-shared -rdynamic -Wall".split() 
    97         def compile_command(source, output): 
    98             return CC + [source, "-o", output] 
     86        compiler = "tinycc" 
    9987    else: 
    100         # MinGW compiler. 
    101         CC = "gcc -shared -std=c99 -O2 -Wall".split() 
    102         if "SAS_OPENMP" in os.environ: 
    103             CC.append("-fopenmp") 
    104         def compile_command(source, output): 
    105             return CC + [source, "-o", output, "-lm"] 
     88        compiler = "mingw" 
    10689else: 
    107     ARCH = "" 
     90    compiler = "unix" 
     91 
     92ARCH = "" if sys.maxint > 2**32 else "x86"  # maxint=2**31-1 on 32 bit 
     93if compiler == "unix": 
    10894    # Generic unix compile 
    10995    # On mac users will need the X code command line tools installed 
     
    11298    # add openmp support if not running on a mac 
    11399    if sys.platform != "darwin": 
     100        CC.append("-fopenmp") 
     101    def compile_command(source, output): 
     102        return CC + [source, "-o", output, "-lm"] 
     103elif compiler == "msvc": 
     104    # Call vcvarsall.bat before compiling to set path, headers, libs, etc. 
     105    # MSVC compiler is available, so use it.  OpenMP requires a copy of 
     106    # vcomp90.dll on the path.  One may be found here: 
     107    #       C:/Windows/winsxs/x86_microsoft.vc90.openmp*/vcomp90.dll 
     108    # Copy this to the python directory and uncomment the OpenMP COMPILE 
     109    # TODO: remove intermediate OBJ file created in the directory 
     110    # TODO: maybe don't use randomized name for the c file 
     111    # TODO: maybe ask distutils to find MSVC 
     112    CC = "cl /nologo /Ox /MD /W3 /GS- /DNDEBUG".split() 
     113    if "SAS_OPENMP" in os.environ: 
     114        CC.append("/openmp") 
     115    LN = "/link /DLL /INCREMENTAL:NO /MANIFEST".split() 
     116    def compile_command(source, output): 
     117        return CC + ["/Tp%s"%source] + LN + ["/OUT:%s"%output] 
     118elif compiler == "tinycc": 
     119    # TinyCC compiler. 
     120    CC = [tinycc.TCC] + "-shared -rdynamic -Wall".split() 
     121    def compile_command(source, output): 
     122        return CC + [source, "-o", output] 
     123elif compiler == "mingw": 
     124    # MinGW compiler. 
     125    CC = "gcc -shared -std=c99 -O2 -Wall".split() 
     126    if "SAS_OPENMP" in os.environ: 
    114127        CC.append("-fopenmp") 
    115128    def compile_command(source, output): 
Note: See TracChangeset for help on using the changeset viewer.