Commit 2e72088e authored by Alex Lubbock's avatar Alex Lubbock

cython_inline compiler directives support

parent b1960185
...@@ -136,8 +136,10 @@ def _populate_unbound(kwds, unbound_symbols, locals=None, globals=None): ...@@ -136,8 +136,10 @@ def _populate_unbound(kwds, unbound_symbols, locals=None, globals=None):
else: else:
print("Couldn't find %r" % symbol) print("Couldn't find %r" % symbol)
def cython_inline(code, get_type=unsafe_type, lib_dir=os.path.join(get_cython_cache_dir(), 'inline'), def cython_inline(code, get_type=unsafe_type,
cython_include_dirs=None, force=False, quiet=False, locals=None, globals=None, **kwds): lib_dir=os.path.join(get_cython_cache_dir(), 'inline'),
cython_include_dirs=None, cython_compiler_directives=None,
force=False, quiet=False, locals=None, globals=None, **kwds):
if get_type is None: if get_type is None:
get_type = lambda x: 'object' get_type = lambda x: 'object'
...@@ -233,7 +235,11 @@ def __invoke(%(params)s): ...@@ -233,7 +235,11 @@ def __invoke(%(params)s):
extra_compile_args = cflags) extra_compile_args = cflags)
if build_extension is None: if build_extension is None:
build_extension = _get_build_extension() build_extension = _get_build_extension()
build_extension.extensions = cythonize([extension], include_path=cython_include_dirs or ['.'], quiet=quiet) build_extension.extensions = cythonize(
[extension],
include_path=cython_include_dirs or ['.'],
compiler_directives=cython_compiler_directives or {},
quiet=quiet)
build_extension.build_temp = os.path.dirname(pyx_file) build_extension.build_temp = os.path.dirname(pyx_file)
build_extension.build_lib = lib_dir build_extension.build_lib = lib_dir
build_extension.run() build_extension.run()
......
...@@ -849,6 +849,14 @@ f'{a * x()}'""" ...@@ -849,6 +849,14 @@ f'{a * x()}'"""
self.assertEqual(f'{d["foo"]}', 'bar') self.assertEqual(f'{d["foo"]}', 'bar')
self.assertEqual(f"{d['foo']}", 'bar') self.assertEqual(f"{d['foo']}", 'bar')
def test_inline_compiler_directives(self):
self.assertEqual(
cy_eval('sum(x)',
x=[1,2,3],
cython_compiler_directives={'boundscheck': False}),
6
)
def __test_backslash_char(self): def __test_backslash_char(self):
# Check eval of a backslash followed by a control char. # Check eval of a backslash followed by a control char.
# See bpo-30682: this used to raise an assert in pydebug mode. # See bpo-30682: this used to raise an assert in pydebug mode.
......
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