FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

# Copyright (c) 2017 CEF Python, see the Authors file. # All rights reserved. Licensed under BSD 3-clause license. # Project website: https://github.com/cztomczak/cefpython """ cython_setup.py is for internal use only - called by build.py. This is Cython's setup for building the cefpython module """ # Use setuptools so that "Visual C++ compiler for Python 2.7" tools # can be used. Otherwise "Unable to find vcvarsall.bat" error occurs. try: from setuptools import setup from setuptools import Extension except ImportError: from distutils.core import setup from distutils.extension import Extension # Use "Extension" from Cython.Distutils so that "cython_directives" works from Cython.Distutils import build_ext, Extension from Cython.Compiler import Options # noinspection PyUnresolvedReferences from Cython.Compiler.ModuleNode import ModuleNode from common import * import sys import platform import Cython import os # Must monkey patch Cython's ModuleNode to inject custom C++ code # in the generated cefpython.cpp. This is a fix for an error on Mac: # > ImportError: dynamic module does not define init function # To get rid of CEF's undefined symbol error when importing module # it was required to pass "-fvisibility=hidden" and "-Wl,-dead_strip" # flags. However these flags cause the "initcefpython_py27" Python # Module Initialization function to be hidden as well. To workaround # this it is required to add default visibility attribute to the # signature of that init function. # # Original definition in Python 2.7: # | https://github.com/python/cpython/blob/2.7/Include/pyport.h # > define PyMODINIT_FUNC extern "C" __declspec(dllexport) void # # Original definition in Python 3.4 / 3.5 / 3.6: # > define PyMODINIT_FUNC extern "C" __declspec(dllexport) PyObject* if MAC: g_generate_extern_c_macro_definition_old = ( ModuleNode.generate_extern_c_macro_definition) def generate_extern_c_macro_definition(self, code): # This code is written by Cython to both cefpython API header file # and cefpython module cpp file. g_generate_extern_c_macro_definition_old(self, code) code.putln("// Added by: cefpython/tools/cython_setup.py") code.putln("#undef PyMODINIT_FUNC") if sys.version_info[:2] == (2, 7): code.putln("#define PyMODINIT_FUNC extern \"C\"" " __attribute__((visibility(\"default\"))) void") else: code.putln("#define PyMODINIT_FUNC extern \"C\"" " __attribute__((visibility(\"default\"))) PyObject*") # Overwrite Cython function ModuleNode.generate_extern_c_macro_definition = ( generate_extern_c_macro_definition) # Constants FAST_FLAG = False # Cython options. Stop on first error, otherwise hundreds # of errors appear in the console. Options.fast_fail = True def main(): print("[cython_setup.py] Python version: {ver} {arch}" .format(ver=platform.python_version(), arch=ARCH_STR)) print("[cython_setup.py] Python executable: %s" % sys.executable) print("[cython_setup.py] Cython version: %s" % Cython.__version__) global FAST_FLAG if len(sys.argv) > 1 and "--fast" in sys.argv: # Fast mode disables optimization flags print("[cython_setup.py] FAST mode enabled") FAST_FLAG = True sys.argv.remove("--fast") if len(sys.argv)

Back | FazBrowse Home | New Git URL