forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
118 lines (98 loc) · 3.66 KB
/
setup.py
File metadata and controls
118 lines (98 loc) · 3.66 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Compiler import Options
import Cython
import sys
import platform
import struct
import os
BITS = str(8 * struct.calcsize('P')) + "bit"
print("[setup.py] Python architecture: %s" % BITS)
print("[setup.py] Cython version: %s" % Cython.__version__)
# Stop on first error, otherwise hundreds of errors appear in the console.
Options.fast_fail = True
# Written to cython_includes/compile_time_constants.pxi
CEF_VERSION = 3
# Python version string: "27" or "32".
PYVER = str(sys.version_info.major) + str(sys.version_info.minor)
# Generate compile_time_constants.pxi
def CompileTimeConstants():
print("[setup.py] Generating: cython_includes/compile_time_constants.pxi")
with open("../../../cython_includes/compile_time_constants.pxi", "w") as fd:
fd.write('# This file was generated by setup.py\n')
# A way around Python 3.2 bug: UNAME_SYSNAME is not set.
fd.write('DEF UNAME_SYSNAME = "%s"\n' % platform.uname()[0])
fd.write('DEF CEF_VERSION = %s\n' % CEF_VERSION)
fd.write('DEF PY_MAJOR_VERSION = %s\n' % sys.version_info.major)
CompileTimeConstants()
# Windows SDK Lib directory.
# It's also hardcoded in compile.bat
if BITS == "32bit":
winsdk_lib = r"C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib"
elif BITS == "64bit":
winsdk_lib = r"C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\x64"
if not os.path.exists(winsdk_lib):
raise Exception("Windows SDK Lib directory not found: %s" % winsdk_lib)
ext_modules = [Extension(
"cefpython_py%s" % PYVER,
["cefpython.pyx"],
# Ignore the warning in the console:
# > C:\Python27\lib\distutils\extension.py:133: UserWarning:
# > Unknown Extension options: 'cython_directives' warnings.warn(msg)
cython_directives={
# Any conversion to unicode must be explicit using .decode().
"c_string_type": "bytes",
"c_string_encoding": "utf-8",
},
language='c++',
include_dirs=[
r'./../',
r'./../../',
r'./../../../',
r'./../../../cython_includes/'],
library_dirs=[
winsdk_lib,
r'./',
r'./lib_%s' % (BITS),
r'./../../client_handler/Release_py%s_%s/' % (PYVER, BITS),
r'./../../subprocess/Release_py%s_%s/' % (PYVER, BITS),
r'./../../../cpp_utils/Release_%s/' % (BITS),
],
libraries=[
'libcef',
'libcef_dll_wrapper_md',
'User32',
'client_handler_py%s_%s' % (PYVER, BITS),
'libcefpythonapp_py%s_%s' % (PYVER, BITS),
'cpp_utils_%s' % (BITS),
],
extra_objects=[
"cefpython.res"
],
# /EHsc - using STL string, multimap and others that use C++ exceptions.
#
# /ignore:4217 - disable warnings such as this:
#
# client_handler_py27_32bit.lib(client_handler.obj) : warning LNK4217:
# locally defined symbol _RemovePythonCallbacksForFrame imported in
# function "public: virtual bool __thiscall
# ClientHandler::OnProcessMessageReceived
#
# The above warning LNK4217 is caused by the warning below which occurs
# when building the client_handler.lib static library:
#
# cefpython.h(36) : warning C4190: 'RequestHandler_GetResourceHandler'
# has C-linkage specified, but returns UDT 'CefRefPtr<T>' which is
# incompatible with C
#
# The C4190 warning is disabled with pragma in cefpython.h, see the
# fix_cefpython_h.py script.
extra_compile_args=['/EHsc'],
extra_link_args=['/ignore:4217']
)]
setup(
name = 'cefpython_py%s' % PYVER,
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)