150
150
command_classes = {'install_scripts': my_install_scripts,
151
151
'build': bzr_build}
152
from distutils.extension import Extension
154
155
from Pyrex.Distutils import build_ext
155
156
except ImportError:
156
158
# try to build the extension from the prior generated source.
157
160
print ("Pyrex not available, while bzr will build, "
158
161
"you cannot modify the C extensions.")
159
162
from distutils.command.build_ext import build_ext
160
from distutils.extension import Extension
162
# Extension("bzrlib.modulename", ["bzrlib/foo.c"], libraries = []))
164
Extension("bzrlib._knit_load_data_c", ["bzrlib/_knit_load_data_c.c"]))
166
from distutils.extension import Extension
168
# Extension("bzrlib.modulename", ["bzrlib/foo.pyx"], libraries = []))
170
Extension("bzrlib._knit_load_data_c", ["bzrlib/_knit_load_data_c.pyx"]))
165
# Override the build_ext if we have Pyrex available
171
166
command_classes['build_ext'] = build_ext
167
unavailable_files = []
169
def add_pyrex_extension(module_name, **kwargs):
170
"""Add a pyrex module to build.
172
This will use Pyrex to auto-generate the .c file if it is available.
173
Otherwise it will fall back on the .c file. If the .c file is not
174
available, it will warn, and not add anything.
176
You can pass any extra options to Extension through kwargs. One example is
179
:param module_name: The python path to the module. This will be used to
180
determine the .pyx and .c files to use.
182
path = module_name.replace('.', '/')
183
pyrex_name = path + '.pyx'
186
ext_modules.append(Extension(module_name, [pyrex_name]))
188
if not os.path.isfile(c_name):
189
unavailable_files.append(c_name)
191
ext_modules.append(Extension(module_name, [c_name]))
194
add_pyrex_extension('bzrlib._knit_load_data_c')
197
if unavailable_files:
198
print 'C extension(s) not found:'
199
print ' %s' % ('\n '.join(unavailable_files),)
200
print 'The python versions will be used instead.'
173
204
if 'bdist_wininst' in sys.argv: