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