3 # zfec -- fast forward error correction library with Python interface
5 # Copyright (C) 2007-2010 Allmydata, Inc.
6 # Author: Zooko Wilcox-O'Hearn
8 # This file is part of zfec.
10 # See README.txt for licensing information.
14 miscdeps=os.path.join(os.getcwd(), 'misc', 'dependencies')
17 from ez_setup import use_setuptools
21 # 0.6c7 on Windows and 0.6c6 on Ubuntu had a problem with multiple
22 # overlapping dependencies on pyutil -- it would end up with the 'pyutil'
23 # key set in sys.modules but the actual code (and the temporary directory
24 # in the filesystem in which the code used to reside) gone, when it needed
26 # On cygwin there was a conflict with swig with setuptools 0.6c7:
27 # File "/home/Buildslave/windows-cygwin-pycryptopp/windows-cygwin/build/misc/dependencies/setuptools-0.6c7.egg/setuptools/command/build_ext.py", line 77, in swig_sources
28 # TypeError: swig_sources() takes exactly 3 arguments (2 given)
29 # If there isn't a setuptools already installed, then this will install
30 # setuptools v0.6c12dev (which is our own toothpick of setuptools).
31 use_setuptools(download_delay=0, min_version="0.6c12dev")
33 from setuptools import Extension, find_packages, setup
35 if "--debug" in sys.argv:
37 sys.argv.remove("--debug")
44 extra_compile_args.append("-std=c99")
50 if arg.startswith("--stride="):
51 stride = int(arg[len("--stride="):])
52 define_macros.append(('STRIDE', stride))
57 extra_compile_args.append("-O0")
58 extra_compile_args.append("-g")
59 extra_compile_args.append("-Wall")
60 extra_link_args.append("-g")
61 undef_macros.append('NDEBUG')
64 "Development Status :: 5 - Production/Stable",
65 "Environment :: Console",
66 "License :: OSI Approved :: GNU General Public License (GPL)",
67 "License :: DFSG approved",
68 "License :: Other/Proprietary License",
69 "Intended Audience :: Developers",
70 "Intended Audience :: End Users/Desktop",
71 "Intended Audience :: System Administrators",
72 "Operating System :: Microsoft",
73 "Operating System :: Microsoft :: Windows",
74 "Operating System :: Unix",
75 "Operating System :: POSIX :: Linux",
76 "Operating System :: POSIX",
77 "Operating System :: MacOS :: MacOS X",
78 "Operating System :: Microsoft :: Windows :: Windows NT/2000",
79 "Operating System :: OS Independent",
80 "Natural Language :: English",
81 "Programming Language :: C",
82 "Programming Language :: Python",
83 "Programming Language :: Python :: 2",
84 "Programming Language :: Python :: 2.4",
85 "Programming Language :: Python :: 2.5",
87 "Topic :: System :: Systems Administration",
88 "Topic :: System :: Filesystems",
89 "Topic :: System :: Distributed Computing",
90 "Topic :: Software Development :: Libraries",
91 "Topic :: Communications :: Usenet News",
92 "Topic :: System :: Archiving :: Backup",
93 "Topic :: System :: Archiving :: Mirroring",
94 "Topic :: System :: Archiving",
98 VERSIONFILE = os.path.join(PKG, "_version.py")
101 verstrline = open(VERSIONFILE, "rt").read()
102 except EnvironmentError:
103 pass # Okay, there is no version file.
105 VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
106 mo = re.search(VSRE, verstrline, re.M)
110 print "unable to find version in %s" % (VERSIONFILE,)
111 raise RuntimeError("if %s.py exists, it is required to be well-formed" % (VERSIONFILE,))
113 dependency_links=[os.path.join(miscdeps, t) for t in os.listdir(miscdeps) if t.endswith(".tar")]
116 # The darcsver command from the darcsver plugin is needed to initialize the
117 # distribution's .version attribute correctly. (It does this either by
118 # examining darcs history, or if that fails by reading the
119 # zfec/_version.py file). darcsver will also write a new version
120 # stamp in zfec/_version.py, with a version number derived from
121 # darcs history. Note that the setup.cfg file has an "[aliases]" section
122 # which enumerates commands that you might run and specifies that it will run
123 # darcsver before each one. If you add different commands (or if I forgot
124 # some that are already in use), you may need to add it to setup.cfg and
125 # configure it to run darcsver before your command, if you want the version
126 # number to be correct when that command runs.
127 # http://pypi.python.org/pypi/darcsver
128 setup_requires.append('darcsver >= 1.2.0')
130 # setuptools_darcs is required to produce complete distributions (such as with
131 # "sdist" or "bdist_egg"), unless there is a zfec.egg-info/SOURCE.txt file
132 # present which contains a complete list of files that should be included.
133 # http://pypi.python.org/pypi/setuptools_darcs
134 setup_requires.append('setuptools_darcs >= 1.1.0')
136 # stdeb is required to build Debian dsc files.
137 if "sdist_dsc" in sys.argv:
138 setup_requires.append('stdeb')
140 data_fnames=[ 'COPYING.GPL', 'changelog', 'COPYING.TGPPL.html', 'TODO', 'README.txt' ]
142 # In case we are building for a .deb with stdeb's sdist_dsc command, we put the
143 # docs in "share/doc/$PKG".
144 doc_loc = "share/doc/" + PKG
145 data_files = [(doc_loc, data_fnames)]
147 def _setup(test_suite):
150 description='a fast erasure codec which can be used with the command-line, C, Python, or Haskell',
151 long_description='Fast, portable, programmable erasure coding a.k.a. "forward error correction": the generation of redundant blocks of information such that if some blocks are lost then the original data can be recovered from the remaining blocks. The zfec package includes command-line tools, C API, Python API, and Haskell API',
152 author='Zooko O\'Whielacronx',
153 author_email='zooko@zooko.com',
154 url='http://allmydata.org/trac/'+PKG,
156 dependency_links=dependency_links,
157 install_requires=["argparse >= 0.8", "pyutil >= 1.3.19"],
158 tests_require=["pyutil >= 1.3.19"],
159 packages=find_packages(),
160 include_package_data=True,
161 data_files=data_files,
162 setup_requires=setup_requires,
163 classifiers=trove_classifiers,
164 entry_points = { 'console_scripts': [ 'zfec = %s.cmdline_zfec:main' % PKG, 'zunfec = %s.cmdline_zunfec:main' % PKG ] },
165 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),],
166 test_suite=test_suite,
167 zip_safe=False, # I prefer unzipped for easier access.
170 test_suite_name=PKG+".test"
172 _setup(test_suite=test_suite_name)
173 except Exception, le:
174 # to work around a bug in Elisa v0.3.5
175 # https://bugs.launchpad.net/elisa/+bug/263697
176 if "test_suite must be a list" in str(le):
177 _setup(test_suite=[test_suite_name])