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