Changeset 739aad4 in sasmodels for sasmodels/kerneldll.py


Ignore:
Timestamp:
Jul 27, 2016 4:18:18 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:
0c24a82
Parents:
df776db
Message:

change method for selecting a particular compiler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    rdf776db 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         if "DONT_USE_TINYCC" in os.environ: 
    78             tinycc = None 
    79     except ImportError: 
    80         tinycc = None 
    81     # 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. 
    8283    if "VCINSTALLDIR" in os.environ: 
    83         # MSVC compiler is available, so use it.  OpenMP requires a copy of 
    84         # vcomp90.dll on the path.  One may be found here: 
    85         #       C:/Windows/winsxs/x86_microsoft.vc90.openmp*/vcomp90.dll 
    86         # Copy this to the python directory and uncomment the OpenMP COMPILE 
    87         # TODO: remove intermediate OBJ file created in the directory 
    88         # TODO: maybe don't use randomized name for the c file 
    89         # TODO: maybe ask distutils to find MSVC 
    90         CC = "cl /nologo /Ox /MD /W3 /GS- /DNDEBUG".split() 
    91         if "SAS_OPENMP" in os.environ: 
    92             CC.append("/openmp") 
    93         LN = "/link /DLL /INCREMENTAL:NO /MANIFEST".split() 
    94         def compile_command(source, output): 
    95             return CC + ["/Tp%s"%source] + LN + ["/OUT:%s"%output] 
     84        compiler = "msvc" 
    9685    elif tinycc: 
    97         # TinyCC compiler. 
    98         CC = [tinycc.TCC] + "-shared -rdynamic -Wall".split() 
    99         def compile_command(source, output): 
    100             return CC + [source, "-o", output] 
     86        compiler = "tinycc" 
    10187    else: 
    102         # MinGW compiler. 
    103         CC = "gcc -shared -std=c99 -O2 -Wall".split() 
    104         if "SAS_OPENMP" in os.environ: 
    105             CC.append("-fopenmp") 
    106         def compile_command(source, output): 
    107             return CC + [source, "-o", output, "-lm"] 
     88        compiler = "mingw" 
    10889else: 
    109     ARCH = "" 
     90    compiler = "unix" 
     91 
     92ARCH = "" if sys.maxint > 2**32 else "x86"  # maxint=2**31-1 on 32 bit 
     93if compiler == "unix": 
    11094    # Generic unix compile 
    11195    # On mac users will need the X code command line tools installed 
     
    11498    # add openmp support if not running on a mac 
    11599    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: 
    116127        CC.append("-fopenmp") 
    117128    def compile_command(source, output): 
Note: See TracChangeset for help on using the changeset viewer.