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
print ("Pyrex not available, while bzr will build, "
158
"you cannot modify the C extensions.")
160
print ("The python package 'Pyrex' is not available."
161
" If the .c files are available,")
162
print ("they will be built,"
163
" but modifying the .pyx files will not rebuild them.")
159
165
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"]))
168
# Override the build_ext if we have Pyrex available
171
169
command_classes['build_ext'] = build_ext
170
unavailable_files = []
173
def add_pyrex_extension(module_name, **kwargs):
174
"""Add a pyrex module to build.
176
This will use Pyrex to auto-generate the .c file if it is available.
177
Otherwise it will fall back on the .c file. If the .c file is not
178
available, it will warn, and not add anything.
180
You can pass any extra options to Extension through kwargs. One example is
183
:param module_name: The python path to the module. This will be used to
184
determine the .pyx and .c files to use.
186
path = module_name.replace('.', '/')
187
pyrex_name = path + '.pyx'
190
ext_modules.append(Extension(module_name, [pyrex_name]))
192
if not os.path.isfile(c_name):
193
unavailable_files.append(c_name)
195
ext_modules.append(Extension(module_name, [c_name]))
198
add_pyrex_extension('bzrlib._knit_load_data_c')
201
if unavailable_files:
202
print 'C extension(s) not found:'
203
print ' %s' % ('\n '.join(unavailable_files),)
204
print 'The python versions will be used instead.'
173
208
if 'bdist_wininst' in sys.argv: