cleanup: consistently use local variable instead of attribute
[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 except ImportError:
8     from distutils.core import setup, Extension
9 from distutils.core import Distribution
10
11 dulwich_version_string = '0.9.8'
12
13 include_dirs = []
14 # Windows MSVC support
15 import os
16 import sys
17 if sys.platform == 'win32':
18     include_dirs.append('dulwich')
19
20
21 class DulwichDistribution(Distribution):
22
23     def is_pure(self):
24         if self.pure:
25             return True
26
27     def has_ext_modules(self):
28         return not self.pure and not '__pypy__' in sys.modules
29
30     global_options = Distribution.global_options + [
31         ('pure', None, "use pure Python code instead of C "
32                        "extensions (slower on CPython)")]
33
34     pure = False
35
36 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
37     # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
38     # distutils.sysconfig
39     import subprocess
40     p = subprocess.Popen(
41         ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
42         stderr=subprocess.PIPE, env={})
43     out, err = p.communicate()
44     for l in out.splitlines():
45         l = l.decode("utf8")
46         # Also parse only first digit, because 3.2.1 can't be parsed nicely
47         if l.startswith('Xcode') and int(l.split()[1].split('.')[0]) >= 4:
48             os.environ['ARCHFLAGS'] = ''
49
50
51 setup(name='dulwich',
52       description='Python Git Library',
53       keywords='git',
54       version=dulwich_version_string,
55       url='https://samba.org/~jelmer/dulwich',
56       license='GPLv2 or later',
57       author='Jelmer Vernooij',
58       author_email='jelmer@samba.org',
59       long_description="""
60       Python implementation of the Git file formats and protocols,
61       without the need to have git installed.
62
63       All functionality is available in pure Python. Optional
64       C extensions can be built for improved performance.
65
66       The project is named after the part of London that Mr. and Mrs. Git live in
67       in the particular Monty Python sketch.
68       """,
69       packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat', 'dulwich.contrib'],
70       scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
71       classifiers=[
72           'Development Status :: 4 - Beta',
73           'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
74           'Programming Language :: Python :: 2.7',
75           'Operating System :: POSIX',
76           'Topic :: Software Development :: Version Control',
77       ],
78       ext_modules=[
79           Extension('dulwich._objects', ['dulwich/_objects.c'],
80                     include_dirs=include_dirs),
81           Extension('dulwich._pack', ['dulwich/_pack.c'],
82               include_dirs=include_dirs),
83           Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
84               include_dirs=include_dirs),
85       ],
86       test_suite='dulwich.tests.test_suite',
87       tests_require=['fastimport', 'mock', 'gevent', 'geventhttpclient'],
88       distclass=DulwichDistribution,
89       include_package_data=True,
90       use_2to3=True,
91       convert_2to3_doctests=['../docs/*', '../docs/tutorial/*', ],
92       )