extension.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. """Pyrex.Distutils.extension
  2. Provides a modified Extension class, that understands how to describe
  3. Pyrex extension modules in setup scripts."""
  4. __revision__ = "$Id:$"
  5. import sys
  6. import distutils.extension as _Extension
  7. try:
  8. import warnings
  9. except ImportError:
  10. warnings = None
  11. class Extension(_Extension.Extension):
  12. # When adding arguments to this constructor, be sure to update
  13. # user_options.extend in build_ext.py.
  14. def __init__(self, name, sources,
  15. include_dirs=None,
  16. define_macros=None,
  17. undef_macros=None,
  18. library_dirs=None,
  19. libraries=None,
  20. runtime_library_dirs=None,
  21. extra_objects=None,
  22. extra_compile_args=None,
  23. extra_link_args=None,
  24. export_symbols=None,
  25. #swig_opts=None,
  26. depends=None,
  27. language=None,
  28. cython_include_dirs=None,
  29. cython_directives=None,
  30. cython_create_listing=False,
  31. cython_line_directives=False,
  32. cython_cplus=False,
  33. cython_c_in_temp=False,
  34. cython_gen_pxi=False,
  35. cython_gdb=False,
  36. no_c_in_traceback=False,
  37. cython_compile_time_env=None,
  38. **kw):
  39. # Translate pyrex_X to cython_X for backwards compatibility.
  40. had_pyrex_options = False
  41. for key in list(kw):
  42. if key.startswith('pyrex_'):
  43. had_pyrex_options = True
  44. kw['cython' + key[5:]] = kw.pop(key)
  45. if had_pyrex_options:
  46. Extension.__init__(
  47. self, name, sources,
  48. include_dirs=include_dirs,
  49. define_macros=define_macros,
  50. undef_macros=undef_macros,
  51. library_dirs=library_dirs,
  52. libraries=libraries,
  53. runtime_library_dirs=runtime_library_dirs,
  54. extra_objects=extra_objects,
  55. extra_compile_args=extra_compile_args,
  56. extra_link_args=extra_link_args,
  57. export_symbols=export_symbols,
  58. #swig_opts=swig_opts,
  59. depends=depends,
  60. language=language,
  61. no_c_in_traceback=no_c_in_traceback,
  62. **kw)
  63. return
  64. _Extension.Extension.__init__(
  65. self, name, sources,
  66. include_dirs=include_dirs,
  67. define_macros=define_macros,
  68. undef_macros=undef_macros,
  69. library_dirs=library_dirs,
  70. libraries=libraries,
  71. runtime_library_dirs=runtime_library_dirs,
  72. extra_objects=extra_objects,
  73. extra_compile_args=extra_compile_args,
  74. extra_link_args=extra_link_args,
  75. export_symbols=export_symbols,
  76. #swig_opts=swig_opts,
  77. depends=depends,
  78. language=language,
  79. **kw)
  80. self.cython_include_dirs = cython_include_dirs or []
  81. self.cython_directives = cython_directives or {}
  82. self.cython_create_listing = cython_create_listing
  83. self.cython_line_directives = cython_line_directives
  84. self.cython_cplus = cython_cplus
  85. self.cython_c_in_temp = cython_c_in_temp
  86. self.cython_gen_pxi = cython_gen_pxi
  87. self.cython_gdb = cython_gdb
  88. self.no_c_in_traceback = no_c_in_traceback
  89. self.cython_compile_time_env = cython_compile_time_env
  90. # class Extension
  91. read_setup_file = _Extension.read_setup_file
  92. # reuse and extend original docstring from base class (if we can)
  93. if sys.version_info[0] < 3 and _Extension.Extension.__doc__:
  94. # -OO discards docstrings
  95. Extension.__doc__ = _Extension.Extension.__doc__ + """\
  96. cython_include_dirs : [string]
  97. list of directories to search for Pyrex header files (.pxd) (in
  98. Unix form for portability)
  99. cython_directives : {string:value}
  100. dict of compiler directives
  101. cython_create_listing_file : boolean
  102. write pyrex error messages to a listing (.lis) file.
  103. cython_line_directives : boolean
  104. emit pyx line numbers for debugging/profiling
  105. cython_cplus : boolean
  106. use the C++ compiler for compiling and linking.
  107. cython_c_in_temp : boolean
  108. put generated C files in temp directory.
  109. cython_gen_pxi : boolean
  110. generate .pxi file for public declarations
  111. cython_gdb : boolean
  112. generate Cython debug information for this extension for cygdb
  113. no_c_in_traceback : boolean
  114. emit the c file and line number from the traceback for exceptions
  115. """