]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - setup.py
setup: patch from Chris Galvan to build sdists with no deps in them normally, but...
[tahoe-lafs/tahoe-lafs.git] / setup.py
1 #! /usr/bin/env python
2
3 # Allmydata Tahoe -- secure, distributed storage grid
4 #
5 # Copyright (C) 2008 Allmydata, Inc.
6 #
7 # This file is part of tahoe.
8 #
9 # See the docs/about.html file for licensing information.
10
11 import os, re, sys
12
13 try:
14     from ez_setup import use_setuptools
15 except ImportError:
16     pass
17 else:
18     # This invokes our own customized version of ez_setup.py to make sure that
19     # setuptools >= v0.6c8 (a.k.a. v0.6-final) is installed.
20
21     # setuptools < v0.6c8 doesn't handle eggs which get installed into the CWD
22     # as a result of being transitively depended on in a setup_requires, but
23     # then are needed for the installed code to run, i.e. in an
24     # install_requires.
25     use_setuptools(download_delay=0, min_version="0.6c8")
26
27 from setuptools import Extension, find_packages, setup
28 from setuptools.command import sdist
29
30 # Make the dependency-version-requirement, which is used by the Makefile at
31 # build-time, also available to the app at runtime:
32 import shutil
33 try:
34     shutil.copyfile("_auto_deps.py", os.path.join("src", "allmydata", "_auto_deps.py"))
35 except EnvironmentError:
36     # Nevermind then -- perhaps it is already in place and in any case we can do
37     # without it.
38     pass
39
40 trove_classifiers=[
41     "Development Status :: 5 - Production/Stable",
42     "Environment :: Console",
43     "Environment :: Web Environment",
44     "License :: OSI Approved :: GNU General Public License (GPL)",
45     "License :: DFSG approved",
46     "License :: Other/Proprietary License",
47     "Intended Audience :: Developers",
48     "Intended Audience :: End Users/Desktop",
49     "Intended Audience :: System Administrators",
50     "Operating System :: Microsoft",
51     "Operating System :: Microsoft :: Windows",
52     "Operating System :: Unix",
53     "Operating System :: POSIX :: Linux",
54     "Operating System :: POSIX",
55     "Operating System :: MacOS :: MacOS X",
56     "Operating System :: Microsoft :: Windows :: Windows NT/2000",
57     "Operating System :: OS Independent",
58     "Natural Language :: English",
59     "Programming Language :: C",
60     "Programming Language :: Python",
61     "Topic :: Utilities",
62     "Topic :: System :: Systems Administration",
63     "Topic :: System :: Filesystems",
64     "Topic :: System :: Distributed Computing",
65     "Topic :: Software Development :: Libraries",
66     "Topic :: Communications :: Usenet News",
67     "Topic :: System :: Archiving :: Backup",
68     "Topic :: System :: Archiving :: Mirroring",
69     "Topic :: System :: Archiving",
70     ]
71
72
73 VERSIONFILE = "src/allmydata/_version.py"
74 verstr = "unknown"
75 try:
76     verstrline = open(VERSIONFILE, "rt").read()
77 except EnvironmentError:
78     pass # Okay, there is no version file.
79 else:
80     VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
81     mo = re.search(VSRE, verstrline, re.M)
82     if mo:
83         verstr = mo.group(1)
84     else:
85         print "unable to find version in %s" % (VERSIONFILE,)
86         raise RuntimeError("if %s.py exists, it is required to be well-formed" % (VERSIONFILE,))
87
88 LONG_DESCRIPTION=\
89 """Welcome to the Tahoe project, a secure, decentralized, fault-tolerant
90 filesystem.  All of the source code is available under a Free Software, Open
91 Source licence.
92
93 This filesystem is encrypted and spread over multiple peers in such a way that
94 it remains available even when some of the peers are unavailable,
95 malfunctioning, or malicious."""
96
97 # For Desert Island builds, assume that the user has extracted the dependency
98 # tarball into a directory named 'misc/dependencies'.
99 dependency_links=[os.path.join(os.getcwd(), 'misc', 'dependencies')]
100
101 # By adding a web page to the dependency_links we are able to put new packages
102 # up there and have them be automatically discovered by existing copies of the
103 # tahoe source when that source was built.
104 dependency_links.append("http://allmydata.org/trac/tahoe/wiki/Dependencies")
105
106 # Default setup_requires are pyutil for the Windows installer builder(see
107 # misc/sub-ver.py) and Twisted for the tests.
108 #setup_requires = ['pyutil >= 1.3.16', 'Twisted >= 2.4.0']
109 setup_requires = []
110 # darcsver is needed only if you want "./setup.py darcsver" to write a new
111 # version stamp in src/allmydata/_version.py, with a version number derived from
112 # darcs history.
113 # http://pypi.python.org/pypi/darcsver
114 if 'darcsver' in sys.argv[1:]:
115     setup_requires.append('darcsver >= 1.1.5')
116
117 # setuptools_darcs is required to produce complete distributions (such as with
118 # "sdist" or "bdist_egg"), unless there is a PKG-INFO file present which shows
119 # that this is itself a source distribution.
120 # http://pypi.python.org/pypi/setuptools_darcs
121 if not os.path.exists('PKG-INFO'):
122     setup_requires.append('setuptools_darcs >= 1.1.0')
123
124 class MySdist(sdist.sdist):
125     """ A hook in the sdist command so that we can determine whether this the
126     tarball should be 'SUMO' or not, i.e. whether or not to include the
127     external dependency tarballs.
128     """
129
130     # Add our own sumo option to the sdist command, which toggles the
131     # external dependencies being included in the sdist.
132     user_options = sdist.sdist.user_options + \
133         [('sumo', 's', "create a 'sumo' sdist which includes the external " \
134           "dependencies")]
135     boolean_options = ['sumo']
136
137     def initialize_options(self):
138         sdist.sdist.initialize_options(self)
139         self.sumo = None
140
141     def run(self):
142         self.run_command('egg_info')
143         ei_cmd = self.get_finalized_command('egg_info')
144         self.filelist = ei_cmd.filelist
145         self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt'))
146
147         # If '--sumo' wasn't specified in the arguments, do not include
148         # the external dependency tarballs in the sdist.
149         if not self.sumo:
150             self.filelist.exclude_pattern(None, prefix='misc/dependencies')
151
152         print self.filelist.files
153         self.check_readme()
154         self.check_metadata()
155         self.make_distribution()
156
157         dist_files = getattr(self.distribution,'dist_files',[])
158         for file in self.archive_files:
159             data = ('sdist', '', file)
160             if data not in dist_files:
161                 dist_files.append(data)
162
163 import _auto_deps
164
165 setup(name='allmydata-tahoe',
166       version=verstr,
167       description='secure, decentralized, fault-tolerant filesystem',
168       long_description=LONG_DESCRIPTION,
169       author='the allmydata.org Tahoe project',
170       author_email='tahoe-dev@allmydata.org',
171       url='http://allmydata.org/',
172       license='GNU GPL',
173       cmdclass={'sdist': MySdist},
174       package_dir = {'':'src'},
175       packages=find_packages("src"),
176       classifiers=trove_classifiers,
177       test_suite="allmydata.test",
178       install_requires=_auto_deps.install_requires,
179       include_package_data=True,
180       setup_requires=setup_requires,
181       dependency_links=dependency_links,
182       entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] },
183       zip_safe=False, # We prefer unzipped for easier access.
184       )