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