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