summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-04-30 08:28:47 -0400
committerJason R. Coombs <jaraco@jaraco.com>2016-04-30 08:28:47 -0400
commit16bb278fdf441b59653872cb8a5dc749230a4fa8 (patch)
tree02c744875dd83cdc1cbaa8dc1aaa13184aeaad72
parent9e040522b817710e6a01d5c995972e57fde0cb5f (diff)
downloadcherrypy-16bb278fdf441b59653872cb8a5dc749230a4fa8.tar.gz
Version string is defined in only two places now - in the package metadata and in the SCM tags.
-rw-r--r--cherrypy/__init__.py11
-rw-r--r--cherrypy/wsgiserver/wsgiserver2.py12
-rw-r--r--cherrypy/wsgiserver/wsgiserver3.py12
3 files changed, 32 insertions, 3 deletions
diff --git a/cherrypy/__init__.py b/cherrypy/__init__.py
index 2c2443f0..30a8cadf 100644
--- a/cherrypy/__init__.py
+++ b/cherrypy/__init__.py
@@ -56,7 +56,10 @@ with customized or extended components. The core API's are:
These API's are described in the `CherryPy specification <https://bitbucket.org/cherrypy/cherrypy/wiki/CherryPySpec>`_.
"""
-__version__ = "5.1.0"
+try:
+ import pkg_resources
+except ImportError:
+ pass
from cherrypy._cpcompat import urljoin as _urljoin, urlencode as _urlencode
from cherrypy._cpcompat import basestring, unicodestr
@@ -88,6 +91,12 @@ except ImportError:
engine = process.bus
+try:
+ __version__ = pkg_resources.require('cherrypy')[0].version
+except Exception:
+ __version__ = 'unknown'
+
+
# Timeout monitor. We add two channels to the engine
# to which cherrypy.Application will publish.
engine.listeners['before_request'] = set()
diff --git a/cherrypy/wsgiserver/wsgiserver2.py b/cherrypy/wsgiserver/wsgiserver2.py
index 175affc1..f3ae1f9d 100644
--- a/cherrypy/wsgiserver/wsgiserver2.py
+++ b/cherrypy/wsgiserver/wsgiserver2.py
@@ -102,6 +102,10 @@ except ImportError:
# Python 2.6
import io
+try:
+ import pkg_resources
+except ImportError:
+ pass
if 'win' in sys.platform and hasattr(socket, "AF_INET6"):
if not hasattr(socket, 'IPPROTO_IPV6'):
@@ -113,6 +117,12 @@ if 'win' in sys.platform and hasattr(socket, "AF_INET6"):
DEFAULT_BUFFER_SIZE = io.DEFAULT_BUFFER_SIZE
+try:
+ cp_version = pkg_resources.require('cherrypy')[0].version
+except Exception:
+ cp_version = 'unknown'
+
+
class FauxSocket(object):
"""Faux socket with the minimal interface required by pypy"""
@@ -1756,7 +1766,7 @@ class HTTPServer(object):
timeout = 10
"""The timeout in seconds for accepted connections (default 10)."""
- version = "CherryPy/5.1.0"
+ version = "CherryPy/" + cp_version
"""A version string for the HTTPServer."""
software = None
diff --git a/cherrypy/wsgiserver/wsgiserver3.py b/cherrypy/wsgiserver/wsgiserver3.py
index 319a8895..eb169d5e 100644
--- a/cherrypy/wsgiserver/wsgiserver3.py
+++ b/cherrypy/wsgiserver/wsgiserver3.py
@@ -99,6 +99,10 @@ except ImportError:
# Python 2.6
import io
+try:
+ import pkg_resources
+except ImportError:
+ pass
if 'win' in sys.platform and hasattr(socket, "AF_INET6"):
if not hasattr(socket, 'IPPROTO_IPV6'):
@@ -110,6 +114,12 @@ if 'win' in sys.platform and hasattr(socket, "AF_INET6"):
DEFAULT_BUFFER_SIZE = io.DEFAULT_BUFFER_SIZE
+try:
+ cp_version = pkg_resources.require('cherrypy')[0].version
+except Exception:
+ cp_version = 'unknown'
+
+
if sys.version_info >= (3, 0):
bytestr = bytes
unicodestr = str
@@ -1478,7 +1488,7 @@ class HTTPServer(object):
timeout = 10
"""The timeout in seconds for accepted connections (default 10)."""
- version = "CherryPy/5.1.0"
+ version = "CherryPy/" + cp_version
"""A version string for the HTTPServer."""
software = None