]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - _auto_deps.py
Add tests for #939
[tahoe-lafs/tahoe-lafs.git] / _auto_deps.py
1 install_requires=[
2                   # we require newer versions of setuptools (actually
3                   # zetuptoolz) to build, but can handle older versions to run
4                   "setuptools >= 0.6c6",
5
6                   "zfec >= 1.1.0",
7
8                   # Feisty has simplejson 1.4
9                   "simplejson >= 1.4",
10
11                   "zope.interface",
12                   "Twisted >= 2.4.0",
13                   "foolscap[secure_connections] >= 0.4.1",
14                   "Nevow >= 0.6.0",
15
16                   # pycryptopp v0.5.15 applied a patch from Wei Dai to fix an
17                   # error in x86 assembly on CPUs that can't do SSE2.  Fixes
18                   # http://allmydata.org/trac/pycryptopp/ticket/24 .
19
20                   # pycryptopp v0.5.14 patched the embedded Crypto++ to remove
21                   # the usages of time functions, thus allowing mingw to build
22                   # and link it for Python 2.6.  If I knew a convenient,
23                   # reliable way to test whether the compiler that builds
24                   # pycryptopp will be mingw then I guess I would add that,
25                   # along with the Python >= v2.6 and the platform == Windows.
26                   # This is to work-around
27                   # http://sourceforge.net/tracker/?func=detail&aid=2805976&group_id=2435&atid=302435
28                   # .
29                   "pycryptopp >= 0.5.15",
30
31                   # Used for SFTP
32                   "pycrypto >= 2.0.1",
33                   ]
34
35 # Sqlite comes built into Python >= 2.5, and is provided by the "pysqlite"
36 # distribution for Python 2.4.
37 import sys
38 if sys.version_info < (2, 5):
39     # pysqlite v2.0.5 was shipped in Ubuntu 6.06 LTS "dapper" and Nexenta NCP 1.
40     install_requires.append("pysqlite >= 2.0.5")
41
42 ## The following block is commented-out because there is not currently a pywin32 package which
43 ## can be easy_install'ed and also which actually makes "import win32api" succeed.
44 ## See http://sourceforge.net/tracker/index.php?func=detail&aid=1799934&group_id=78018&atid=551954
45 ## Users have to manually install pywin32 on Windows before installing Tahoe.
46 ##import platform
47 ##if platform.system() == "Windows":
48 ##    # Twisted requires pywin32 if it is going to offer process management functionality, or if
49 ##    # it is going to offer iocp reactor.  We currently require process management.  It would be
50 ##    # better if Twisted would declare that it requires pywin32 if it is going to offer process
51 ##    # management.  That is twisted ticket #3238 -- http://twistedmatrix.com/trac/ticket/3238 .
52 ##    # On the other hand, Tahoe also depends on pywin32 for getting free disk space statistics
53 ##    # (although that is not a hard requirement: if win32api can't be imported then we don't
54 ##    # rely on having the disk stats).
55 ##    install_requires.append('pywin32')
56
57 if hasattr(sys, 'frozen'): # for py2exe
58     install_requires=[]
59
60 def require_python_2_with_working_base64():
61     import sys
62     if sys.version_info[0] != 2:
63         raise NotImplementedError("Tahoe-LAFS current requires Python v2.4.2 or greater (but less than v3), not %r" % (sys.version_info,))
64
65     # make sure we have a working base64.b32decode. The one in
66     # python2.4.[01] was broken.
67     nodeid_b32 = 't5g7egomnnktbpydbuijt6zgtmw4oqi5'
68     import base64
69     nodeid = base64.b32decode(nodeid_b32.upper())
70     if nodeid != "\x9fM\xf2\x19\xcckU0\xbf\x03\r\x10\x99\xfb&\x9b-\xc7A\x1d":
71         raise NotImplementedError("There is a bug in this base64 module: %r.  This was a known issue in Python v2.4.0 and v2.4.1 (http://bugs.python.org/issue1171487 ).  Tahoe-LAFS current requires Python v2.4.2 or greater (but less than v3).  The current Python version is %r" % (base64, sys.version_info,))
72
73 def require_auto_deps():
74     """
75     The purpose of this function is to raise a pkg_resources exception if any of the
76     requirements can't be imported.  This is just to give earlier and more explicit error
77     messages, as opposed to waiting until the source code tries to import some module from one
78     of these packages and gets an ImportError.  This function gets called from
79     src/allmydata/__init__.py .
80     """
81     require_python_2_with_working_base64()
82
83     import pkg_resources
84     for requirement in install_requires:
85         try:
86             pkg_resources.require(requirement)
87         except pkg_resources.DistributionNotFound:
88             # there is no .egg-info present for this requirement, which
89             # either means that it isn't installed, or it is installed in a
90             # way that pkg_resources can't find it (but regular python
91             # might).  There are several older Linux distributions which
92             # provide our dependencies just fine, but they don't ship
93             # .egg-info files. Note that if there *is* an .egg-info file,
94             # but it shows a too-old version, then we'll get a
95             # VersionConflict error instead of DistributionNotFound.
96             pass
97
98 def get_package_versions_from_setuptools():
99     import pkg_resources
100     return dict([(p.project_name, (p.version, p.location)) for p in pkg_resources.require('allmydata-tahoe')])