X Tutup
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 # 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: compile_time_constants.pxi") with open("../../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 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'./../../extern/', r'./../../extern/cef/', ], 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' 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 )
X Tutup