181
182
class build_ext_if_possible(build_ext):
184
user_options = build_ext.user_options + [
185
('allow-python-fallback', None,
186
"When an extension cannot be built, allow falling"
187
" back to the pure-python implementation.")
190
def initialize_options(self):
191
build_ext.initialize_options(self)
192
self.allow_python_fallback = False
185
196
build_ext.run(self)
186
197
except DistutilsPlatformError, e:
198
if not self.allow_python_fallback:
199
log.warn('\n Cannot build extensions.\n'
200
' Use --allow-python-fallback to use slower'
201
' python implementations instead.\n')
188
log.warn('Extensions cannot be built, '
189
'will use the Python versions instead')
204
log.warn('\n Extensions cannot be built.\n'
205
' Using the slower Python implementations instead.\n')
191
207
def build_extension(self, ext):
193
209
build_ext.build_extension(self, ext)
194
210
except CCompilerError:
195
log.warn('Building of "%s" extension failed, '
196
'will use the Python version instead' % (ext.name,))
211
if not self.allow_python_fallback:
212
log.warn('\n Failed to build "%s".\n'
213
' Use --allow-python-fallback to use slower'
214
' python implementations instead.\n'
217
log.warn('\n Building of "%s" extension failed.\n'
218
' Using the slower Python implementation instead.'
199
222
# Override the build_ext if we have Pyrex available