2007-04-19 20:47:59 +00:00
|
|
|
"""
|
2007-04-30 20:06:09 +00:00
|
|
|
Decentralized storage grid.
|
2007-04-19 20:47:59 +00:00
|
|
|
|
|
|
|
maintainer web site: U{http://allmydata.com/}
|
|
|
|
|
|
|
|
community web site: U{http://allmydata.org/}
|
|
|
|
"""
|
|
|
|
|
2007-05-04 03:14:07 +00:00
|
|
|
__version__ = "unknown"
|
|
|
|
try:
|
2007-08-16 21:09:30 +00:00
|
|
|
from _version import __version__
|
2007-05-04 03:14:07 +00:00
|
|
|
except ImportError:
|
2008-01-22 17:22:51 +00:00
|
|
|
# We're running in a tree that hasn't run "./setup.py darcsver", and didn't
|
|
|
|
# come with a _version.py, so we don't know what our version is. This should
|
|
|
|
# not happen very often.
|
2007-05-04 03:14:07 +00:00
|
|
|
pass
|
2007-04-19 20:47:59 +00:00
|
|
|
|
versioning: include an "appname" in the application version string in the versioning protocol, and make that appname be controlled by setup.py
It is currently hardcoded in setup.py to be 'allmydata-tahoe'. Ticket #556 is to make it configurable by a runtime command-line argument to setup.py: "--appname=foo", but I suddenly wondered if we really wanted that and at the same time realized that we don't need that for tahoe-1.3.0 release, so this patch just hardcodes it in setup.py.
setup.py inspects a file named 'src/allmydata/_appname.py' and assert that it contains the string "__appname__ = 'allmydata-tahoe'", and creates it if it isn't already present. src/allmydata/__init__.py import _appname and reads __appname__ from it. The rest of the Python code imports allmydata and inspects "allmydata.__appname__", although actually every use it uses "allmydata.__full_version__" instead, where "allmydata.__full_version__" is created in src/allmydata/__init__.py to be:
__full_version__ = __appname + '-' + str(__version__).
All the code that emits an "application version string" when describing what version of a protocol it supports (introducer server, storage server, upload helper), or when describing itself in general (introducer client), usese allmydata.__full_version__.
This fixes ticket #556 at least well enough for tahoe-1.3.0 release.
2009-02-12 00:18:16 +00:00
|
|
|
__appname__ = "unknown"
|
|
|
|
try:
|
|
|
|
from _appname import __appname__
|
|
|
|
except ImportError:
|
|
|
|
# We're running in a tree that hasn't run "./setup.py". This shouldn't happen.
|
|
|
|
pass
|
|
|
|
|
|
|
|
# __full_version__ is the one that you ought to use when identifying yourself in the
|
|
|
|
# "application" part of the Tahoe versioning scheme:
|
|
|
|
# http://allmydata.org/trac/tahoe/wiki/Versioning
|
2009-02-13 05:37:38 +00:00
|
|
|
__full_version__ = __appname__ + '/' + str(__version__)
|
versioning: include an "appname" in the application version string in the versioning protocol, and make that appname be controlled by setup.py
It is currently hardcoded in setup.py to be 'allmydata-tahoe'. Ticket #556 is to make it configurable by a runtime command-line argument to setup.py: "--appname=foo", but I suddenly wondered if we really wanted that and at the same time realized that we don't need that for tahoe-1.3.0 release, so this patch just hardcodes it in setup.py.
setup.py inspects a file named 'src/allmydata/_appname.py' and assert that it contains the string "__appname__ = 'allmydata-tahoe'", and creates it if it isn't already present. src/allmydata/__init__.py import _appname and reads __appname__ from it. The rest of the Python code imports allmydata and inspects "allmydata.__appname__", although actually every use it uses "allmydata.__full_version__" instead, where "allmydata.__full_version__" is created in src/allmydata/__init__.py to be:
__full_version__ = __appname + '-' + str(__version__).
All the code that emits an "application version string" when describing what version of a protocol it supports (introducer server, storage server, upload helper), or when describing itself in general (introducer client), usese allmydata.__full_version__.
This fixes ticket #556 at least well enough for tahoe-1.3.0 release.
2009-02-12 00:18:16 +00:00
|
|
|
|
2007-05-04 03:14:07 +00:00
|
|
|
hush_pyflakes = __version__
|
|
|
|
del hush_pyflakes
|
2007-04-19 20:47:59 +00:00
|
|
|
|
2008-04-30 20:22:04 +00:00
|
|
|
import _auto_deps
|
|
|
|
_auto_deps.require_auto_deps()
|
2008-01-23 00:42:54 +00:00
|
|
|
|
2009-01-19 22:04:35 +00:00
|
|
|
import os, platform, re, subprocess, sys
|
2008-09-23 17:14:31 +00:00
|
|
|
_distributor_id_cmdline_re = re.compile("(?:Distributor ID:)\s*(.*)", re.I)
|
|
|
|
_release_cmdline_re = re.compile("(?:Release:)\s*(.*)", re.I)
|
2008-09-23 16:28:58 +00:00
|
|
|
|
2008-09-23 17:14:31 +00:00
|
|
|
_distributor_id_file_re = re.compile("(?:DISTRIB_ID\s*=)\s*(.*)", re.I)
|
|
|
|
_release_file_re = re.compile("(?:DISTRIB_RELEASE\s*=)\s*(.*)", re.I)
|
2008-08-28 22:04:54 +00:00
|
|
|
|
2008-09-24 18:09:22 +00:00
|
|
|
global _distname,_version
|
|
|
|
_distname = None
|
|
|
|
_version = None
|
|
|
|
|
2008-09-22 23:53:54 +00:00
|
|
|
def get_linux_distro():
|
|
|
|
""" Tries to determine the name of the Linux OS distribution name.
|
|
|
|
|
2008-09-23 17:14:31 +00:00
|
|
|
First, try to parse a file named "/etc/lsb-release". If it exists, and
|
|
|
|
contains the "DISTRIB_ID=" line and the "DISTRIB_RELEASE=" line, then return
|
2008-09-24 18:09:22 +00:00
|
|
|
the strings parsed from that file.
|
|
|
|
|
|
|
|
If that doesn't work, then invoke platform.dist().
|
2008-09-23 17:14:31 +00:00
|
|
|
|
2008-09-24 18:09:22 +00:00
|
|
|
If that doesn't work, then try to execute "lsb_release", as standardized in
|
|
|
|
2001:
|
2008-09-22 23:53:54 +00:00
|
|
|
|
|
|
|
http://refspecs.freestandards.org/LSB_1.0.0/gLSB/lsbrelease.html
|
|
|
|
|
|
|
|
The current version of the standard is here:
|
|
|
|
|
|
|
|
http://refspecs.freestandards.org/LSB_3.2.0/LSB-Core-generic/LSB-Core-generic/lsbrelease.html
|
|
|
|
|
2008-09-23 17:14:31 +00:00
|
|
|
that lsb_release emitted, as strings.
|
2008-09-23 16:28:58 +00:00
|
|
|
|
2008-09-22 23:53:54 +00:00
|
|
|
Returns a tuple (distname,version). Distname is what LSB calls a
|
|
|
|
"distributor id", e.g. "Ubuntu". Version is what LSB calls a "release",
|
|
|
|
e.g. "8.04".
|
|
|
|
|
|
|
|
A version of this has been submitted to python as a patch for the standard
|
|
|
|
library module "platform":
|
|
|
|
|
|
|
|
http://bugs.python.org/issue3937
|
|
|
|
"""
|
2008-09-24 18:09:22 +00:00
|
|
|
global _distname,_version
|
|
|
|
if _distname and _version:
|
|
|
|
return (_distname, _version)
|
2008-09-23 16:28:58 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
etclsbrel = open("/etc/lsb-release", "rU")
|
2008-09-23 16:55:51 +00:00
|
|
|
for line in etclsbrel:
|
|
|
|
m = _distributor_id_file_re.search(line)
|
2008-09-23 16:28:58 +00:00
|
|
|
if m:
|
|
|
|
_distname = m.group(1).strip()
|
2008-09-23 17:14:31 +00:00
|
|
|
if _distname and _version:
|
|
|
|
return (_distname, _version)
|
2008-09-23 16:55:51 +00:00
|
|
|
m = _release_file_re.search(line)
|
2008-09-23 16:28:58 +00:00
|
|
|
if m:
|
|
|
|
_version = m.group(1).strip()
|
2008-09-23 17:14:31 +00:00
|
|
|
if _distname and _version:
|
|
|
|
return (_distname, _version)
|
2008-09-23 16:28:58 +00:00
|
|
|
except EnvironmentError:
|
|
|
|
pass
|
|
|
|
|
2008-09-24 18:09:22 +00:00
|
|
|
(_distname, _version) = platform.dist()[:2]
|
|
|
|
if _distname and _version:
|
|
|
|
return (_distname, _version)
|
|
|
|
|
2008-09-23 17:14:31 +00:00
|
|
|
try:
|
|
|
|
p = subprocess.Popen(["lsb_release", "--all"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
rc = p.wait()
|
|
|
|
if rc == 0:
|
|
|
|
for line in p.stdout.readlines():
|
|
|
|
m = _distributor_id_cmdline_re.search(line)
|
|
|
|
if m:
|
|
|
|
_distname = m.group(1).strip()
|
|
|
|
if _distname and _version:
|
|
|
|
return (_distname, _version)
|
|
|
|
|
|
|
|
m = _release_cmdline_re.search(p.stdout.read())
|
|
|
|
if m:
|
|
|
|
_version = m.group(1).strip()
|
|
|
|
if _distname and _version:
|
|
|
|
return (_distname, _version)
|
|
|
|
except EnvironmentError:
|
|
|
|
pass
|
2008-09-23 16:28:58 +00:00
|
|
|
|
2008-11-25 16:51:18 +00:00
|
|
|
if os.path.exists("/etc/arch-release"):
|
|
|
|
return ("Arch_Linux", "")
|
|
|
|
|
2008-09-24 18:09:22 +00:00
|
|
|
return (_distname,_version)
|
2008-09-22 23:53:54 +00:00
|
|
|
|
|
|
|
def get_platform():
|
|
|
|
# Our version of platform.platform(), telling us both less and more than the
|
|
|
|
# Python Standard Library's version does.
|
|
|
|
# We omit details such as the Linux kernel version number, but we add a
|
|
|
|
# more detailed and correct rendition of the Linux distribution and
|
|
|
|
# distribution-version.
|
|
|
|
if "linux" in platform.system().lower():
|
|
|
|
return platform.system()+"-"+"_".join(get_linux_distro())+"-"+platform.machine()+"-"+"_".join([x for x in platform.architecture() if x])
|
|
|
|
else:
|
|
|
|
return platform.platform()
|
|
|
|
|
2009-01-19 22:04:35 +00:00
|
|
|
def get_package_versions_and_locations():
|
2009-06-04 15:37:28 +00:00
|
|
|
# because there are a few dependencies that are outside setuptools's ken
|
|
|
|
# (Python and platform, and sqlite3 if you are on Python >= 2.5), and
|
|
|
|
# because setuptools might fail to find something even though import
|
|
|
|
# finds it:
|
2009-05-22 00:38:23 +00:00
|
|
|
import OpenSSL, allmydata, foolscap.api, nevow, platform, pycryptopp, setuptools, simplejson, twisted, zfec, zope.interface
|
2009-06-04 15:37:28 +00:00
|
|
|
pysqlitever = None
|
|
|
|
pysqlitefile = None
|
|
|
|
sqlitever = None
|
|
|
|
try:
|
|
|
|
import sqlite3
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
from pysqlite2 import dbapi2
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
pysqlitever = dbapi2.version
|
|
|
|
pysqlitefile = os.path.dirname(dbapi2.__file__)
|
|
|
|
sqlitever = dbapi2.sqlite_version
|
|
|
|
else:
|
|
|
|
pysqlitever = sqlite3.version
|
|
|
|
pysqlitefile = os.path.dirname(sqlite3.__file__)
|
|
|
|
sqlitever = sqlite3.sqlite_version
|
2009-01-19 22:04:35 +00:00
|
|
|
|
|
|
|
d1 = {
|
|
|
|
'pyOpenSSL': (OpenSSL.__version__, os.path.dirname(OpenSSL.__file__)),
|
|
|
|
'allmydata-tahoe': (allmydata.__version__, os.path.dirname(allmydata.__file__)),
|
2009-05-22 00:38:23 +00:00
|
|
|
'foolscap': (foolscap.api.__version__, os.path.dirname(foolscap.__file__)),
|
2009-01-19 22:04:35 +00:00
|
|
|
'Nevow': (nevow.__version__, os.path.dirname(nevow.__file__)),
|
|
|
|
'pycryptopp': (pycryptopp.__version__, os.path.dirname(pycryptopp.__file__)),
|
|
|
|
'setuptools': (setuptools.__version__, os.path.dirname(setuptools.__file__)),
|
|
|
|
'simplejson': (simplejson.__version__, os.path.dirname(simplejson.__file__)),
|
2009-06-04 15:37:28 +00:00
|
|
|
'pysqlite': (pysqlitever, pysqlitefile),
|
|
|
|
'sqlite': (sqlitever, 'unknown'),
|
2009-01-19 22:04:35 +00:00
|
|
|
'zope.interface': ('unknown', os.path.dirname(zope.interface.__file__)),
|
|
|
|
'Twisted': (twisted.__version__, os.path.dirname(twisted.__file__)),
|
|
|
|
'zfec': (zfec.__version__, os.path.dirname(zfec.__file__)),
|
|
|
|
'python': (platform.python_version(), sys.executable),
|
|
|
|
'platform': (get_platform(), None),
|
2007-12-13 02:37:37 +00:00
|
|
|
}
|
|
|
|
|
2009-01-19 22:04:35 +00:00
|
|
|
# But we prefer to get all the dependencies as known by setuptools:
|
|
|
|
import pkg_resources
|
|
|
|
try:
|
|
|
|
d2 = _auto_deps.get_package_versions_from_setuptools()
|
|
|
|
except pkg_resources.DistributionNotFound:
|
|
|
|
# See docstring in _auto_deps.require_auto_deps() to explain why it makes sense to ignore this exception.
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
d1.update(d2)
|
|
|
|
|
|
|
|
return d1
|
|
|
|
|
|
|
|
def get_package_versions():
|
|
|
|
return dict([(k, v) for k, (v, l) in get_package_versions_and_locations().iteritems()])
|
|
|
|
|
2009-01-16 19:47:51 +00:00
|
|
|
def get_package_locations():
|
2009-01-19 22:04:35 +00:00
|
|
|
return dict([(k, l) for k, (v, l) in get_package_versions_and_locations().iteritems()])
|
2009-01-16 19:47:51 +00:00
|
|
|
|
|
|
|
def get_package_versions_string(show_paths=False):
|
2009-01-19 22:04:35 +00:00
|
|
|
vers_and_locs = get_package_versions_and_locations()
|
2007-12-13 02:37:37 +00:00
|
|
|
res = []
|
2009-01-19 22:04:35 +00:00
|
|
|
for p in ["allmydata-tahoe", "foolscap", "pycryptopp", "zfec", "Twisted", "Nevow", "zope.interface", "python", "platform"]:
|
|
|
|
(ver, loc) = vers_and_locs.get(p, ('UNKNOWN', 'UNKNOWN'))
|
|
|
|
info = str(p) + ": " + str(ver)
|
2009-01-16 19:47:51 +00:00
|
|
|
if show_paths:
|
2009-01-19 22:04:35 +00:00
|
|
|
info = info + " (%s)" % str(loc)
|
2009-01-16 19:47:51 +00:00
|
|
|
res.append(info)
|
2009-01-19 22:04:35 +00:00
|
|
|
if vers_and_locs.has_key(p):
|
|
|
|
del vers_and_locs[p]
|
2009-01-16 19:47:51 +00:00
|
|
|
|
2009-01-19 22:04:35 +00:00
|
|
|
for p, (v, loc) in vers_and_locs.iteritems():
|
|
|
|
info = str(p) + ": " + str(v)
|
|
|
|
if show_paths:
|
|
|
|
info = info + " (%s)" % str(loc)
|
|
|
|
res.append(info)
|
2007-12-13 02:37:37 +00:00
|
|
|
return ', '.join(res)
|