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