##// END OF EJS Templates
Add support for libraries, include path and compiler args to %%cython...
Fernando Perez -
Show More
@@ -107,6 +107,18 b' class CythonMagics(Magics):'
107
107
108 @magic_arguments()
108 @magic_arguments()
109 @argument(
109 @argument(
110 '-c', '--compile-args', action='append', default=[],
111 help="Extra flag to pass to compiler via the `extra_compile_args` Extension flag (can be called multiple times)."
112 )
113 @argument(
114 '-l', '--lib', action='append', default=[],
115 help="Add a library to link the extension against (can be called multiple times)."
116 )
117 @argument(
118 '-i', '--include', action='append', default=[],
119 help="Add a path to the list of include directories (can be called multiple times)."
120 )
121 @argument(
110 '-f', '--force', action='store_true', default=False,
122 '-f', '--force', action='store_true', default=False,
111 help="Force the compilation of the pyx module even if it hasn't changed"
123 help="Force the compilation of the pyx module even if it hasn't changed"
112 )
124 )
@@ -141,8 +153,7 b' class CythonMagics(Magics):'
141 os.makedirs(lib_dir)
153 os.makedirs(lib_dir)
142
154
143 if force or not os.path.isfile(module_path):
155 if force or not os.path.isfile(module_path):
144 cflags = []
156 c_include_dirs = args.include
145 c_include_dirs = []
146 if 'numpy' in code:
157 if 'numpy' in code:
147 import numpy
158 import numpy
148 c_include_dirs.append(numpy.get_include())
159 c_include_dirs.append(numpy.get_include())
@@ -154,7 +165,8 b' class CythonMagics(Magics):'
154 name = module_name,
165 name = module_name,
155 sources = [pyx_file],
166 sources = [pyx_file],
156 include_dirs = c_include_dirs,
167 include_dirs = c_include_dirs,
157 extra_compile_args = cflags
168 extra_compile_args = args.compile_args,
169 libraries = args.lib,
158 )
170 )
159 dist = Distribution()
171 dist = Distribution()
160 config_files = dist.find_config_files()
172 config_files = dist.find_config_files()
General Comments 0
You need to be logged in to leave comments. Login now