]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - setup.py
setuptools: remove the dependency on a custom copy of setuptools
[tahoe-lafs/zfec.git] / setup.py
1 
2 # zfec -- fast forward error correction library with Python interface
3 #
4 # copyright © 2007-2013 Zooko Wilcox-O'Hearn
5 #
6 # This file is part of zfec.
7 #
8 # See README.rst for licensing information.
9
10 import glob, os, re, sys
11 import setuptools
12
13 from setuptools import Extension, find_packages, setup
14
15 if "--debug" in sys.argv:
16     DEBUGMODE=True
17     sys.argv.remove("--debug")
18 else:
19     DEBUGMODE=False
20
21 extra_compile_args=[]
22 extra_link_args=[]
23
24 extra_compile_args.append("-std=c99")
25
26 define_macros=[]
27 undef_macros=[]
28
29 for arg in sys.argv:
30     if arg.startswith("--stride="):
31         stride = int(arg[len("--stride="):])
32         define_macros.append(('STRIDE', stride))
33         sys.argv.remove(arg)
34         break
35
36 if DEBUGMODE:
37     extra_compile_args.append("-O0")
38     extra_compile_args.append("-g")
39     extra_compile_args.append("-Wall")
40     extra_compile_args.append("-Wextra")
41     extra_link_args.append("-g")
42     undef_macros.append('NDEBUG')
43
44 trove_classifiers=[
45     "Development Status :: 5 - Production/Stable",
46     "Environment :: Console",
47     "License :: OSI Approved :: GNU General Public License (GPL)", # See README.rst for alternative licensing.
48     "License :: DFSG approved",
49     "License :: Other/Proprietary License",
50     "Intended Audience :: Developers",
51     "Intended Audience :: End Users/Desktop",
52     "Intended Audience :: System Administrators",
53     "Operating System :: Microsoft",
54     "Operating System :: Microsoft :: Windows",
55     "Operating System :: Unix",
56     "Operating System :: POSIX :: Linux",
57     "Operating System :: POSIX",
58     "Operating System :: MacOS :: MacOS X",
59     "Operating System :: Microsoft :: Windows :: Windows NT/2000",
60     "Operating System :: OS Independent",
61     "Natural Language :: English",
62     "Programming Language :: C",
63     "Programming Language :: Python", 
64     "Programming Language :: Python :: 2",
65     "Programming Language :: Python :: 2.4",
66     "Programming Language :: Python :: 2.5",
67     "Programming Language :: Python :: 2.6",
68     "Programming Language :: Python :: 2.7",
69     "Topic :: Utilities",
70     "Topic :: System :: Systems Administration",
71     "Topic :: System :: Filesystems",
72     "Topic :: System :: Distributed Computing",
73     "Topic :: Software Development :: Libraries",
74     "Topic :: Communications :: Usenet News",
75     "Topic :: System :: Archiving :: Backup",
76     "Topic :: System :: Archiving :: Mirroring",
77     "Topic :: System :: Archiving",
78     ]
79
80 PKG = "zfec"
81 VERSIONFILE = os.path.join(PKG, "_version.py")
82 verstr = "unknown"
83 try:
84     verstrline = open(VERSIONFILE, "rt").read()
85 except EnvironmentError:
86     pass # Okay, there is no version file.
87 else:
88     VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
89     mo = re.search(VSRE, verstrline, re.M)
90     if mo:
91         verstr = mo.group(1)
92     else:
93         print "unable to find version in %s" % (VERSIONFILE,)
94         raise RuntimeError("if %s.py exists, it is required to be well-formed" % (VERSIONFILE,))
95
96 setup_requires = []
97 tests_require = []
98
99 tests_require.append("pyutil >= 1.3.19")
100
101 # darcsver is needed only if you want "./setup.py darcsver" to write a new
102 # version stamp in pyutil/_version.py, with a version number derived from
103 # darcs history.  http://pypi.python.org/pypi/darcsver
104 if 'darcsver' in sys.argv[1:]:
105     setup_requires.append('darcsver >= 1.0.0')
106
107 # setuptools_darcs is required to produce complete distributions (such
108 # as with "sdist" or "bdist_egg"), unless there is a
109 # zfec.egg-info/SOURCE.txt file present which contains a complete
110 # list of files that should be included.
111 # http://pypi.python.org/pypi/setuptools_darcs
112
113 # However, requiring it runs afoul of a bug in Distribute, which was
114 # shipped in Ubuntu Lucid, so for now you have to manually install it
115 # before building sdists or eggs:
116 # http://bitbucket.org/tarek/distribute/issue/55/revision-control-plugin-automatically-installed-as-a-build-dependency-is-not-present-when-another-build-dependency-is-being
117 if False:
118     setup_requires.append('setuptools_darcs >= 1.1.0')
119
120
121 # setuptools_trial is needed if you want "./setup.py trial" or
122 # "./setup.py test" to execute the tests.
123 # http://pypi.python.org/pypi/setuptools_trial
124 if 'trial' in sys.argv[1:]:
125     setup_requires.extend(['setuptools_trial >= 0.5'])
126
127 # trialcoverage is required if you want the "trial" unit test runner to have a
128 # "--reporter=bwverbose-coverage" option which produces code-coverage results.
129 if "--reporter=bwverbose-coverage" in sys.argv:
130     tests_require.append('trialcoverage >= 0.3.3')
131     tests_require.append('twisted >= 2.4.0')
132     tests_require.append('setuptools_trial >= 0.5')
133
134 # stdeb is required to build Debian dsc files.
135 if "sdist_dsc" in sys.argv:
136     setup_requires.append('stdeb')
137
138 data_fnames=[ 'COPYING.GPL', 'changelog', 'COPYING.TGPPL.rst', 'TODO', 'README.rst' ]
139
140 # In case we are building for a .deb with stdeb's sdist_dsc command, we put the
141 # docs in "share/doc/$PKG".
142 doc_loc = "share/doc/" + PKG
143 data_files = [(doc_loc, data_fnames)]
144
145 readmetext = open('README.rst').read()
146 if readmetext[:3] == '\xef\xbb\xbf':
147     # utf-8 "BOM"
148     readmetext = readmetext[3:]
149
150 try:
151     readmetext = readmetext.decode('utf-8')
152 except UnicodeDecodeError:
153     pass
154
155 install_requires=["pyutil >= 1.3.19"]
156
157 # argparse comes built into Python >= 2.7, and is provided by the "argparse"
158 # distribution for earlier versions of Python.
159 try:
160     import argparse
161     argparse # hush pyflakes
162 except ImportError:
163     install_requires.append("argparse >= 0.8")
164
165 # distutils in Python 2.4 has a bug in that it tries to encode the long
166 # description into ascii. We detect the resulting exception and try again
167 # after squashing the long description (lossily) into ascii.
168
169 def _setup(longdescription):
170     setup(name=PKG,
171           version=verstr,
172           description='a fast erasure codec which can be used with the command-line, C, Python, or Haskell',
173           long_description=longdescription,
174           author='Zooko O\'Whielacronx',
175           author_email='zooko@zooko.com',
176           url='https://tahoe-lafs.org/trac/'+PKG,
177           license='GNU GPL', # See README.rst for alternative licensing.
178           install_requires=install_requires,
179           tests_require=tests_require,
180           packages=find_packages(),
181           include_package_data=True,
182           data_files=data_files,
183           setup_requires=setup_requires,
184           classifiers=trove_classifiers,
185           entry_points = { 'console_scripts': [ 'zfec = %s.cmdline_zfec:main' % PKG, 'zunfec = %s.cmdline_zunfec:main' % PKG ] },
186           ext_modules=[Extension(PKG+'._fec', [PKG+'/fec.c', PKG+'/_fecmodule.c',], extra_link_args=extra_link_args, extra_compile_args=extra_compile_args, undef_macros=undef_macros, define_macros=define_macros),],
187           test_suite=PKG+".test",
188           zip_safe=False, # I prefer unzipped for easier access.
189           extras_require={
190             'ed25519=ba95497adf4db8e17f688c0979003c48c76897d60e2d2193f938b9ab62115f59':[],
191             },
192           )
193
194 try:
195     _setup(readmetext)
196 except UnicodeEncodeError:
197     _setup(repr(readmetext))