[Plugins] Convert plugins to deluge_ module prefix convention

This commit reverts namespace for the plugins and uses a module prefix
"deluge_" in it's place. The distribution package name remains the same
for now but will also be considered to use a prefix to help find the
third-party plugins e.g. Deluge-{Plugin} and the pluginmanager will
strip the prefix for displaying.

The change is a result of problems trying to package Deluge with
pyinstaller and the pkg_resources namespaces is not compatible.
Testing alternatives to using the pkgutil or PEP420 (native) namespaces
did not yield any joy either as importing eggs with namespaces does not
work. [1]

At this point importable eggs are considered deprecated but there is no
viable alternative yet. [2]

[1] https://github.com/pypa/packaging-problems/issues/212
[2] https://github.com/pypa/packaging-problems/issues/244
This commit is contained in:
Calum Lind 2019-05-14 14:41:58 +01:00
parent d6a0276a78
commit 535b13b5f1
132 changed files with 123 additions and 171 deletions

View File

@ -1,2 +1 @@
"""Deluge"""
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -21,4 +21,4 @@ from pkg_resources import resource_filename
def get_resource(filename, subdir=False):
folder = os.path.join('data', 'autoadd_options') if subdir else 'data'
return resource_filename('deluge.plugins.autoadd', os.path.join(folder, filename))
return resource_filename(__package__, os.path.join(folder, filename))

View File

@ -23,9 +23,7 @@ __url__ = 'http://dev.deluge-torrent.org/wiki/Plugins/AutoAdd'
__license__ = 'GPLv3'
__description__ = 'Monitors folders for .torrent files.'
__long_description__ = """"""
__pkg_data__ = {
'deluge.plugins.' + __plugin_name__.lower(): ['template/*', 'data/*', 'data/*/*']
}
__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*', 'data/*/*']}
setup(
name=__plugin_name__,
@ -37,15 +35,14 @@ setup(
license=__license__,
long_description=__long_description__ if __long_description__ else __description__,
packages=find_packages(),
namespace_packages=['deluge', 'deluge.plugins'],
package_data=__pkg_data__,
entry_points="""
[deluge.plugin.core]
%s = deluge.plugins.%s:CorePlugin
%s = deluge_%s:CorePlugin
[deluge.plugin.gtk3ui]
%s = deluge.plugins.%s:Gtk3UIPlugin
%s = deluge_%s:Gtk3UIPlugin
[deluge.plugin.web]
%s = deluge.plugins.%s:WebUIPlugin
%s = deluge_%s:WebUIPlugin
"""
% ((__plugin_name__, __plugin_name__.lower()) * 3),
)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -23,7 +23,7 @@ from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename('deluge.plugins.blocklist', os.path.join('data', filename))
return resource_filename(__package__, os.path.join('data', filename))
def raises_errors_as(error):

View File

Before

Width:  |  Height:  |  Size: 586 B

After

Width:  |  Height:  |  Size: 586 B

View File

@ -17,7 +17,7 @@ __url__ = 'http://deluge-torrent.org'
__license__ = 'GPLv3'
__description__ = 'Download and import IP blocklists'
__long_description__ = __description__
__pkg_data__ = {'deluge.plugins.' + __plugin_name__.lower(): ['data/*']}
__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*']}
setup(
name=__plugin_name__,
@ -30,15 +30,14 @@ setup(
zip_safe=False,
long_description=__long_description__,
packages=find_packages(),
namespace_packages=['deluge', 'deluge.plugins'],
package_data=__pkg_data__,
entry_points="""
[deluge.plugin.core]
%s = deluge.plugins.%s:CorePlugin
%s = deluge_%s:CorePlugin
[deluge.plugin.gtk3ui]
%s = deluge.plugins.%s:GtkUIPlugin
%s = deluge_%s:GtkUIPlugin
[deluge.plugin.web]
%s = deluge.plugins.%s:WebUIPlugin
%s = deluge_%s:WebUIPlugin
"""
% ((__plugin_name__, __plugin_name__.lower()) * 3),
)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
# 2007-2009 Andrew Resch <andrewresch@gmail.com>
# 2009 Damien Churchill <damoxc@gmail.com>
# 2010 Pedro Algarvio <pedro@algarvio.me>
# 2017 Calum Lind <calumlind+deluge@gmail.com>
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
from __future__ import unicode_literals
import os.path
from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename('deluge.plugins.execute', os.path.join('data', filename))

View File

@ -20,4 +20,4 @@ from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename('deluge.plugins.label', os.path.join('data', filename))
return resource_filename(__package__, os.path.join('data', filename))

View File

@ -17,7 +17,7 @@ __url__ = 'http://deluge-torrent.org'
__license__ = 'GPLv3'
__description__ = 'Plugin to execute a command upon an event'
__long_description__ = __description__
__pkg_data__ = {'deluge.plugins.' + __plugin_name__.lower(): ['data/*']}
__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*']}
setup(
name=__plugin_name__,
@ -29,15 +29,14 @@ setup(
license=__license__,
long_description=__long_description__,
packages=find_packages(),
namespace_packages=['deluge', 'deluge.plugins'],
package_data=__pkg_data__,
entry_points="""
[deluge.plugin.core]
%s = deluge.plugins.%s:CorePlugin
%s = deluge_%s:CorePlugin
[deluge.plugin.gtk3ui]
%s = deluge.plugins.%s:GtkUIPlugin
%s = deluge_%s:GtkUIPlugin
[deluge.plugin.web]
%s = deluge.plugins.%s:WebUIPlugin
%s = deluge_%s:WebUIPlugin
"""
% ((__plugin_name__, __plugin_name__.lower()) * 3),
)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
# 2007-2009 Andrew Resch <andrewresch@gmail.com>
# 2009 Damien Churchill <damoxc@gmail.com>
# 2010 Pedro Algarvio <pedro@algarvio.me>
# 2017 Calum Lind <calumlind+deluge@gmail.com>
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
from __future__ import unicode_literals
import os.path
from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename('deluge.plugins.extractor', os.path.join('data', filename))

View File

@ -20,4 +20,4 @@ from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename('deluge.plugins.webui', os.path.join('data', filename))
return resource_filename(__package__, os.path.join('data', filename))

View File

@ -30,7 +30,7 @@ Windows support: .rar, .zip, .tar, .7z, .xz, .lzma
Note: Will not extract with 'Move Completed' enabled
"""
__pkg_data__ = {'deluge.plugins.' + __plugin_name__.lower(): ['template/*', 'data/*']}
__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*']}
setup(
name=__plugin_name__,
@ -42,15 +42,14 @@ setup(
license=__license__,
long_description=__long_description__ if __long_description__ else __description__,
packages=find_packages(),
namespace_packages=['deluge', 'deluge.plugins'],
package_data=__pkg_data__,
entry_points="""
[deluge.plugin.core]
%s = deluge.plugins.%s:CorePlugin
%s = deluge_%s:CorePlugin
[deluge.plugin.gtk3ui]
%s = deluge.plugins.%s:GtkUIPlugin
%s = deluge_%s:GtkUIPlugin
[deluge.plugin.web]
%s = deluge.plugins.%s:WebUIPlugin
%s = deluge_%s:WebUIPlugin
"""
% ((__plugin_name__, __plugin_name__.lower()) * 3),
)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -20,4 +20,4 @@ from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename('deluge.plugins.stats', os.path.join('data', filename))
return resource_filename(__package__, os.path.join('data', filename))

View File

@ -21,7 +21,7 @@ Allows labels to be assigned to torrents
Also offers filters on state, tracker and keywords
"""
__pkg_data__ = {'deluge.plugins.' + __plugin_name__.lower(): ['template/*', 'data/*']}
__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*']}
setup(
name=__plugin_name__,
@ -33,15 +33,14 @@ setup(
license=__license__,
long_description=__long_description__,
packages=find_packages(),
namespace_packages=['deluge', 'deluge.plugins'],
package_data=__pkg_data__,
entry_points="""
[deluge.plugin.core]
%s = deluge.plugins.%s:CorePlugin
%s = deluge_%s:CorePlugin
[deluge.plugin.gtk3ui]
%s = deluge.plugins.%s:GtkUIPlugin
%s = deluge_%s:GtkUIPlugin
[deluge.plugin.web]
%s = deluge.plugins.%s:WebUIPlugin
%s = deluge_%s:WebUIPlugin
"""
% ((__plugin_name__, __plugin_name__.lower()) * 3),
)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -27,9 +27,7 @@ log = logging.getLogger(__name__)
def get_resource(filename):
return resource_filename(
'deluge.plugins.notifications', os.path.join('data', filename)
)
return resource_filename(__package__, os.path.join('data', filename))
class CustomNotifications(object):

View File

@ -29,7 +29,7 @@ Email, Popup, Blink and Sound notifications
The plugin also allows other plugins to make
use of itself for their own custom notifications
"""
__pkg_data__ = {'deluge.plugins.' + __plugin_name__.lower(): ['template/*', 'data/*']}
__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*']}
setup(
name=__plugin_name__,
@ -40,16 +40,15 @@ setup(
url=__url__,
license=__license__,
long_description=__long_description__ if __long_description__ else __description__,
packages=find_packages(exclude=['**/test.py']),
namespace_packages=['deluge', 'deluge.plugins'],
packages=find_packages(),
package_data=__pkg_data__,
entry_points="""
[deluge.plugin.core]
%s = deluge.plugins.%s:CorePlugin
%s = deluge_%s:CorePlugin
[deluge.plugin.gtk3ui]
%s = deluge.plugins.%s:GtkUIPlugin
%s = deluge_%s:GtkUIPlugin
[deluge.plugin.web]
%s = deluge.plugins.%s:WebUIPlugin
%s = deluge_%s:WebUIPlugin
"""
% ((__plugin_name__, __plugin_name__.lower()) * 3),
)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
# 2007-2009 Andrew Resch <andrewresch@gmail.com>
# 2009 Damien Churchill <damoxc@gmail.com>
# 2010 Pedro Algarvio <pedro@algarvio.me>
# 2017 Calum Lind <calumlind+deluge@gmail.com>
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
from __future__ import unicode_literals
import os.path
from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename('deluge.plugins.scheduler', os.path.join('data', filename))

View File

@ -20,4 +20,4 @@ from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename('deluge.plugins.toggle', os.path.join('data', filename))
return resource_filename(__package__, os.path.join('data', filename))

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -21,7 +21,7 @@ __url__ = 'http://deluge-torrent.org'
__license__ = 'GPLv3'
__description__ = 'Schedule limits on a per-hour per-day basis.'
__long_description__ = """"""
__pkg_data__ = {'deluge.plugins.' + __plugin_name__.lower(): ['template/*', 'data/*']}
__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*']}
setup(
name=__plugin_name__,
@ -33,15 +33,14 @@ setup(
license=__license__,
long_description=__long_description__ if __long_description__ else __description__,
packages=find_packages(),
namespace_packages=['deluge', 'deluge.plugins'],
package_data=__pkg_data__,
entry_points="""
[deluge.plugin.core]
%s = deluge.plugins.%s:CorePlugin
%s = deluge_%s:CorePlugin
[deluge.plugin.gtk3ui]
%s = deluge.plugins.%s:GtkUIPlugin
%s = deluge_%s:GtkUIPlugin
[deluge.plugin.web]
%s = deluge.plugins.%s:WebUIPlugin
%s = deluge_%s:WebUIPlugin
"""
% ((__plugin_name__, __plugin_name__.lower()) * 3),
)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
# 2007-2009 Andrew Resch <andrewresch@gmail.com>
# 2009 Damien Churchill <damoxc@gmail.com>
# 2010 Pedro Algarvio <pedro@algarvio.me>
# 2017 Calum Lind <calumlind+deluge@gmail.com>
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
from __future__ import unicode_literals
import os.path
from pkg_resources import resource_filename
def get_resource(filename):
return resource_filename(__package__, os.path.join('data', filename))

Some files were not shown because too many files have changed in this diff Show More