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
|
|
0.19.1
by Robert Collins
Start to simplify flush_range. |
2 |
import os |
|
0.17.1
by Robert Collins
Starting point. Interface tests hooked up and failing. |
3 |
from distutils.core import setup |
4 |
||
5 |
bzr_plugin_name = 'groupcompress' |
|
6 |
||
7 |
bzr_plugin_version = (1, 6, 0, 'dev', 0) |
|
8 |
||
|
0.18.1
by John Arbash Meinel
Start working on an EquivalenceTable construct. |
9 |
from distutils import log |
10 |
from distutils.errors import CCompilerError, DistutilsPlatformError |
|
11 |
from distutils.extension import Extension |
|
12 |
ext_modules = [] |
|
13 |
try: |
|
14 |
from Pyrex.Distutils import build_ext |
|
15 |
except ImportError: |
|
16 |
have_pyrex = False |
|
17 |
# try to build the extension from the prior generated source.
|
|
18 |
print
|
|
19 |
print ("The python package 'Pyrex' is not available." |
|
20 |
" If the .c files are available,") |
|
21 |
print ("they will be built," |
|
22 |
" but modifying the .pyx files will not rebuild them.") |
|
23 |
print
|
|
24 |
from distutils.command.build_ext import build_ext |
|
25 |
else: |
|
26 |
have_pyrex = True |
|
27 |
||
28 |
||
29 |
class build_ext_if_possible(build_ext): |
|
30 |
||
|
0.23.39
by John Arbash Meinel
Merge the setup.py changes so that it actually fails if an extension fails to build. |
31 |
user_options = build_ext.user_options + [ |
32 |
('allow-python-fallback', None, |
|
33 |
"When an extension cannot be built, allow falling"
|
|
34 |
" back to the pure-python implementation.") |
|
35 |
]
|
|
36 |
||
37 |
def initialize_options(self): |
|
38 |
build_ext.initialize_options(self) |
|
39 |
self.allow_python_fallback = False |
|
40 |
||
|
0.18.1
by John Arbash Meinel
Start working on an EquivalenceTable construct. |
41 |
def run(self): |
42 |
try: |
|
43 |
build_ext.run(self) |
|
44 |
except DistutilsPlatformError, e: |
|
|
0.23.39
by John Arbash Meinel
Merge the setup.py changes so that it actually fails if an extension fails to build. |
45 |
if not self.allow_python_fallback: |
46 |
log.warn('\n Cannot build extensions.\n' |
|
47 |
' Use "build_ext --allow-python-fallback" to use'
|
|
48 |
' slower python implementations instead.\n') |
|
49 |
raise
|
|
|
0.18.1
by John Arbash Meinel
Start working on an EquivalenceTable construct. |
50 |
log.warn(str(e)) |
|
0.23.39
by John Arbash Meinel
Merge the setup.py changes so that it actually fails if an extension fails to build. |
51 |
log.warn('\n Extensions cannot be built.\n' |
52 |
' Using the slower Python implementations instead.\n') |
|
|
0.18.1
by John Arbash Meinel
Start working on an EquivalenceTable construct. |
53 |
|
54 |
def build_extension(self, ext): |
|
55 |
try: |
|
56 |
build_ext.build_extension(self, ext) |
|
57 |
except CCompilerError: |
|
|
0.23.39
by John Arbash Meinel
Merge the setup.py changes so that it actually fails if an extension fails to build. |
58 |
if not self.allow_python_fallback: |
59 |
log.warn('\n Cannot build extension (%s).\n' |
|
60 |
' Use "build_ext --allow-python-fallback" to use'
|
|
61 |
' slower python implementations instead.\n' |
|
62 |
% (ext.name,)) |
|
63 |
raise
|
|
64 |
log.warn('\n Building of "%s" extension failed.\n' |
|
65 |
' Using the slower Python implementation instead.'
|
|
66 |
% (ext.name,)) |
|
|
0.18.1
by John Arbash Meinel
Start working on an EquivalenceTable construct. |
67 |
|
68 |
||
69 |
# Override the build_ext if we have Pyrex available
|
|
70 |
unavailable_files = [] |
|
71 |
||
72 |
||
|
0.23.6
by John Arbash Meinel
Start stripping out the actual GroupCompressor |
73 |
def add_pyrex_extension(module_name, extra_source=[]): |
|
0.18.1
by John Arbash Meinel
Start working on an EquivalenceTable construct. |
74 |
"""Add a pyrex module to build. |
75 |
||
76 |
This will use Pyrex to auto-generate the .c file if it is available.
|
|
77 |
Otherwise it will fall back on the .c file. If the .c file is not
|
|
78 |
available, it will warn, and not add anything.
|
|
79 |
||
80 |
You can pass any extra options to Extension through kwargs. One example is
|
|
81 |
'libraries = []'.
|
|
82 |
||
83 |
:param module_name: The python path to the module. This will be used to
|
|
84 |
determine the .pyx and .c files to use.
|
|
85 |
"""
|
|
86 |
path = module_name.replace('.', '/') |
|
87 |
pyrex_name = path + '.pyx' |
|
88 |
c_name = path + '.c' |
|
89 |
# Manually honour package_dir :(
|
|
90 |
module_name = 'bzrlib.plugins.groupcompress.' + module_name |
|
91 |
if have_pyrex: |
|
|
0.23.6
by John Arbash Meinel
Start stripping out the actual GroupCompressor |
92 |
source = [pyrex_name] |
93 |
elif not os.path.isfile(c_name): |
|
94 |
unavailable_files.append(c_name) |
|
95 |
return
|
|
|
0.18.1
by John Arbash Meinel
Start working on an EquivalenceTable construct. |
96 |
else: |
|
0.23.6
by John Arbash Meinel
Start stripping out the actual GroupCompressor |
97 |
source = [c_name] |
98 |
source.extend(extra_source) |
|
|
0.23.11
by John Arbash Meinel
Insert a fulltext if the delta is more than half the total size. |
99 |
ext_modules.append(Extension(module_name, source, |
100 |
extra_compile_args = ['-O3'])) |
|
|
0.19.1
by Robert Collins
Start to simplify flush_range. |
101 |
|
|
0.23.21
by John Arbash Meinel
Rename the extension to _pyx, since Robert prefers that form |
102 |
add_pyrex_extension('_groupcompress_pyx', |
|
0.17.31
by John Arbash Meinel
Bring in the 'rabin' experiment. |
103 |
extra_source=['diff-delta.c']) |
|
0.19.1
by Robert Collins
Start to simplify flush_range. |
104 |
|
|
0.17.1
by Robert Collins
Starting point. Interface tests hooked up and failing. |
105 |
|
106 |
if __name__ == '__main__': |
|
107 |
setup(name="bzr groupcompress", |
|
108 |
version="1.6.0dev0", |
|
109 |
description="bzr group compression.", |
|
110 |
author="Robert Collins", |
|
111 |
author_email="bazaar@lists.canonical.com", |
|
112 |
license = "GNU GPL v2", |
|
113 |
url="https://launchpad.net/bzr-groupcompress", |
|
114 |
packages=['bzrlib.plugins.groupcompress', |
|
115 |
'bzrlib.plugins.groupcompress.tests', |
|
116 |
],
|
|
117 |
package_dir={'bzrlib.plugins.groupcompress': '.'}, |
|
|
0.19.1
by Robert Collins
Start to simplify flush_range. |
118 |
cmdclass={'build_ext': build_ext_if_possible}, |
119 |
ext_modules=ext_modules, |
|
|
0.18.13
by John Arbash Meinel
Copy the EquivalenceTable code into pyrex and get it under test. |
120 |
)
|