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