/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.17.1 by Robert Collins
Starting point. Interface tests hooked up and failing.
1
#!/usr/bin/env python
2
from distutils.core import setup
3
4
bzr_plugin_name = 'groupcompress'
5
6
bzr_plugin_version = (1, 6, 0, 'dev', 0)
7
0.18.1 by John Arbash Meinel
Start working on an EquivalenceTable construct.
8
from distutils import log
9
from distutils.errors import CCompilerError, DistutilsPlatformError
10
from distutils.extension import Extension
11
ext_modules = []
12
try:
13
    from Pyrex.Distutils import build_ext
14
except ImportError:
15
    have_pyrex = False
16
    # try to build the extension from the prior generated source.
17
    print
18
    print ("The python package 'Pyrex' is not available."
19
           " If the .c files are available,")
20
    print ("they will be built,"
21
           " but modifying the .pyx files will not rebuild them.")
22
    print
23
    from distutils.command.build_ext import build_ext
24
else:
25
    have_pyrex = True
26
27
28
class build_ext_if_possible(build_ext):
29
30
    def run(self):
31
        try:
32
            build_ext.run(self)
33
        except DistutilsPlatformError, e:
34
            log.warn(str(e))
35
            log.warn('Extensions cannot be built, '
36
                     'will use the Python versions instead')
37
38
    def build_extension(self, ext):
39
        try:
40
            build_ext.build_extension(self, ext)
41
        except CCompilerError:
42
            log.warn('Building of "%s" extension failed, '
43
                     'will use the Python version instead' % (ext.name,))
44
45
46
# Override the build_ext if we have Pyrex available
47
unavailable_files = []
48
49
50
def add_pyrex_extension(module_name, **kwargs):
51
    """Add a pyrex module to build.
52
53
    This will use Pyrex to auto-generate the .c file if it is available.
54
    Otherwise it will fall back on the .c file. If the .c file is not
55
    available, it will warn, and not add anything.
56
57
    You can pass any extra options to Extension through kwargs. One example is
58
    'libraries = []'.
59
60
    :param module_name: The python path to the module. This will be used to
61
        determine the .pyx and .c files to use.
62
    """
63
    path = module_name.replace('.', '/')
64
    pyrex_name = path + '.pyx'
65
    c_name = path + '.c'
66
    # Manually honour package_dir :(
67
    module_name = 'bzrlib.plugins.groupcompress.' + module_name
68
    if have_pyrex:
69
        ext_modules.append(Extension(module_name, [pyrex_name]))
70
    else:
71
        if not os.path.isfile(c_name):
72
            unavailable_files.append(c_name)
73
        else:
74
            ext_modules.append(Extension(module_name, [c_name]))
0.17.1 by Robert Collins
Starting point. Interface tests hooked up and failing.
75
76
if __name__ == '__main__':
77
    setup(name="bzr groupcompress",
78
          version="1.6.0dev0",
79
          description="bzr group compression.",
80
          author="Robert Collins",
81
          author_email="bazaar@lists.canonical.com",
82
          license = "GNU GPL v2",
83
          url="https://launchpad.net/bzr-groupcompress",
84
          packages=['bzrlib.plugins.groupcompress',
85
                    'bzrlib.plugins.groupcompress.tests',
86
                    ],
87
          package_dir={'bzrlib.plugins.groupcompress': '.'},
88
          }