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
|
|
|
|
2012-03-08 23:17:19 +00:00
|
|
|
community web site: U{https://tahoe-lafs.org/}
|
2007-04-19 20:47:59 +00:00
|
|
|
"""
|
2021-03-30 15:05:49 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2021-04-16 15:55:20 +00:00
|
|
|
from future.utils import PY2, PY3
|
2021-03-30 15:05:49 +00:00
|
|
|
if PY2:
|
|
|
|
# Don't import future str() so we don't break Foolscap serialization on Python 2.
|
|
|
|
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, max, min # noqa: F401
|
|
|
|
from past.builtins import unicode as str
|
2019-03-30 15:58:02 +00:00
|
|
|
|
2019-08-13 19:11:01 +00:00
|
|
|
__all__ = [
|
|
|
|
"__version__",
|
|
|
|
"__appname__",
|
|
|
|
"__full_version__",
|
|
|
|
]
|
2010-05-23 22:11:57 +00:00
|
|
|
|
2021-10-14 14:58:41 +00:00
|
|
|
def _discover_version():
|
|
|
|
try:
|
|
|
|
from allmydata._version import version
|
|
|
|
except ImportError:
|
|
|
|
# Perhaps we're running from a git checkout where the _version.py file
|
|
|
|
# hasn't been generated yet. Try to discover the version using git
|
|
|
|
# information instead.
|
|
|
|
try:
|
|
|
|
import setuptools_scm
|
|
|
|
return setuptools_scm.get_version()
|
|
|
|
except Exception:
|
|
|
|
return "unknown"
|
|
|
|
else:
|
|
|
|
return version
|
2007-04-19 20:47:59 +00:00
|
|
|
|
2016-08-08 01:46:59 +00:00
|
|
|
__appname__ = "tahoe-lafs"
|
2021-10-14 14:58:41 +00:00
|
|
|
__version__ = _discover_version()
|
|
|
|
del _discover_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
|
|
|
|
2016-08-08 01:46:59 +00:00
|
|
|
# __full_version__ is the one that you ought to use when identifying yourself
|
|
|
|
# in the "application" part of the Tahoe versioning scheme:
|
2012-03-08 23:17:19 +00:00
|
|
|
# https://tahoe-lafs.org/trac/tahoe-lafs/wiki/Versioning
|
2009-02-13 05:37:38 +00:00
|
|
|
__full_version__ = __appname__ + '/' + str(__version__)
|
2020-07-02 18:31:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Install Python 3 module locations in Python 2:
|
|
|
|
from future import standard_library
|
|
|
|
standard_library.install_aliases()
|
2020-10-01 14:48:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Monkey-patch 3rd party libraries:
|
|
|
|
from ._monkeypatch import patch
|
|
|
|
patch()
|
|
|
|
del patch
|
2021-04-16 15:55:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
# On Python 3, turn BytesWarnings into exceptions. This can have potential
|
|
|
|
# production impact... if BytesWarnings are actually present in the codebase.
|
|
|
|
# Given that this has been enabled before Python 3 Tahoe-LAFS was publicly
|
|
|
|
# released, no such code should exist, and this will ensure it doesn't get
|
|
|
|
# added either.
|
|
|
|
#
|
|
|
|
# Also note that BytesWarnings only happen if Python is run with -b option, so
|
|
|
|
# in practice this should only affect tests.
|
|
|
|
if PY3:
|
|
|
|
import warnings
|
|
|
|
# Error on BytesWarnings, to catch things like str(b""), but only for
|
|
|
|
# allmydata code.
|
|
|
|
warnings.filterwarnings("error", category=BytesWarning, module=".*allmydata.*")
|