224
224
unavailable_files = []
227
def add_pyrex_extension(module_name, **kwargs):
227
def add_pyrex_extension(module_name, libraries=None):
228
228
"""Add a pyrex module to build.
230
230
This will use Pyrex to auto-generate the .c file if it is available.
240
240
path = module_name.replace('.', '/')
241
241
pyrex_name = path + '.pyx'
242
242
c_name = path + '.c'
244
if sys.platform == 'win32':
245
# pyrex uses the macro WIN32 to detect the platform, even though it should
246
# be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
248
define_macros.append(('WIN32', None))
244
ext_modules.append(Extension(module_name, [pyrex_name], **kwargs))
250
ext_modules.append(Extension(module_name, [pyrex_name],
251
define_macros=define_macros, libraries=libraries))
246
253
if not os.path.isfile(c_name):
247
254
unavailable_files.append(c_name)
249
ext_modules.append(Extension(module_name, [c_name], **kwargs))
256
ext_modules.append(Extension(module_name, [c_name],
257
define_macros=define_macros, libraries=libraries))
252
260
add_pyrex_extension('bzrlib._btree_serializer_c')
253
261
add_pyrex_extension('bzrlib._knit_load_data_c')
254
262
if sys.platform == 'win32':
255
263
add_pyrex_extension('bzrlib._dirstate_helpers_c',
258
# pyrex uses the macro WIN32 to detect the platform, even though it should
259
# be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
261
add_pyrex_extension('bzrlib._walkdirs_win32',
262
define_macros=[('WIN32', None)])
264
libraries=['Ws2_32'])
265
add_pyrex_extension('bzrlib._walkdirs_win32')
264
267
if have_pyrex and pyrex_version == '0.9.4.1':
265
268
# Pyrex 0.9.4.1 fails to compile this extension correctly