Release 0.19.9
[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     has_setuptools = False
11 else:
12     has_setuptools = True
13 from distutils.core import Distribution
14 import io
15 import os
16 import sys
17
18 dulwich_version_string = '0.19.9'
19
20 include_dirs = []
21 # Windows MSVC support
22 if sys.platform == 'win32' and sys.version_info[:2] < (3, 6):
23     # Include dulwich/ for fallback stdint.h
24     include_dirs.append('dulwich')
25
26
27 class DulwichDistribution(Distribution):
28
29     def is_pure(self):
30         if self.pure:
31             return True
32
33     def has_ext_modules(self):
34         return not self.pure
35
36     global_options = Distribution.global_options + [
37         ('pure', None, "use pure Python code instead of C "
38                        "extensions (slower on CPython)")]
39
40     pure = False
41
42
43 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
44     # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
45     # distutils.sysconfig
46     import subprocess
47     p = subprocess.Popen(
48         ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
49         stderr=subprocess.PIPE, env={})
50     out, err = p.communicate()
51     for line in out.splitlines():
52         line = line.decode("utf8")
53         # Also parse only first digit, because 3.2.1 can't be parsed nicely
54         if (line.startswith('Xcode') and
55                 int(line.split()[1].split('.')[0]) >= 4):
56             os.environ['ARCHFLAGS'] = ''
57
58 tests_require = ['fastimport']
59
60
61 if '__pypy__' not in sys.modules and not sys.platform == 'win32':
62     tests_require.extend([
63         'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1'])
64
65
66 ext_modules = [
67     Extension('dulwich._objects', ['dulwich/_objects.c'],
68               include_dirs=include_dirs),
69     Extension('dulwich._pack', ['dulwich/_pack.c'],
70               include_dirs=include_dirs),
71     Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
72               include_dirs=include_dirs),
73 ]
74
75 setup_kwargs = {}
76
77 if has_setuptools:
78     setup_kwargs['extras_require'] = {
79         'fastimport': ['fastimport'],
80         'https': ['urllib3[secure]>=1.21'],
81         }
82     setup_kwargs['install_requires'] = ['urllib3>=1.21', 'certifi']
83     setup_kwargs['include_package_data'] = True
84     setup_kwargs['test_suite'] = 'dulwich.tests.test_suite'
85     setup_kwargs['tests_require'] = tests_require
86
87 with io.open(os.path.join(os.path.dirname(__file__), "README.md"),
88              encoding="utf-8") as f:
89     description = f.read()
90
91 setup(name='dulwich',
92       author="Jelmer Vernooij",
93       author_email="jelmer@jelmer.uk",
94       url="https://www.dulwich.io/",
95       long_description=description,
96       description="Python Git Library",
97       version=dulwich_version_string,
98       license='Apachev2 or later or GPLv2',
99       project_urls={
100           "Bug Tracker": "https://github.com/dulwich/dulwich/issues",
101           "Repository": "https://www.dulwich.io/code/",
102           "GitHub": "https://github.com/dulwich/dulwich",
103       },
104       keywords="git vcs",
105       packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat',
106                 'dulwich.contrib'],
107       package_data={'': ['../docs/tutorial/*.txt']},
108       scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
109       ext_modules=ext_modules,
110       distclass=DulwichDistribution,
111       classifiers=[
112           'Development Status :: 4 - Beta',
113           'License :: OSI Approved :: Apache Software License',
114           'Programming Language :: Python :: 2.7',
115           'Programming Language :: Python :: 3.4',
116           'Programming Language :: Python :: 3.5',
117           'Programming Language :: Python :: 3.6',
118           'Programming Language :: Python :: Implementation :: CPython',
119           'Programming Language :: Python :: Implementation :: PyPy',
120           'Operating System :: POSIX',
121           'Operating System :: Microsoft :: Windows',
122           'Topic :: Software Development :: Version Control',
123       ],
124       **setup_kwargs
125       )