Dulwich 0.16.0.
[jelmer/dulwich.git] / setup.py
1 #!/usr/bin/python
2 # encoding: utf-8
3 # Setup file for dulwich
4 # Copyright (C) 2008-2016 Jelmer Vernooij <jelmer@jelmer.uk>
5
6 try:
7     from setuptools import setup, Extension
8 except ImportError:
9     from distutils.core import setup, Extension
10 from distutils.core import Distribution
11
12 dulwich_version_string = '0.16.0'
13
14 include_dirs = []
15 # Windows MSVC support
16 import os
17 import sys
18 if sys.platform == 'win32':
19     include_dirs.append('dulwich')
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
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 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
55 if sys.version_info[0] > 2 and sys.platform == 'win32':
56     # C Modules don't build for python3 windows, and prevent tests from running
57     ext_modules = []
58 else:
59     ext_modules = [
60         Extension('dulwich._objects', ['dulwich/_objects.c'],
61                   include_dirs=include_dirs),
62         Extension('dulwich._pack', ['dulwich/_pack.c'],
63                   include_dirs=include_dirs),
64         Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
65                   include_dirs=include_dirs),
66     ]
67
68
69 setup(name='dulwich',
70       description='Python Git Library',
71       keywords='git',
72       version=dulwich_version_string,
73       url='https://www.dulwich.io/',
74       license='Apachev2 or later or GPLv2',
75       author='Jelmer Vernooij',
76       author_email='jelmer@jelmer.uk',
77       long_description="""
78       Python implementation of the Git file formats and protocols,
79       without the need to have git installed.
80
81       All functionality is available in pure Python. Optional
82       C extensions can be built for improved performance.
83
84       The project is named after the part of London that Mr. and Mrs. Git live in
85       in the particular Monty Python sketch.
86       """,
87       packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat', 'dulwich.contrib'],
88       package_data={'': ['../docs/tutorial/*.txt']},
89       scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
90       classifiers=[
91           'Development Status :: 4 - Beta',
92           'License :: OSI Approved :: Apache Software License',
93           'Programming Language :: Python :: 2.7',
94           'Programming Language :: Python :: 3.4',
95           'Programming Language :: Python :: 3.5',
96           'Programming Language :: Python :: Implementation :: CPython',
97           'Programming Language :: Python :: Implementation :: PyPy',
98           'Operating System :: POSIX',
99           'Topic :: Software Development :: Version Control',
100       ],
101       ext_modules=ext_modules,
102       test_suite='dulwich.tests.test_suite',
103       tests_require=tests_require,
104       distclass=DulwichDistribution,
105       include_package_data=True,
106       )