Bump to version 3.7
[rss2email.git] / rss2email / version.py
1 # Copyright (C) 2013 W. Trevor King <wking@tremily.us>
2 #
3 # This file is part of rss2email.
4 #
5 # rss2email is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 2 of the License, or (at your option) version 3 of
8 # the License.
9 #
10 # rss2email is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # rss2email.  If not, see <http://www.gnu.org/licenses/>.
16
17 """Calculate version numbers for this package and its dependencies
18
19 This makes it easier for users to submit useful bug reports.
20 """
21
22 import importlib as _importlib
23 import sys as _sys
24
25 from . import __version__
26
27
28 def get_rss2email_version(package):
29     return __version__
30
31 def get_python_version(package):
32     return _sys.version
33
34 def get_python_package_version(package):
35     try:
36         module = _importlib.import_module(package)
37     except ImportError as e:
38         return None
39     return getattr(module, '__version__', 'unknown')
40
41 def get_versions(packages=None):
42     if not packages:
43         packages = ['rss2email', 'python', 'feedparser', 'html2text']
44     for package in packages:
45         get = globals().get(
46             'get_{}_version'.format(package),
47             get_python_package_version)
48         version = get(package=package)
49         yield (package, version)