Specify custom get_parents
[jelmer/dulwich.git] / setup.py
1 #!/usr/bin/python
2 # Setup file for dulwich
3 # Copyright (C) 2008-2011 Jelmer Vernooij <jelmer@samba.org>
4
5 try:
6     from setuptools import setup, Extension
7     has_setuptools = True
8 except ImportError:
9     from distutils.core import setup, Extension
10     has_setuptools = False
11 from distutils.core import Distribution
12
13 dulwich_version_string = '0.9.5'
14
15 include_dirs = []
16 # Windows MSVC support
17 import os
18 import sys
19 if sys.platform == 'win32':
20     include_dirs.append('dulwich')
21
22
23 class DulwichDistribution(Distribution):
24
25     def is_pure(self):
26         if self.pure:
27             return True
28
29     def has_ext_modules(self):
30         return not self.pure and not '__pypy__' in sys.modules
31
32     global_options = Distribution.global_options + [
33         ('pure', None, "use pure Python code instead of C "
34                        "extensions (slower on CPython)")]
35
36     pure = False
37
38 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
39     # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
40     # distutils.sysconfig
41     import subprocess
42     p = subprocess.Popen(
43         ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
44         stderr=subprocess.PIPE, env={})
45     out, err = p.communicate()
46     for l in out.splitlines():
47         # Also parse only first digit, because 3.2.1 can't be parsed nicely
48         if l.startswith('Xcode') and int(l.split()[1].split('.')[0]) >= 4:
49             os.environ['ARCHFLAGS'] = ''
50
51 setup_kwargs = {}
52
53 if has_setuptools:
54     setup_kwargs['test_suite'] = 'dulwich.tests.test_suite'
55
56 setup(name='dulwich',
57       description='Python Git Library',
58       keywords='git',
59       version=dulwich_version_string,
60       url='https://samba.org/~jelmer/dulwich',
61       license='GPLv2 or later',
62       author='Jelmer Vernooij',
63       author_email='jelmer@samba.org',
64       long_description="""
65       Python implementation of the Git file formats and protocols,
66       without the need to have git installed.
67
68       All functionality is available in pure Python. Optional
69       C extensions can be built for improved performance.
70
71       The project is named after the part of London that Mr. and Mrs. Git live in
72       in the particular Monty Python sketch.
73       """,
74       packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat'],
75       scripts=['bin/dulwich', 'bin/dul-daemon', 'bin/dul-web', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
76       ext_modules=[
77           Extension('dulwich._objects', ['dulwich/_objects.c'],
78                     include_dirs=include_dirs),
79           Extension('dulwich._pack', ['dulwich/_pack.c'],
80               include_dirs=include_dirs),
81           Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
82               include_dirs=include_dirs),
83       ],
84       distclass=DulwichDistribution,
85       **setup_kwargs
86       )