/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to setup.py

Merge commit builder changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
    """Customized build distutils action.
145
145
    Generate bzr.1.
146
146
    """
 
147
 
147
148
    def run(self):
148
149
        build.run(self)
149
150
 
175
176
    from distutils.command.build_ext import build_ext
176
177
else:
177
178
    have_pyrex = True
 
179
    from Pyrex.Compiler.Version import version as pyrex_version
178
180
 
179
181
 
180
182
class build_ext_if_possible(build_ext):
181
183
 
 
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.")
 
188
        ]
 
189
 
 
190
    def initialize_options(self):
 
191
        build_ext.initialize_options(self)
 
192
        self.allow_python_fallback = False
 
193
 
182
194
    def run(self):
183
195
        try:
184
196
            build_ext.run(self)
185
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')
 
202
                raise
186
203
            log.warn(str(e))
187
 
            log.warn('Extensions cannot be built, '
188
 
                     'will use the Python versions instead')
 
204
            log.warn('\n  Extensions cannot be built.\n'
 
205
                     '  Using the slower Python implementations instead.\n')
189
206
 
190
207
    def build_extension(self, ext):
191
208
        try:
192
209
            build_ext.build_extension(self, ext)
193
210
        except CCompilerError:
194
 
            log.warn('Building of "%s" extension failed, '
195
 
                     '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'
 
215
                         % (ext.name,))
 
216
                raise
 
217
            log.warn('\n  Building of "%s" extension failed.\n'
 
218
                     '  Using the slower Python implementation instead.'
 
219
                     % (ext.name,))
196
220
 
197
221
 
198
222
# Override the build_ext if we have Pyrex available
226
250
 
227
251
 
228
252
add_pyrex_extension('bzrlib._btree_serializer_c')
229
 
add_pyrex_extension('bzrlib._dirstate_helpers_c')
230
253
add_pyrex_extension('bzrlib._knit_load_data_c')
231
254
if sys.platform == 'win32':
 
255
    add_pyrex_extension('bzrlib._dirstate_helpers_c',
 
256
                         libraries=['Ws2_32']
 
257
                       )
232
258
    # pyrex uses the macro WIN32 to detect the platform, even though it should
233
259
    # be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
234
260
    # right value.
235
261
    add_pyrex_extension('bzrlib._walkdirs_win32',
236
262
                        define_macros=[('WIN32', None)])
237
263
else:
 
264
    if have_pyrex and pyrex_version == '0.9.4.1':
 
265
        # Pyrex 0.9.4.1 fails to compile this extension correctly
 
266
        # The code it generates re-uses a "local" pointer and
 
267
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
 
268
        # which is NULL safe with PY_DECREF which is not.)
 
269
        print 'Cannot build extension "bzrlib._dirstate_helpers_c" using'
 
270
        print 'your version of pyrex "%s". Please upgrade your pyrex' % (
 
271
            pyrex_version,)
 
272
        print 'install. For now, the non-compiled (python) version will'
 
273
        print 'be used instead.'
 
274
    else:
 
275
        add_pyrex_extension('bzrlib._dirstate_helpers_c')
238
276
    add_pyrex_extension('bzrlib._readdir_pyx')
239
277
ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))
240
278