1 """Pyrex.Distutils.extension
3 Provides a modified Extension class, that understands how to describe
4 Pyrex extension modules in setup scripts."""
9 import distutils
.extension
as _Extension
17 class Extension(_Extension
.Extension
):
18 # When adding arguments to this constructor, be sure to update
19 # user_options.extend in build_ext.py.
20 def __init__(self
, name
, sources
,
26 runtime_library_dirs
=None,
28 extra_compile_args
=None,
34 cython_include_dirs
=None,
35 cython_directives
=None,
36 cython_create_listing
=False,
37 cython_line_directives
=False,
39 cython_c_in_temp
=False,
42 no_c_in_traceback
=False,
43 cython_compile_time_env
=None,
46 # Translate pyrex_X to cython_X for backwards compatibility.
47 had_pyrex_options
= False
49 if key
.startswith('pyrex_'):
50 had_pyrex_options
= True
51 kw
['cython' + key
[5:]] = kw
.pop(key
)
55 include_dirs
=include_dirs
,
56 define_macros
=define_macros
,
57 undef_macros
=undef_macros
,
58 library_dirs
=library_dirs
,
60 runtime_library_dirs
=runtime_library_dirs
,
61 extra_objects
=extra_objects
,
62 extra_compile_args
=extra_compile_args
,
63 extra_link_args
=extra_link_args
,
64 export_symbols
=export_symbols
,
68 no_c_in_traceback
=no_c_in_traceback
,
72 _Extension
.Extension
.__init
__(
74 include_dirs
=include_dirs
,
75 define_macros
=define_macros
,
76 undef_macros
=undef_macros
,
77 library_dirs
=library_dirs
,
79 runtime_library_dirs
=runtime_library_dirs
,
80 extra_objects
=extra_objects
,
81 extra_compile_args
=extra_compile_args
,
82 extra_link_args
=extra_link_args
,
83 export_symbols
=export_symbols
,
89 self
.cython_include_dirs
= cython_include_dirs
or []
90 self
.cython_directives
= cython_directives
or {}
91 self
.cython_create_listing
= cython_create_listing
92 self
.cython_line_directives
= cython_line_directives
93 self
.cython_cplus
= cython_cplus
94 self
.cython_c_in_temp
= cython_c_in_temp
95 self
.cython_gen_pxi
= cython_gen_pxi
96 self
.cython_gdb
= cython_gdb
97 self
.no_c_in_traceback
= no_c_in_traceback
98 self
.cython_compile_time_env
= cython_compile_time_env
102 read_setup_file
= _Extension
.read_setup_file
105 # reuse and extend original docstring from base class (if we can)
106 if sys
.version_info
[0] < 3 and _Extension
.Extension
.__doc
__:
107 # -OO discards docstrings
108 Extension
.__doc
__ = _Extension
.Extension
.__doc
__ + """\
109 cython_include_dirs : [string]
110 list of directories to search for Pyrex header files (.pxd) (in
111 Unix form for portability)
112 cython_directives : {string:value}
113 dict of compiler directives
114 cython_create_listing_file : boolean
115 write pyrex error messages to a listing (.lis) file.
116 cython_line_directives : boolean
117 emit pyx line numbers for debugging/profiling
118 cython_cplus : boolean
119 use the C++ compiler for compiling and linking.
120 cython_c_in_temp : boolean
121 put generated C files in temp directory.
122 cython_gen_pxi : boolean
123 generate .pxi file for public declarations
125 generate Cython debug information for this extension for cygdb
126 no_c_in_traceback : boolean
127 emit the c file and line number from the traceback for exceptions