#2 Changes to reduce dependencies of server packages.
Closed 3 years ago by mooninite. Opened 3 years ago by alebastr.
rpms/ alebastr/deluge master  into  master

@@ -0,0 +1,85 @@ 

+ From 23a48dd01c86ef01cd1d13371de51247ec9a503b Mon Sep 17 00:00:00 2001

+ From: Calum Lind <calumlind+deluge@gmail.com>

+ Date: Mon, 27 Apr 2020 21:41:41 +0100

+ Subject: [#3309|GTK] Fix cmp function for None types

+ 

+ Comparisons on Python 3 are much stricter resulting in the following

+ error comparing with None:

+ 

+     TypeError: '>' not supported between instances of 'NoneType' and 'str'

+ 

+ Fix this by getting the type of the other value and getting it's default

+ value.

+ ---

+  deluge/tests/test_ui_gtk3.py | 34 ++++++++++++++++++++++++++++++++++

+  deluge/ui/gtk3/common.py     | 13 ++++++++++++-

+  2 files changed, 46 insertions(+), 1 deletion(-)

+  create mode 100644 deluge/tests/test_ui_gtk3.py

+ 

+ diff --git a/deluge/tests/test_ui_gtk3.py b/deluge/tests/test_ui_gtk3.py

+ new file mode 100644

+ index 0000000..a208bb4

+ --- /dev/null

+ +++ b/deluge/tests/test_ui_gtk3.py

+ @@ -0,0 +1,34 @@

+ +# -*- coding: utf-8 -*-

+ +#

+ +# 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 sys

+ +

+ +import mock

+ +import pytest

+ +from twisted.trial import unittest

+ +

+ +

+ +@pytest.mark.gtkui

+ +class GTK3CommonTestCase(unittest.TestCase):

+ +    def setUp(self):

+ +        sys.modules['gi.repository'] = mock.MagicMock()

+ +

+ +    def tearDown(self):

+ +        pass

+ +

+ +    def test_cmp(self):

+ +        from deluge.ui.gtk3.common import cmp

+ +

+ +        self.assertEqual(cmp(None, None), 0)

+ +        self.assertEqual(cmp(1, None), 1)

+ +        self.assertEqual(cmp(0, None), 1)

+ +        self.assertEqual(cmp(None, 7), -1)

+ +        self.assertEqual(cmp(None, 'bar'), -1)

+ +        self.assertEqual(cmp('foo', None), 1)

+ +        self.assertEqual(cmp('', None), 1)

+ diff --git a/deluge/ui/gtk3/common.py b/deluge/ui/gtk3/common.py

+ index 0be3bff..7434172 100644

+ --- a/deluge/ui/gtk3/common.py

+ +++ b/deluge/ui/gtk3/common.py

+ @@ -42,7 +42,18 @@ def cmp(x, y):

+      and strictly positive if x > y.

+      """

+  

+ -    return (x > y) - (x < y)

+ +    try:

+ +        return (x > y) - (x < y)

+ +    except TypeError:

+ +        # Handle NoneType comparison

+ +        if x is None:

+ +            if y is None:

+ +                return 0

+ +            return -1

+ +        elif y is None:

+ +            return 1

+ +        else:

+ +            raise

+  

+  

+  def create_blank_pixbuf(size=16):

+ -- 

+ cgit v1.1

+ 

@@ -0,0 +1,69 @@ 

+ From 351664ec071daa04161577c6a1c949ed0f2c3206 Mon Sep 17 00:00:00 2001

+ From: minus <minus@mnus.de>

+ Date: Sun, 17 Nov 2019 09:36:23 +0100

+ Subject: [PATCH 1/2] [Logging] Fix Python 3.8 compatibility

+ 

+ Deluge's logger class extends Python's `logging.Logger`. Since Python

+ 3.8, it takes an additional argument `stacklevel`.

+ The implementation in Deluge does not support that. Work around the

+ problem by ignoring additional arguments.

+ ---

+  deluge/log.py | 2 +-

+  1 file changed, 1 insertion(+), 1 deletion(-)

+ 

+ diff --git a/deluge/log.py b/deluge/log.py

+ index 75e8308b5..0f9877fdb 100644

+ --- a/deluge/log.py

+ +++ b/deluge/log.py

+ @@ -86,7 +86,7 @@ def critical(self, msg, *args, **kwargs):

+      def exception(self, msg, *args, **kwargs):

+          yield LoggingLoggerClass.exception(self, msg, *args, **kwargs)

+  

+ -    def findCaller(self, stack_info=False):  # NOQA: N802

+ +    def findCaller(self, *args, **kwargs):  # NOQA: N802

+          f = logging.currentframe().f_back

+          rv = '(unknown file)', 0, '(unknown function)'

+          while hasattr(f, 'f_code'):

+ 

+ From 5e06aee5c8846f94bd5fcc209132dacf06de781f Mon Sep 17 00:00:00 2001

+ From: minus <minus@mnus.de>

+ Date: Tue, 19 Nov 2019 17:14:01 +0100

+ Subject: [PATCH 2/2] [Logging] Fix findCaller with unknown source

+ 

+ In case no source was found, a 3-tuple was returned instead of a 4-tuple

+ in Python 3

+ ---

+  deluge/log.py | 12 ++++++------

+  1 file changed, 6 insertions(+), 6 deletions(-)

+ 

+ diff --git a/deluge/log.py b/deluge/log.py

+ index 0f9877fdb..bf4f3c2d7 100644

+ --- a/deluge/log.py

+ +++ b/deluge/log.py

+ @@ -88,7 +88,7 @@ def exception(self, msg, *args, **kwargs):

+  

+      def findCaller(self, *args, **kwargs):  # NOQA: N802

+          f = logging.currentframe().f_back

+ -        rv = '(unknown file)', 0, '(unknown function)'

+ +        rv = ('(unknown file)', 0, '(unknown function)', None)

+          while hasattr(f, 'f_code'):

+              co = f.f_code

+              filename = os.path.normcase(co.co_filename)

+ @@ -98,12 +98,12 @@ def findCaller(self, *args, **kwargs):  # NOQA: N802

+              ):

+                  f = f.f_back

+                  continue

+ -            if common.PY2:

+ -                rv = (filename, f.f_lineno, co.co_name)

+ -            else:

+ -                rv = (filename, f.f_lineno, co.co_name, None)

+ +            rv = (co.co_filename, f.f_lineno, co.co_name, None)

+              break

+ -        return rv

+ +        if common.PY2:

+ +            return rv[:-1]

+ +        else:

+ +            return rv

+  

+  

+  levels = {

file modified
+22 -19
@@ -1,6 +1,6 @@ 

  Name:           deluge

  Version:        2.0.3

- Release:        8%{?dist}

+ Release:        9%{?dist}

  Summary:        A GTK+ BitTorrent client with support for DHT, UPnP, and PEX

  License:        GPLv3 with exceptions

  URL:            http://deluge-torrent.org/
@@ -11,6 +11,11 @@ 

  

  # https://git.deluge-torrent.org/deluge/patch/?id=eeeb7fb69b73cca40a27662997f2d21cec6ed33f

  Patch0:         deluge-2.0.3-gtk-status.patch

+ # https://git.deluge-torrent.org/deluge/commit/?h=develop&id=351664ec071daa04161577c6a1c949ed0f2c3206

+ # https://git.deluge-torrent.org/deluge/commit/?h=develop&id=5e06aee5c8846f94bd5fcc209132dacf06de781f

+ Patch1:         deluge-2.0.3-logging-fix-python-3.8-compatibility.patch

+ # https://git.deluge-torrent.org/deluge/commit/?h=develop&id=5e06aee5c8846f94bd5fcc209132dacf06de781f

+ Patch2:         deluge-2.0.3-fix-cmp-function-for-none-types.patch

  

  BuildArch:     noarch

  BuildRequires: desktop-file-utils
@@ -20,6 +25,7 @@ 

  BuildRequires: intltool

  BuildRequires: rb_libtorrent-python3

  BuildRequires: libappstream-glib

+ BuildRequires: systemd-rpm-macros

  

  ## add Requires to make into Meta package

  Requires: %{name}-common = %{version}-%{release}
@@ -41,17 +47,9 @@ 

  %package common

  Summary:    Files common to Deluge sub packages

  License:    GPLv3 with exceptions

- Requires:   python3-setuptools

- Requires:   python3-pyOpenSSL

- Requires:   python3-chardet

- Requires:   python3-pygame

- Requires:   python3-setproctitle

- Requires:   python3-pyxdg

  Requires:   rb_libtorrent-python3

- Requires:   python3-twisted

- Requires:   python3-GeoIP

- Requires:   python3-rencode

  Requires:   python3-service-identity

+ Recommends: python3-GeoIP

  

  

  %description common
@@ -70,6 +68,8 @@ 

  Requires:   python3-gobject

  Requires:   libappindicator-gtk3

  Requires:   librsvg2

+ Recommends: python3-dbus

+ Recommends: python3-pygame

  

  %description gtk

  Deluge bittorent client GTK graphical user interface
@@ -104,10 +104,6 @@ 

  License:    GPLv3 with exceptions

  Requires:   %{name}-common = %{version}-%{release}

  Requires(pre): shadow-utils

- Requires(post): systemd

- Requires(preun): systemd

- Requires(postun): systemd

- BuildRequires: systemd

  

  %description daemon

  Files for the Deluge daemon
@@ -116,17 +112,17 @@ 

  %autosetup -p1

  

  %build

- CFLAGS="%{optflags}" %{__python3} setup.py build

+ %py3_build

  

  %install

+ %py3_install

+ 

  # http://dev.deluge-torrent.org/ticket/2034

  mkdir -p %{buildroot}%{_unitdir}

  install -m644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}-daemon.service

  install -m644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}-web.service

  mkdir -p %{buildroot}/var/lib/%{name}

  

- %{__python3} setup.py install -O1 --skip-build --root %{buildroot}

- 

  desktop-file-install  \

      --dir %{buildroot}%{_datadir}/applications    \

      --copy-name-to-generic-name            \
@@ -189,13 +185,13 @@ 

  %{python3_sitelib}/%{name}/ui/data

  # if someone decides to only install images

  %dir %{python3_sitelib}/%{name}

- %{_datadir}/icons/hicolor/*/apps/%{name}*

- %{_datadir}/pixmaps/%{name}.*

  

  %files gtk

  %{_bindir}/%{name}

  %{_bindir}/%{name}-gtk

  %{_datadir}/applications/%{name}.desktop

+ %{_datadir}/icons/hicolor/*/apps/%{name}*

+ %{_datadir}/pixmaps/%{name}.*

  %{_metainfodir}/%{name}.appdata.xml

  %{python3_sitelib}/%{name}/ui/gtk3

  %{_mandir}/man?/%{name}-gtk*
@@ -245,6 +241,13 @@ 

  %systemd_postun_with_restart deluge-web.service

  

  %changelog

+ * Sat Jul 11 2020 Aleksei Bavshin <alebastr89@gmail.com> - 2.0.3-9

+ - Add patch for Python 3.8 logging API changes

+ - Add patch for 'NoneType' cmp error (#1775962, #1812790, #1830593, #1836670)

+ - Change optional deps to Recommends and move pygame to the deluge-gtk.

+ - Remove duplicates of autogenerated Requires.

+ - Use python packaging macros

+ 

  * Tue May 26 2020 Miro HronĨok <mhroncok@redhat.com> - 2.0.3-8

  - Rebuilt for Python 3.9

  

Thanks for maintaining the deluge package!

I did some changes to reduce footprint of deluge-daemon + deluge-web installation by ~150Mb (about half the size of container image built from fedora-minimal). I also added patches for a couple of annoying Python 3 bugs and removed duplicates of automatically picked Requires.
Let me know if you have any questions/suggestions on these changes.


One thing I didn't do is to install upstream systemd services from deluge-2.0.3/packaging/systemd. I prepared the commit with this change, but I don't quite agree with default UMask=007 and the way upstream injects User into the service.
Maybe it's worth patching service files before installing, but this gives a little benefit over continuing with existing downstream files.

rebased onto f6f78da

3 years ago

Thanks for the PR. I've implemented the changes in the -12 release.

Pull-Request has been closed by mooninite

3 years ago