Release 0.12.0.
[jelmer/dulwich.git] / setup.py
1 #!/usr/bin/python
2 # Setup file for dulwich
3 # Copyright (C) 2008-2011 Jelmer Vernooij <jelmer@jelmer.uk>
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.12.0'
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 class DulwichDistribution(Distribution):
21
22     def is_pure(self):
23         if self.pure:
24             return True
25
26     def has_ext_modules(self):
27         return not self.pure
28
29     global_options = Distribution.global_options + [
30         ('pure', None, "use pure Python code instead of C "
31                        "extensions (slower on CPython)")]
32
33     pure = False
34
35 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
36     # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
37     # distutils.sysconfig
38     import subprocess
39     p = subprocess.Popen(
40         ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
41         stderr=subprocess.PIPE, env={})
42     out, err = p.communicate()
43     for l in out.splitlines():
44         l = l.decode("utf8")
45         # Also parse only first digit, because 3.2.1 can't be parsed nicely
46         if l.startswith('Xcode') and int(l.split()[1].split('.')[0]) >= 4:
47             os.environ['ARCHFLAGS'] = ''
48
49 if sys.version_info[0] == 2:
50     tests_require = ['fastimport']
51     if not '__pypy__' in sys.modules and not sys.platform == 'win32':
52         tests_require.extend([
53             'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1'])
54     if sys.version_info < (2, 7):
55         tests_require.append('unittest2')
56 else:
57     # fastimport, gevent, geventhttpclient are not available for PY3
58     # mock only used for test_swift, which requires gevent/geventhttpclient
59     tests_require = []
60
61 if sys.version_info[0] > 2 and sys.platform == 'win32':
62     # C Modules don't build for python3 windows, and prevent tests from running
63     ext_modules = []
64 else:
65     ext_modules = [
66         Extension('dulwich._objects', ['dulwich/_objects.c'],
67                   include_dirs=include_dirs),
68         Extension('dulwich._pack', ['dulwich/_pack.c'],
69                   include_dirs=include_dirs),
70         Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
71                   include_dirs=include_dirs),
72     ]
73
74
75 setup(name='dulwich',
76       description='Python Git Library',
77       keywords='git',
78       version=dulwich_version_string,
79       url='https://www.dulwich.io/',
80       license='GPLv2 or later',
81       author='Jelmer Vernooij',
82       author_email='jelmer@jelmer.uk',
83       long_description="""
84       Python implementation of the Git file formats and protocols,
85       without the need to have git installed.
86
87       All functionality is available in pure Python. Optional
88       C extensions can be built for improved performance.
89
90       The project is named after the part of London that Mr. and Mrs. Git live in
91       in the particular Monty Python sketch.
92       """,
93       packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat', 'dulwich.contrib'],
94       package_data={'': ['../docs/tutorial/*.txt']},
95       scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
96       classifiers=[
97           'Development Status :: 4 - Beta',
98           'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
99           'Programming Language :: Python :: 2.6',
100           'Programming Language :: Python :: 2.7',
101           'Programming Language :: Python :: 3.4',
102           'Programming Language :: Python :: Implementation :: CPython',
103           'Programming Language :: Python :: Implementation :: PyPy',
104           'Operating System :: POSIX',
105           'Topic :: Software Development :: Version Control',
106       ],
107       ext_modules=ext_modules,
108       test_suite='dulwich.tests.test_suite',
109       tests_require=tests_require,
110       distclass=DulwichDistribution,
111       include_package_data=True,
112       )