Commit 9361decf authored by Robert Bradshaw's avatar Robert Bradshaw Committed by GitHub

Merge pull request #1579 from karlkempe/master

Add --src flag to add c/c++ src files (cythonmagic)
parents d02cc4c5 57cc7cd2
...@@ -188,6 +188,11 @@ class CythonMagics(Magics): ...@@ -188,6 +188,11 @@ class CythonMagics(Magics):
help="Add a path to the list of include directories (can be specified " help="Add a path to the list of include directories (can be specified "
"multiple times)." "multiple times)."
) )
@magic_arguments.argument(
'-S', '--src', action='append', default=[],
help="Add a path to the list of src files (can be specified "
"multiple times)."
)
@magic_arguments.argument( @magic_arguments.argument(
'-+', '--cplus', action='store_true', default=False, '-+', '--cplus', action='store_true', default=False,
help="Output a C++ rather than C file." help="Output a C++ rather than C file."
...@@ -252,6 +257,7 @@ class CythonMagics(Magics): ...@@ -252,6 +257,7 @@ class CythonMagics(Magics):
if need_cythonize: if need_cythonize:
c_include_dirs = args.include c_include_dirs = args.include
c_src_files = map(str, args.src)
if 'numpy' in code: if 'numpy' in code:
import numpy import numpy
c_include_dirs.append(numpy.get_include()) c_include_dirs.append(numpy.get_include())
...@@ -261,7 +267,7 @@ class CythonMagics(Magics): ...@@ -261,7 +267,7 @@ class CythonMagics(Magics):
f.write(code) f.write(code)
extension = Extension( extension = Extension(
name = module_name, name = module_name,
sources = [pyx_file], sources = [pyx_file] + c_src_files,
include_dirs = c_include_dirs, include_dirs = c_include_dirs,
library_dirs = args.library_dirs, library_dirs = args.library_dirs,
extra_compile_args = args.compile_args, extra_compile_args = args.compile_args,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment