From 20431cc7712e67b9249251dc47162333785d5e91 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Thu, 1 Nov 2018 23:18:05 +0000 Subject: [PATCH] [Docs] Fix build errors getting Deluge version The use of pkg_resource.require caused an unwanted requirements lookup that errored out the sphinx build when no dependencies are installed. This is fixed by switching to pkg_resources.get_distribution. Also changed the tox docs env to not install Deluge as the setup.py now contains install_requires which is unwanted. --- deluge/common.py | 27 ++++++++++++++------------- docs/source/conf.py | 2 +- tox.ini | 2 ++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/deluge/common.py b/deluge/common.py index c1c1d641b..00b8cf463 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -87,14 +87,12 @@ PY2 = sys.version_info.major == 2 def get_version(): - """ - Returns the program version from the egg metadata - - :returns: the version of Deluge - :rtype: string + """The program version from the egg metadata. + Returns: + str: The version of Deluge. """ - return pkg_resources.require('Deluge')[0].version + return pkg_resources.get_distribution('Deluge').version def get_default_config_dir(filename=None): @@ -289,14 +287,17 @@ def get_pixmap(fname): def resource_filename(module, path): - """While developing, if there's a second deluge package, installed globally - and another in develop mode somewhere else, while pkg_resources.require('Deluge') - returns the proper deluge instance, pkg_resources.resource_filename does - not, it returns the first found on the python path, which is not good - enough. - This is a work-around that. + """Get filesystem path for a resource. + + This function contains a work-around for pkg_resources.resource_filename + not returning the correct path with multiple packages installed. + + So if there's a second deluge package, installed globally and another in + develop mode somewhere else, while pkg_resources.get_distribution('Deluge') + returns the proper deluge instance, pkg_resources.resource_filename + does not, it returns the first found on the python path, which is wrong. """ - return pkg_resources.require('Deluge>=%s' % get_version())[0].get_resource_filename( + return pkg_resources.get_distribution('Deluge').get_resource_filename( pkg_resources._manager, os.path.join(*(module.split('.') + [path])) ) diff --git a/docs/source/conf.py b/docs/source/conf.py index 4d70c35bd..24bd4e368 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -150,7 +150,7 @@ copyright = '2008-%s, Deluge Team' % current_year # noqa: A001 if get_version: version = get_version(prefix='deluge-', suffix='.dev0') else: - version = pkg_resources.require('Deluge')[0].version + version = pkg_resources.get_distribution('Deluge').version # The full version, including alpha/beta/rc tags. release = version diff --git a/tox.ini b/tox.ini index bb6b096a5..ad933169b 100644 --- a/tox.ini +++ b/tox.ini @@ -156,6 +156,7 @@ deps = [testenv:docs] basepython = python2.7 sitepackages = {[docsbase]sitepackages} +skip_install = True deps = {[docsbase]deps} commands = python setup.py clean_docs @@ -165,6 +166,7 @@ commands = [testenv:docscoverage] basepython = python2.7 sitepackages = {[docsbase]sitepackages} +skip_install = True changedir = {[docsbase]changedir} deps = {[docsbase]deps}