forked from jobovy/galpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__intelcompiler.py
83 lines (68 loc) · 2.6 KB
/
__intelcompiler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#############################################################################
# Setup Intel Compiler
# Please notice it only supports Visual Studio 2015 or later
#############################################################################
import platform
from distutils import ccompiler
from distutils.ccompiler import * # nopycln: import
if platform.system() == "Windows": # to prevent linux import error
from distutils._msvccompiler import MSVCCompiler, _find_exe
else:
raise OSError("You are not using Windows, so you should not import this file")
class Intel64CompilerW(MSVCCompiler):
"""
A modified Intel compiler compatible with an MSVC-built Python.
Only need to define the Windows one because Linux one is imported from distutils
"""
compiler_type = "intel64w"
compiler_cxx = "icl"
def __init__(self, verbose=0, dry_run=0, force=0):
MSVCCompiler.__init__(self, verbose, dry_run, force)
def initialize(self, plat_name=None):
MSVCCompiler.initialize(self)
self.cc = _find_exe("icl.exe")
self.lib = _find_exe("xilib.exe")
self.linker = _find_exe("xilink.exe")
self.compile_options = ["/nologo", "/O3", "/MD", "/W3", "/Qstd=c99"]
self.compile_options_debug = [
"/nologo",
"/Od",
"/MDd",
"/W3",
"/Qstd=c99",
"/Z7",
"/D_DEBUG",
]
compiler_class["intel64w"] = (
"__intelcompiler",
"Intel64CompilerW",
"Intel C Compiler for 64-bit applications on Windows",
)
ccompiler._default_compilers += ("nt", "intel64w")
_distutils_new_compiler = new_compiler
def new_compiler(plat=os.name, compiler=None, verbose=0, dry_run=0, force=0):
"""
make new compiler and pass it to distutils
dont delete verbose even not using it, distutils expects it
"""
try:
if compiler is None:
compiler = get_default_compiler(plat)
(module_name, class_name, long_description) = compiler_class[compiler]
except KeyError:
msg = "don't know how to compile C/C++ code on platform '%s'" % plat
if compiler is not None:
msg = msg + " with '%s' compiler" % compiler
raise DistutilsPlatformError(msg)
try:
__import__(module_name)
except ImportError:
# go back to default compiler
__import__("distutils." + module_name)
module_name = "distutils." + module_name
module = sys.modules[module_name]
klass = vars(module)[class_name]
# dryrun compiler
compiler = klass(None, dry_run, force)
return compiler
ccompiler.new_compiler = new_compiler