~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Robert Collins
  • Date: 2010-07-04 06:22:11 UTC
  • mto: This revision was merged to the branch mainline in revision 5332.
  • Revision ID: robertc@robertcollins.net-20100704062211-tk9hw6bnsn5x47fm
``bzrlib.lsprof.profile`` will no longer silently generate bad threaded
profiles when concurrent profile requests are made. Instead the profile
requests will be serialised. Reentrant requests will now deadlock.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
                f = file(batch_path, "w")
126
126
                f.write(batch_str)
127
127
                f.close()
128
 
                print "Created:", batch_path
129
 
            except Exception, e:
130
 
                print "ERROR: Unable to create %s: %s" % (batch_path, e)
 
128
                print("Created: %s" % batch_path)
 
129
            except Exception:
 
130
                e = sys.exc_info()[1]
 
131
                print("ERROR: Unable to create %s: %s" % (batch_path, e))
131
132
 
132
133
    def _quoted_path(self, path):
133
134
        if ' ' in path:
171
172
        from Pyrex.Distutils import build_ext
172
173
        from Pyrex.Compiler.Version import version as pyrex_version
173
174
    except ImportError:
174
 
        print "No Pyrex, trying Cython..."
 
175
        print("No Pyrex, trying Cython...")
175
176
        from Cython.Distutils import build_ext
176
177
        from Cython.Compiler.Version import version as pyrex_version
177
178
except ImportError:
178
179
    have_pyrex = False
179
180
    # try to build the extension from the prior generated source.
180
 
    print
181
 
    print ("The python package 'Pyrex' is not available."
182
 
           " If the .c files are available,")
183
 
    print ("they will be built,"
184
 
           " but modifying the .pyx files will not rebuild them.")
185
 
    print
 
181
    print("")
 
182
    print("The python package 'Pyrex' is not available."
 
183
          " If the .c files are available,")
 
184
    print("they will be built,"
 
185
          " but modifying the .pyx files will not rebuild them.")
 
186
    print("")
186
187
    from distutils.command.build_ext import build_ext
187
188
else:
188
189
    have_pyrex = True
204
205
    def run(self):
205
206
        try:
206
207
            build_ext.run(self)
207
 
        except DistutilsPlatformError, e:
 
208
        except DistutilsPlatformError:
 
209
            e = sys.exc_info()[1]
208
210
            if not self.allow_python_fallback:
209
211
                log.warn('\n  Cannot build extensions.\n'
210
212
                         '  Use "build_ext --allow-python-fallback" to use'
281
283
    add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
282
284
                        libraries=['Ws2_32'])
283
285
    add_pyrex_extension('bzrlib._walkdirs_win32')
284
 
    z_lib = 'zdll'
285
286
else:
286
287
    if have_pyrex and pyrex_version_info[:3] == (0,9,4):
287
288
        # Pyrex 0.9.4.1 fails to compile this extension correctly
290
291
        # which is NULL safe with PY_DECREF which is not.)
291
292
        # <https://bugs.edge.launchpad.net/bzr/+bug/449372>
292
293
        # <https://bugs.edge.launchpad.net/bzr/+bug/276868>
293
 
        print 'Cannot build extension "bzrlib._dirstate_helpers_pyx" using'
294
 
        print 'your version of pyrex "%s". Please upgrade your pyrex' % (
295
 
            pyrex_version,)
296
 
        print 'install. For now, the non-compiled (python) version will'
297
 
        print 'be used instead.'
 
294
        print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
 
295
        print('your version of pyrex "%s". Please upgrade your pyrex' % (
 
296
            pyrex_version,))
 
297
        print('install. For now, the non-compiled (python) version will')
 
298
        print('be used instead.')
298
299
    else:
299
300
        add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
300
301
    add_pyrex_extension('bzrlib._readdir_pyx')
301
 
    z_lib = 'z'
302
 
add_pyrex_extension('bzrlib._chk_map_pyx', libraries=[z_lib])
 
302
add_pyrex_extension('bzrlib._chk_map_pyx')
303
303
ext_modules.append(Extension('bzrlib._patiencediff_c',
304
304
                             ['bzrlib/_patiencediff_c.c']))
305
305
if have_pyrex and pyrex_version_info < (0, 9, 6, 3):
306
 
    print
307
 
    print 'Your Pyrex/Cython version %s is too old to build the simple_set' % (
308
 
        pyrex_version)
309
 
    print 'and static_tuple extensions.'
310
 
    print 'Please upgrade to at least Pyrex 0.9.6.3'
311
 
    print
 
306
    print("")
 
307
    print('Your Pyrex/Cython version %s is too old to build the simple_set' % (
 
308
        pyrex_version))
 
309
    print('and static_tuple extensions.')
 
310
    print('Please upgrade to at least Pyrex 0.9.6.3')
 
311
    print("")
312
312
    # TODO: Should this be a fatal error?
313
313
else:
314
314
    # We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
320
320
 
321
321
 
322
322
if unavailable_files:
323
 
    print 'C extension(s) not found:'
324
 
    print '   %s' % ('\n  '.join(unavailable_files),)
325
 
    print 'The python versions will be used instead.'
326
 
    print
 
323
    print('C extension(s) not found:')
 
324
    print('   %s' % ('\n  '.join(unavailable_files),))
 
325
    print('The python versions will be used instead.')
 
326
    print("")
327
327
 
328
328
 
329
329
def get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
534
534
            install_data.run(self)
535
535
 
536
536
            py2exe = self.distribution.get_command_obj('py2exe', False)
537
 
            optimize = py2exe.optimize
 
537
            # GZ 2010-04-19: Setup has py2exe.optimize as 2, but give plugins
 
538
            #                time before living with docstring stripping
 
539
            optimize = 1
538
540
            compile_names = [f for f in self.outfiles if f.endswith('.py')]
539
541
            byte_compile(compile_names,
540
542
                         optimize=optimize,
541
543
                         force=self.force, prefix=self.install_dir,
542
544
                         dry_run=self.dry_run)
543
 
            if optimize:
544
 
                suffix = 'o'
545
 
            else:
546
 
                suffix = 'c'
547
 
            self.outfiles.extend([f + suffix for f in compile_names])
 
545
            self.outfiles.extend([f + 'o' for f in compile_names])
548
546
    # end of class install_data_with_bytecompile
549
547
 
550
548
    target = py2exe.build_exe.Target(script = "bzr",
681
679
        # print this warning to stderr as output is redirected, so it is seen
682
680
        # at build time.  Also to stdout so it appears in the log
683
681
        for f in (sys.stderr, sys.stdout):
684
 
            print >> f, \
685
 
                "Skipping TBZR binaries - please set TBZR to a directory to enable"
 
682
            f.write("Skipping TBZR binaries - "
 
683
                "please set TBZR to a directory to enable\n")
686
684
 
687
685
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
688
686
    # in on Vista.
692
690
                               "excludes": excludes,
693
691
                               "dll_excludes": dll_excludes,
694
692
                               "dist_dir": "win32_bzr.exe",
695
 
                               "optimize": 1,
 
693
                               "optimize": 2,
696
694
                              },
697
695
                   }
698
 
 
699
 
    setup(options=options_list,
700
 
          console=console_targets,
701
 
          windows=gui_targets,
702
 
          zipfile='lib/library.zip',
703
 
          data_files=data_files,
704
 
          cmdclass={'install_data': install_data_with_bytecompile},
705
 
          )
 
696
    if __name__ == '__main__':
 
697
        setup(options=options_list,
 
698
              console=console_targets,
 
699
              windows=gui_targets,
 
700
              zipfile='lib/library.zip',
 
701
              data_files=data_files,
 
702
              cmdclass={'install_data': install_data_with_bytecompile},
 
703
              )
706
704
 
707
705
else:
708
706
    # ad-hoc for easy_install
736
734
    ARGS.update(BZRLIB)
737
735
    ARGS.update(PKG_DATA)
738
736
 
739
 
    setup(**ARGS)
 
737
    if __name__ == '__main__':
 
738
        setup(**ARGS)