]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - zfec/setup.py
setup: upgrade the bundled copy of zetuptoolz from 0.6c10dev to 0.6c12dev and increas...
[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-2008 Allmydata, Inc.
6 # Author: Zooko Wilcox-O'Hearn
7
8 # This file is part of zfec.
9 #
10 # See README.txt for licensing information.
11
12 import os, re, sys
13
14 miscdeps=os.path.join(os.getcwd(), 'misc', 'dependencies')
15
16 try:
17     from ez_setup import use_setuptools
18 except ImportError:
19     pass
20 else:
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
25     # pyutil again later.
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     # This invokes our own customized version of ez_setup.py to make sure
30     # that setuptools v0.6c12dev (which is our own toothpick of setuptools)
31     # is used to build.
32     use_setuptools(download_delay=0, min_version="0.6c12dev")
33
34 from setuptools import Extension, find_packages, setup
35
36 if "--debug" in sys.argv:
37     DEBUGMODE=True
38     sys.argv.remove("--debug")
39 else:
40     DEBUGMODE=False
41
42 extra_compile_args=[]
43 extra_link_args=[]
44
45 extra_compile_args.append("-std=c99")
46
47 define_macros=[]
48 undef_macros=[]
49
50 for arg in sys.argv:
51     if arg.startswith("--stride="):
52         stride = int(arg[len("--stride="):])
53         define_macros.append(('STRIDE', stride))
54         sys.argv.remove(arg)
55         break
56
57 if DEBUGMODE:
58     extra_compile_args.append("-O0")
59     extra_compile_args.append("-g")
60     extra_compile_args.append("-Wall")
61     extra_link_args.append("-g")
62     undef_macros.append('NDEBUG')
63
64 trove_classifiers=[
65     "Development Status :: 5 - Production/Stable",
66     "Environment :: Console",
67     "License :: OSI Approved :: GNU General Public License (GPL)", 
68     "License :: DFSG approved",
69     "License :: Other/Proprietary License",
70     "Intended Audience :: Developers", 
71     "Intended Audience :: End Users/Desktop",
72     "Intended Audience :: System Administrators",
73     "Operating System :: Microsoft",
74     "Operating System :: Microsoft :: Windows",
75     "Operating System :: Unix",
76     "Operating System :: POSIX :: Linux",
77     "Operating System :: POSIX",
78     "Operating System :: MacOS :: MacOS X",
79     "Operating System :: Microsoft :: Windows :: Windows NT/2000",
80     "Operating System :: OS Independent", 
81     "Natural Language :: English", 
82     "Programming Language :: C", 
83     "Programming Language :: Python", 
84     "Programming Language :: Python :: 2",
85     "Programming Language :: Python :: 2.4",
86     "Programming Language :: Python :: 2.5",
87     "Topic :: Utilities",
88     "Topic :: System :: Systems Administration",
89     "Topic :: System :: Filesystems",
90     "Topic :: System :: Distributed Computing",
91     "Topic :: Software Development :: Libraries",
92     "Topic :: Communications :: Usenet News",
93     "Topic :: System :: Archiving :: Backup", 
94     "Topic :: System :: Archiving :: Mirroring", 
95     "Topic :: System :: Archiving", 
96     ]
97
98 PKG = "zfec"
99 VERSIONFILE = os.path.join(PKG, "_version.py")
100 verstr = "unknown"
101 try:
102     verstrline = open(VERSIONFILE, "rt").read()
103 except EnvironmentError:
104     pass # Okay, there is no version file.
105 else:
106     VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
107     mo = re.search(VSRE, verstrline, re.M)
108     if mo:
109         verstr = mo.group(1)
110     else:
111         print "unable to find version in %s" % (VERSIONFILE,)
112         raise RuntimeError("if %s.py exists, it is required to be well-formed" % (VERSIONFILE,))
113
114 dependency_links=[os.path.join(miscdeps, t) for t in os.listdir(miscdeps) if t.endswith(".tar")]
115 setup_requires = []
116
117 # The darcsver command from the darcsver plugin is needed to initialize the
118 # distribution's .version attribute correctly. (It does this either by
119 # examining darcs history, or if that fails by reading the
120 # zfec/_version.py file). darcsver will also write a new version
121 # stamp in zfec/_version.py, with a version number derived from
122 # darcs history. Note that the setup.cfg file has an "[aliases]" section
123 # which enumerates commands that you might run and specifies that it will run
124 # darcsver before each one. If you add different commands (or if I forgot
125 # some that are already in use), you may need to add it to setup.cfg and
126 # configure it to run darcsver before your command, if you want the version
127 # number to be correct when that command runs.
128 # http://pypi.python.org/pypi/darcsver
129 setup_requires.append('darcsver >= 1.2.0')
130
131 # setuptools_darcs is required to produce complete distributions (such as with
132 # "sdist" or "bdist_egg"), unless there is a zfec.egg-info/SOURCE.txt file
133 # present which contains a complete list of files that should be included.
134 # http://pypi.python.org/pypi/setuptools_darcs
135 setup_requires.append('setuptools_darcs >= 1.1.0')
136
137 # stdeb is required to build Debian dsc files.
138 if "sdist_dsc" in sys.argv:
139     setup_requires.append('stdeb')
140
141 data_fnames=[ 'COPYING.GPL', 'changelog', 'COPYING.TGPPL.html', 'TODO', 'README.txt' ]
142
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)]
147
148 def _setup(test_suite):
149     setup(name=PKG,
150           version=verstr,
151           description='a fast erasure codec which can be used with the command-line, C, Python, or Haskell',
152           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',
153           author='Zooko O\'Whielacronx',
154           author_email='zooko@zooko.com',
155           url='http://allmydata.org/trac/'+PKG,
156           license='GNU GPL',
157           dependency_links=dependency_links,
158           install_requires=["argparse >= 0.8", "pyutil >= 1.3.19"],
159           tests_require=["pyutil >= 1.3.19"],
160           packages=find_packages(),
161           include_package_data=True,
162           data_files=data_files,
163           setup_requires=setup_requires,
164           classifiers=trove_classifiers,
165           entry_points = { 'console_scripts': [ 'zfec = %s.cmdline_zfec:main' % PKG, 'zunfec = %s.cmdline_zunfec:main' % PKG ] },
166           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),],
167           test_suite=test_suite,
168           zip_safe=False, # I prefer unzipped for easier access.
169           )
170
171 test_suite_name=PKG+".test"
172 try:
173     _setup(test_suite=test_suite_name)
174 except Exception, le:
175     # to work around a bug in Elisa v0.3.5
176     # https://bugs.launchpad.net/elisa/+bug/263697
177     if "test_suite must be a list" in str(le):
178         _setup(test_suite=[test_suite_name])
179     else:
180         raise