201
201
unavailable_files = []
204
def add_pyrex_extension(module_name, **kwargs):
204
def add_pyrex_extension(module_name, define_macros=[], **kwargs):
205
205
"""Add a pyrex module to build.
207
207
This will use Pyrex to auto-generate the .c file if it is available.
217
217
path = module_name.replace('.', '/')
218
218
pyrex_name = path + '.pyx'
219
219
c_name = path + '.c'
220
if sys.platform == 'win32':
221
# pyrex uses the macro WIN32 to detect the platform, even though it should
222
# be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
224
define_macros.append(('WIN32', None))
221
ext_modules.append(Extension(module_name, [pyrex_name], **kwargs))
226
ext_modules.append(Extension(module_name, [pyrex_name],
227
define_macros=define_macros, **kwargs))
223
229
if not os.path.isfile(c_name):
224
230
unavailable_files.append(c_name)
226
ext_modules.append(Extension(module_name, [c_name], **kwargs))
232
ext_modules.append(Extension(module_name, [c_name],
233
define_macros=define_macros, **kwargs))
236
add_pyrex_extension('bzrlib._btree_serializer_c')
229
237
add_pyrex_extension('bzrlib._knit_load_data_c')
230
238
if sys.platform == 'win32':
231
# pyrex uses the macro WIN32 to detect the platform, even though it should
232
# be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
234
add_pyrex_extension('bzrlib._btree_serializer_c',
235
define_macros=[('WIN32', None)])
236
239
add_pyrex_extension('bzrlib._dirstate_helpers_c',
237
libraries=['Ws2_32'],
238
define_macros=[('WIN32', None)],
240
add_pyrex_extension('bzrlib._walkdirs_win32',
241
define_macros=[('WIN32', None)])
240
libraries=['Ws2_32'])
241
add_pyrex_extension('bzrlib._walkdirs_win32')
243
add_pyrex_extension('bzrlib._btree_serializer_c')
244
243
if have_pyrex and pyrex_version == '0.9.4.1':
245
244
# Pyrex 0.9.4.1 fails to compile this extension correctly
246
245
# The code it generates re-uses a "local" pointer and