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