/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

  • Committer: John Arbash Meinel
  • Date: 2008-10-22 19:07:07 UTC
  • mfrom: (3789 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3790.
  • Revision ID: john@arbash-meinel.com-20081022190707-qf5480pbkqp33d51
Merge bzr.dev 3789

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
 
180
181
 
181
182
class build_ext_if_possible(build_ext):
182
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
 
183
194
    def run(self):
184
195
        try:
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')
 
202
                raise
187
203
            log.warn(str(e))
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')
190
206
 
191
207
    def build_extension(self, ext):
192
208
        try:
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'
 
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,))
197
220
 
198
221
 
199
222
# Override the build_ext if we have Pyrex available
201
224
unavailable_files = []
202
225
 
203
226
 
204
 
def add_pyrex_extension(module_name, **kwargs):
 
227
def add_pyrex_extension(module_name, libraries=None):
205
228
    """Add a pyrex module to build.
206
229
 
207
230
    This will use Pyrex to auto-generate the .c file if it is available.
217
240
    path = module_name.replace('.', '/')
218
241
    pyrex_name = path + '.pyx'
219
242
    c_name = path + '.c'
 
243
    define_macros = []
 
244
    if sys.platform == 'win32':
 
245
        # pyrex uses the macro WIN32 to detect the platform, even though it should
 
246
        # be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
 
247
        # right value.
 
248
        define_macros.append(('WIN32', None))
220
249
    if have_pyrex:
221
 
        ext_modules.append(Extension(module_name, [pyrex_name], **kwargs))
 
250
        ext_modules.append(Extension(module_name, [pyrex_name],
 
251
            define_macros=define_macros, libraries=libraries))
222
252
    else:
223
253
        if not os.path.isfile(c_name):
224
254
            unavailable_files.append(c_name)
225
255
        else:
226
 
            ext_modules.append(Extension(module_name, [c_name], **kwargs))
 
256
            ext_modules.append(Extension(module_name, [c_name],
 
257
                define_macros=define_macros, libraries=libraries))
227
258
 
228
259
 
229
260
add_pyrex_extension('bzrlib._btree_serializer_c')
230
261
add_pyrex_extension('bzrlib._knit_load_data_c')
231
262
if sys.platform == 'win32':
232
263
    add_pyrex_extension('bzrlib._dirstate_helpers_c',
233
 
                         libraries=['Ws2_32']
234
 
                       )
235
 
    # pyrex uses the macro WIN32 to detect the platform, even though it should
236
 
    # be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
237
 
    # right value.
238
 
    add_pyrex_extension('bzrlib._walkdirs_win32',
239
 
                        define_macros=[('WIN32', None)])
 
264
                        libraries=['Ws2_32'])
 
265
    add_pyrex_extension('bzrlib._walkdirs_win32')
240
266
else:
241
267
    if have_pyrex and pyrex_version == '0.9.4.1':
242
268
        # Pyrex 0.9.4.1 fails to compile this extension correctly