2 # zfec -- fast forward error correction library with Python interface
4 # copyright © 2007-2013 Zooko Wilcox-O'Hearn
6 # This file is part of zfec.
8 # See README.rst for licensing information.
10 import glob, os, re, sys
13 from setuptools import Extension, find_packages, setup
15 if "--debug" in sys.argv:
17 sys.argv.remove("--debug")
24 extra_compile_args.append("-std=c99")
30 if arg.startswith("--stride="):
31 stride = int(arg[len("--stride="):])
32 define_macros.append(('STRIDE', stride))
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')
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",
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",
81 VERSIONFILE = os.path.join(PKG, "_version.py")
84 verstrline = open(VERSIONFILE, "rt").read()
85 except EnvironmentError:
86 pass # Okay, there is no version file.
88 VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
89 mo = re.search(VSRE, verstrline, re.M)
93 print "unable to find version in %s" % (VERSIONFILE,)
94 raise RuntimeError("if %s.py exists, it is required to be well-formed" % (VERSIONFILE,))
99 tests_require.append("pyutil >= 1.3.19")
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')
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
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
118 setup_requires.append('setuptools_darcs >= 1.1.0')
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'])
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')
134 # stdeb is required to build Debian dsc files.
135 if "sdist_dsc" in sys.argv:
136 setup_requires.append('stdeb')
138 data_fnames=[ 'COPYING.GPL', 'changelog', 'COPYING.TGPPL.rst', 'TODO', 'README.rst' ]
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)]
145 readmetext = open('README.rst').read()
146 if readmetext[:3] == '\xef\xbb\xbf':
148 readmetext = readmetext[3:]
151 readmetext = readmetext.decode('utf-8')
152 except UnicodeDecodeError:
155 install_requires=["pyutil >= 1.3.19"]
157 # argparse comes built into Python >= 2.7, and is provided by the "argparse"
158 # distribution for earlier versions of Python.
161 argparse # hush pyflakes
163 install_requires.append("argparse >= 0.8")
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.
169 def _setup(longdescription):
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.
190 'ed25519=ba95497adf4db8e17f688c0979003c48c76897d60e2d2193f938b9ab62115f59':[],
196 except UnicodeEncodeError:
197 _setup(repr(readmetext))