/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: Martin Pool
  • Date: 2010-06-24 06:53:06 UTC
  • mfrom: (5317 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5343.
  • Revision ID: mbp@sourcefrog.net-20100624065306-qcx1wg84ufuckime
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    'version':      bzrlib.__version__,
38
38
    'author':       'Canonical Ltd',
39
39
    'author_email': 'bazaar@lists.canonical.com',
40
 
    'url':          'http://www.bazaar-vcs.org/',
 
40
    'url':          'http://bazaar.canonical.com/',
41
41
    'description':  'Friendly distributed version control system',
42
42
    'license':      'GNU GPL v2',
43
43
    'download_url': 'https://launchpad.net/bzr/+download',
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
 
190
    pyrex_version_info = tuple(map(int, pyrex_version.split('.')))
189
191
 
190
192
 
191
193
class build_ext_if_possible(build_ext):
203
205
    def run(self):
204
206
        try:
205
207
            build_ext.run(self)
206
 
        except DistutilsPlatformError, e:
 
208
        except DistutilsPlatformError:
 
209
            e = sys.exc_info()[1]
207
210
            if not self.allow_python_fallback:
208
211
                log.warn('\n  Cannot build extensions.\n'
209
212
                         '  Use "build_ext --allow-python-fallback" to use'
280
283
    add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
281
284
                        libraries=['Ws2_32'])
282
285
    add_pyrex_extension('bzrlib._walkdirs_win32')
283
 
    z_lib = 'zdll'
284
286
else:
285
 
    if have_pyrex and pyrex_version.startswith('0.9.4'):
 
287
    if have_pyrex and pyrex_version_info[:3] == (0,9,4):
286
288
        # Pyrex 0.9.4.1 fails to compile this extension correctly
287
289
        # The code it generates re-uses a "local" pointer and
288
290
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
289
291
        # which is NULL safe with PY_DECREF which is not.)
290
292
        # <https://bugs.edge.launchpad.net/bzr/+bug/449372>
291
293
        # <https://bugs.edge.launchpad.net/bzr/+bug/276868>
292
 
        print 'Cannot build extension "bzrlib._dirstate_helpers_pyx" using'
293
 
        print 'your version of pyrex "%s". Please upgrade your pyrex' % (
294
 
            pyrex_version,)
295
 
        print 'install. For now, the non-compiled (python) version will'
296
 
        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.')
297
299
    else:
298
300
        add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
299
301
    add_pyrex_extension('bzrlib._readdir_pyx')
300
 
    z_lib = 'z'
301
 
add_pyrex_extension('bzrlib._chk_map_pyx', libraries=[z_lib])
 
302
add_pyrex_extension('bzrlib._chk_map_pyx')
302
303
ext_modules.append(Extension('bzrlib._patiencediff_c',
303
304
                             ['bzrlib/_patiencediff_c.c']))
304
 
add_pyrex_extension('bzrlib._simple_set_pyx')
305
 
ext_modules.append(Extension('bzrlib._static_tuple_c',
306
 
                             ['bzrlib/_static_tuple_c.c']))
 
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("")
 
312
    # TODO: Should this be a fatal error?
 
313
else:
 
314
    # We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
 
315
    # on simple_set
 
316
    add_pyrex_extension('bzrlib._simple_set_pyx')
 
317
    ext_modules.append(Extension('bzrlib._static_tuple_c',
 
318
                                 ['bzrlib/_static_tuple_c.c']))
307
319
add_pyrex_extension('bzrlib._btree_serializer_pyx')
308
320
 
309
321
 
310
322
if unavailable_files:
311
 
    print 'C extension(s) not found:'
312
 
    print '   %s' % ('\n  '.join(unavailable_files),)
313
 
    print 'The python versions will be used instead.'
314
 
    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("")
315
327
 
316
328
 
317
329
def get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
458
470
 
459
471
def get_svn_py2exe_info(includes, excludes, packages):
460
472
    packages.append('subvertpy')
 
473
    packages.append('sqlite3')
461
474
 
462
475
 
463
476
if 'bdist_wininst' in sys.argv:
521
534
            install_data.run(self)
522
535
 
523
536
            py2exe = self.distribution.get_command_obj('py2exe', False)
524
 
            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
525
540
            compile_names = [f for f in self.outfiles if f.endswith('.py')]
526
541
            byte_compile(compile_names,
527
542
                         optimize=optimize,
528
543
                         force=self.force, prefix=self.install_dir,
529
544
                         dry_run=self.dry_run)
530
 
            if optimize:
531
 
                suffix = 'o'
532
 
            else:
533
 
                suffix = 'c'
534
 
            self.outfiles.extend([f + suffix for f in compile_names])
 
545
            self.outfiles.extend([f + 'o' for f in compile_names])
535
546
    # end of class install_data_with_bytecompile
536
547
 
537
548
    target = py2exe.build_exe.Target(script = "bzr",
541
552
                                     version = version_str,
542
553
                                     description = META_INFO['description'],
543
554
                                     author = META_INFO['author'],
544
 
                                     copyright = "(c) Canonical Ltd, 2005-2009",
 
555
                                     copyright = "(c) Canonical Ltd, 2005-2010",
545
556
                                     company_name = "Canonical Ltd.",
546
557
                                     comments = META_INFO['description'],
547
558
                                    )
560
571
    if sys.version.startswith('2.4'):
561
572
        # adding elementtree package
562
573
        additional_packages.add('elementtree')
563
 
    elif sys.version.startswith('2.5'):
 
574
    elif sys.version.startswith('2.6') or sys.version.startswith('2.5'):
564
575
        additional_packages.add('xml.etree')
565
576
    else:
566
577
        import warnings
612
623
            excludes.extend(["bzrlib.plugins." + d for d in dirs])
613
624
        x = []
614
625
        for i in files:
615
 
            if os.path.splitext(i)[1] not in [".py", ".pyd", ".dll", ".mo"]:
 
626
            # Throw away files we don't want packaged. Note that plugins may
 
627
            # have data files with all sorts of extensions so we need to
 
628
            # be conservative here about what we ditch.
 
629
            ext = os.path.splitext(i)[1]
 
630
            if ext.endswith('~') or ext in [".pyc", ".swp"]:
616
631
                continue
617
632
            if i == '__init__.py' and root == 'bzrlib/plugins':
618
633
                continue
664
679
        # print this warning to stderr as output is redirected, so it is seen
665
680
        # at build time.  Also to stdout so it appears in the log
666
681
        for f in (sys.stderr, sys.stdout):
667
 
            print >> f, \
668
 
                "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")
669
684
 
670
685
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
671
686
    # in on Vista.
675
690
                               "excludes": excludes,
676
691
                               "dll_excludes": dll_excludes,
677
692
                               "dist_dir": "win32_bzr.exe",
678
 
                               "optimize": 1,
 
693
                               "optimize": 2,
679
694
                              },
680
695
                   }
681
 
 
682
 
    setup(options=options_list,
683
 
          console=console_targets,
684
 
          windows=gui_targets,
685
 
          zipfile='lib/library.zip',
686
 
          data_files=data_files,
687
 
          cmdclass={'install_data': install_data_with_bytecompile},
688
 
          )
 
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
              )
689
704
 
690
705
else:
691
706
    # ad-hoc for easy_install
695
710
        # easy_install one
696
711
        DATA_FILES = [('man/man1', ['bzr.1'])]
697
712
 
 
713
    if sys.platform != 'win32':
 
714
        # see https://wiki.kubuntu.org/Apport/DeveloperHowTo
 
715
        #
 
716
        # checking the paths and hardcoding the check for root is a bit gross,
 
717
        # but I don't see a cleaner way to find out the locations in a way
 
718
        # that's going to align with the hardcoded paths in apport.
 
719
        if os.geteuid() == 0:
 
720
            DATA_FILES += [
 
721
                ('/usr/share/apport/package-hooks',
 
722
                    ['apport/source_bzr.py']),
 
723
                ('/etc/apport/crashdb.conf.d/',
 
724
                    ['apport/bzr-crashdb.conf']),]
 
725
 
698
726
    # std setup
699
727
    ARGS = {'scripts': ['bzr'],
700
728
            'data_files': DATA_FILES,
706
734
    ARGS.update(BZRLIB)
707
735
    ARGS.update(PKG_DATA)
708
736
 
709
 
    setup(**ARGS)
 
737
    if __name__ == '__main__':
 
738
        setup(**ARGS)