Commit 083cceb6 authored by Chuck Blake's avatar Chuck Blake

Add pyrex_directives dictionary optional attribute of Extension objects to

support distutils/setup.py-based directives setting.
parent 482734b7
......@@ -44,6 +44,8 @@ class build_ext(_build_ext.build_ext):
"put generated C files in temp directory"),
('pyrex-gen-pxi', None,
"generate .pxi file for public declarations"),
('pyrex-directives=', None,
"compiler directive overrides"),
])
boolean_options.extend([
......@@ -56,6 +58,7 @@ class build_ext(_build_ext.build_ext):
self.pyrex_create_listing = 0
self.pyrex_line_directives = 0
self.pyrex_include_dirs = None
self.pyrex_directives = None
self.pyrex_c_in_temp = 0
self.pyrex_gen_pxi = 0
......@@ -66,6 +69,8 @@ class build_ext(_build_ext.build_ext):
elif type(self.pyrex_include_dirs) is StringType:
self.pyrex_include_dirs = \
self.pyrex_include_dirs.split(os.pathsep)
if self.pyrex_directives is None:
self.pyrex_directives = {}
# finalize_options ()
def build_extensions(self):
......@@ -139,6 +144,13 @@ class build_ext(_build_ext.build_ext):
if not i in includes:
includes.append(i)
# Set up Cython compiler directives:
# 1. Start with the command line option.
# 2. Add in any (unique) entries from the extension
# pyrex_directives (if Cython.Distutils.extension is used).
directives = self.pyrex_directives
directives.update(extension.pyrex_directives)
# Set the target_ext to '.c'. Cython will change this to '.cpp' if
# needed.
if cplus:
......@@ -189,6 +201,7 @@ class build_ext(_build_ext.build_ext):
options = CompilationOptions(pyrex_default_options,
use_listing_file = create_listing,
include_path = includes,
compiler_directives = directives,
output_file = target,
cplus = cplus,
emit_linenums = line_directives,
......
......@@ -19,6 +19,8 @@ class Extension(_Extension.Extension):
"""pyrex_include_dirs : [string]
list of directories to search for Pyrex header files (.pxd) (in
Unix form for portability)
pyrex_directives : {string:value}
dict of compiler directives
pyrex_create_listing_file : boolean
write pyrex error messages to a listing (.lis) file.
pyrex_line_directivess : boolean
......@@ -48,6 +50,7 @@ class Extension(_Extension.Extension):
depends = None,
language = None,
pyrex_include_dirs = None,
pyrex_directives = None,
pyrex_create_listing = 0,
pyrex_line_directives = 0,
pyrex_cplus = 0,
......@@ -72,6 +75,7 @@ class Extension(_Extension.Extension):
**kw)
self.pyrex_include_dirs = pyrex_include_dirs or []
self.pyrex_directives = pyrex_directives or {}
self.pyrex_create_listing = pyrex_create_listing
self.pyrex_line_directives = pyrex_line_directives
self.pyrex_cplus = pyrex_cplus
......
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