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