/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-02 16:35:05 UTC
  • mto: This revision was merged to the branch mainline in revision 3772.
  • Revision ID: john@arbash-meinel.com-20081002163505-sscy52tfqzz7ltg9
Default to requiring extensions.

The build process will fail if extensions cannot be compiled, unless
--allow-python-fallback is supplied.
This helps PQM to make sure extensions are tested, and helps
users by having them explicitly allow non-compiled forms.

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
 
179
180
 
180
181
class build_ext_if_possible(build_ext):
181
182
 
 
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.")
 
187
        ]
 
188
 
 
189
    def initialize_options(self):
 
190
        build_ext.initialize_options(self)
 
191
        self.allow_python_fallback = False
 
192
 
182
193
    def run(self):
183
194
        try:
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')
 
201
                raise
186
202
            log.warn(str(e))
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')
189
205
 
190
206
    def build_extension(self, ext):
191
207
        try:
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'
 
214
                         % (ext.name,))
 
215
                raise
 
216
            log.warn('\n  Building of "%s" extension failed.\n'
 
217
                     '  Using the slower Python implementation instead.'
 
218
                     % (ext.name,))
196
219
 
197
220
 
198
221
# Override the build_ext if we have Pyrex available