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