Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / cython / src / Tools / site_scons / site_tools / cython.py
blob40af7bb8db736e53da292cecffa3dd52876b3af9
1 """
2 Tool to run Cython files (.pyx) into .c and .cpp.
4 TODO:
5 - Add support for dynamically selecting in-process Cython
6 through CYTHONINPROCESS variable.
7 - Have a CYTHONCPP option which turns on C++ in flags and
8 changes output extension at the same time
10 VARIABLES:
11 - CYTHON - The path to the "cython" command line tool.
12 - CYTHONFLAGS - Flags to pass to the "cython" command line tool.
14 AUTHORS:
15 - David Cournapeau
16 - Dag Sverre Seljebotn
18 """
19 import SCons
20 from SCons.Builder import Builder
21 from SCons.Action import Action
23 #def cython_action(target, source, env):
24 # print target, source, env
25 # from Cython.Compiler.Main import compile as cython_compile
26 # res = cython_compile(str(source[0]))
28 cythonAction = Action("$CYTHONCOM")
30 def create_builder(env):
31 try:
32 cython = env['BUILDERS']['Cython']
33 except KeyError:
34 cython = SCons.Builder.Builder(
35 action = cythonAction,
36 emitter = {},
37 suffix = cython_suffix_emitter,
38 single_source = 1)
39 env['BUILDERS']['Cython'] = cython
41 return cython
43 def cython_suffix_emitter(env, source):
44 return "$CYTHONCFILESUFFIX"
46 def generate(env):
47 env["CYTHON"] = "cython"
48 env["CYTHONCOM"] = "$CYTHON $CYTHONFLAGS -o $TARGET $SOURCE"
49 env["CYTHONCFILESUFFIX"] = ".c"
51 c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
53 c_file.suffix['.pyx'] = cython_suffix_emitter
54 c_file.add_action('.pyx', cythonAction)
56 c_file.suffix['.py'] = cython_suffix_emitter
57 c_file.add_action('.py', cythonAction)
59 create_builder(env)
61 def exists(env):
62 try:
63 # import Cython
64 return True
65 except ImportError:
66 return False