]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - zfec/setup.py
a000c82af0348cf4cb2738fa1e68b47185c5f971
[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.rst 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 # darcsver is needed only if you want "./setup.py darcsver" to write a new
104 # version stamp in pyutil/_version.py, with a version number derived from
105 # darcs history.  http://pypi.python.org/pypi/darcsver
106 if 'darcsver' in sys.argv[1:]:
107     setup_requires.append('darcsver >= 1.0.0')
108
109 # setuptools_darcs is required to produce complete distributions (such
110 # as with "sdist" or "bdist_egg"), unless there is a
111 # zfec.egg-info/SOURCE.txt file present which contains a complete
112 # list of files that should be included.
113 # http://pypi.python.org/pypi/setuptools_darcs
114
115 # However, requiring it runs afoul of a bug in Distribute, which was
116 # shipped in Ubuntu Lucid, so for now you have to manually install it
117 # before building sdists or eggs:
118 # http://bitbucket.org/tarek/distribute/issue/55/revision-control-plugin-automatically-installed-as-a-build-dependency-is-not-present-when-another-build-dependency-is-being
119 if False:
120     setup_requires.append('setuptools_darcs >= 1.1.0')
121
122
123 setup_requires.append('setuptools_trial >= 0.5')
124
125 # trialcoverage is required if you want the "trial" unit test runner to have a
126 # "--reporter=bwverbose-coverage" option which produces code-coverage results.
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     tests_require.append('setuptools_trial >= 0.5')
131
132 # stdeb is required to build Debian dsc files.
133 if "sdist_dsc" in sys.argv:
134     setup_requires.append('stdeb')
135
136 data_fnames=[ 'COPYING.GPL', 'changelog', 'COPYING.TGPPL.html', 'TODO', 'README.rst' ]
137
138 # In case we are building for a .deb with stdeb's sdist_dsc command, we put the
139 # docs in "share/doc/$PKG".
140 doc_loc = "share/doc/" + PKG
141 data_files = [(doc_loc, data_fnames)]
142
143 readmetext = open('README.rst').read()
144 if readmetext[:3] == '\xef\xbb\xbf':
145     # utf-8 "BOM"
146     readmetext = readmetext[3:].decode('utf-8')
147
148 setup(name=PKG,
149       version=verstr,
150       description='a fast erasure codec which can be used with the command-line, C, Python, or Haskell',
151       long_description=readmetext,
152       author='Zooko O\'Whielacronx',
153       author_email='zooko@zooko.com',
154       url='http://tahoe-lafs.org/trac/'+PKG,
155       license='GNU GPL',
156       install_requires=["argparse >= 0.8", "pyutil >= 1.3.19"],
157       tests_require=tests_require,
158       packages=find_packages(),
159       include_package_data=True,
160       data_files=data_files,
161       setup_requires=setup_requires,
162       classifiers=trove_classifiers,
163       entry_points = { 'console_scripts': [ 'zfec = %s.cmdline_zfec:main' % PKG, 'zunfec = %s.cmdline_zunfec:main' % PKG ] },
164       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),],
165       test_suite=PKG+".test",
166       zip_safe=False, # I prefer unzipped for easier access.
167       )