From e265efc42abab05143a0f2209d3cd3e76b0621e2f81263f760e8cbc3e57920bd Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 4 Jul 2022 18:09:52 +0000 Subject: [PATCH 1/2] Accepting request 986650 from home:bnavigator:branches:devel:languages:python:mailman - Rename the built package to python prefixless HyperKitty * Doesn't imply any false impression of multiflavor - Go back to python39 -- highest supported Python by mailman OBS-URL: https://build.opensuse.org/request/show/986650 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:mailman/python-HyperKitty?expand=0&rev=57 --- python-HyperKitty-rpmlintrc | 1 + python-HyperKitty.changes | 7 +++ python-HyperKitty.spec | 89 ++++++++++++++++++++++++------------- 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/python-HyperKitty-rpmlintrc b/python-HyperKitty-rpmlintrc index d098176..c448252 100644 --- a/python-HyperKitty-rpmlintrc +++ b/python-HyperKitty-rpmlintrc @@ -3,3 +3,4 @@ addFilter("non-standard-gid") addFilter("non-standard-uid") addFilter("spurious-executable-perm .*example_project/wsgi.py") addFilter("hidden-file-or-dir .*example_project/logs/.keep") +addFilter("obsolete-not-provided python3-HyperKitty") diff --git a/python-HyperKitty.changes b/python-HyperKitty.changes index 77cafce..2b8291b 100644 --- a/python-HyperKitty.changes +++ b/python-HyperKitty.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Jul 4 11:02:04 UTC 2022 - Ben Greiner + +- Rename the built package to python prefixless HyperKitty + * Doesn't imply any false impression of multiflavor +- Go back to python39 -- highest supported Python by mailman + ------------------------------------------------------------------- Sun Jul 3 20:46:20 UTC 2022 - Ben Greiner diff --git a/python-HyperKitty.spec b/python-HyperKitty.spec index 077b281..7f69e7a 100644 --- a/python-HyperKitty.spec +++ b/python-HyperKitty.spec @@ -31,9 +31,20 @@ %global hyperkitty_services hyperkitty-qcluster.service hyperkitty-runjob-daily.service hyperkitty-runjob-daily.timer hyperkitty-runjob-hourly.service hyperkitty-runjob-hourly.timer hyperkitty-runjob-minutely.service hyperkitty-runjob-minutely.timer hyperkitty-runjob-monthly.service hyperkitty-runjob-monthly.timer hyperkitty-runjob-quarter-hourly.service hyperkitty-runjob-quarter-hourly.timer hyperkitty-runjob-weekly.service hyperkitty-runjob-weekly.timer hyperkitty-runjob-yearly.service hyperkitty-runjob-yearly.timer +%if 0%{?suse_version} >= 1550 +# Newest python supported by mailman is Python 3.9 -- https://gitlab.com/mailman/mailman/-/issues/936 +%define pythons python39 +%define mypython python39 +%define __mypython %{__python39} +%define mypython_sitelib %{python39_sitelib} +%else %{?!python_module:%define python_module() python3-%{**}} -# mailman is built only for primary python3 flavor %define pythons python3 +%define mypython python3 +%define __mypython %{__python3} +%define mypython_sitelib %{python3_sitelib} +%endif + Name: python-HyperKitty Version: 1.3.5 Release: 0 @@ -79,25 +90,11 @@ BuildRequires: openssl BuildRequires: python-rpm-macros BuildRequires: rsync BuildRequires: sudo -Requires: python-Django >= 1.11 -Requires: python-django-compressor >= 1.3 -Requires: python-django-debug-toolbar >= 2.2 -Requires: python-django-extensions >= 1.3.7 -Requires: python-django-gravatar2 >= 1.0.6 -Requires: python-django-haystack >= 2.8.0 -Requires: python-django-mailman3 >= 1.3.7 -Requires: python-django-q >= 1.3.9 -Requires: python-djangorestframework >= 3.0.0 -Requires: python-flufl.lock -Requires: python-libsass -Requires: python-mailmanclient >= 3.3.2 -Requires: python-mistune -Requires: python-networkx >= 1.9.1 -Requires: python-python-dateutil >= 2.0 -Requires: python-pytz >= 2012 -Requires: python-robot-detection >= 0.3 -Requires: python-xapian-haystack >= 2.1.0 BuildArch: noarch +%if 0%{?suse_version} >= 1550 +# use the real python3 primary for rpm pythondistdeps.py +BuildRequires: python3-packaging +%endif # SECTION test requirements BuildRequires: %{python_module Django >= 1.11} BuildRequires: %{python_module Whoosh >= 2.5.7} @@ -121,21 +118,45 @@ BuildRequires: %{python_module python-dateutil >= 2.0} BuildRequires: %{python_module pytz >= 2012} BuildRequires: %{python_module robot-detection >= 0.3} # /SECTION -%if 0%{python3_version_nodots} == 38 -# help in replacing any previously installed multiflavor package back to the primary python3 package -Provides: python38-Hyperkitty = %{version}-%{release} -Obsoletes: python38-Hyperkitty < %{version}-%{release} -%endif -%python_subpackages %description A web interface to access GNU Mailman v3 archives. +%package -n %{hyperkitty_pkgname} +Summary: A web interface to access GNU Mailman v3 archives +Requires: %{mypython}-Django >= 1.11 +Requires: %{mypython}-django-compressor >= 1.3 +Requires: %{mypython}-django-debug-toolbar >= 2.2 +Requires: %{mypython}-django-extensions >= 1.3.7 +Requires: %{mypython}-django-gravatar2 >= 1.0.6 +Requires: %{mypython}-django-haystack >= 2.8.0 +Requires: %{mypython}-django-mailman3 >= 1.3.7 +Requires: %{mypython}-django-q >= 1.3.9 +Requires: %{mypython}-djangorestframework >= 3.0.0 +Requires: %{mypython}-flufl.lock +Requires: %{mypython}-libsass +Requires: %{mypython}-mailmanclient >= 3.3.2 +Requires: %{mypython}-mistune +Requires: %{mypython}-networkx >= 1.9.1 +Requires: %{mypython}-python-dateutil >= 2.0 +Requires: %{mypython}-pytz >= 2012 +Requires: %{mypython}-robot-detection >= 0.3 +Requires: %{mypython}-xapian-haystack >= 2.1.0 +%if "%{expand:%%%{mypython}_provides}" == "python3" +Provides: python3-%{hyperkitty_pkgname} = %{version}-%{release} +%endif +Obsoletes: python3-%{hyperkitty_pkgname} < %{version}-%{release} +Provides: %{mypython}-%{hyperkitty_pkgname} = %{version}-%{release} +Obsoletes: %{mypython}-%{hyperkitty_pkgname} < %{version}-%{release} + +%description -n %{hyperkitty_pkgname} +A web interface to access GNU Mailman v3 archives. + %package -n %{hyperkitty_pkgname}-web Summary: The webroot for GNU Mailman +Requires: %{hyperkitty_pkgname} Requires: acl Requires: openssl -Requires: python3-HyperKitty Requires: sudo %description -n %{hyperkitty_pkgname}-web @@ -146,7 +167,11 @@ This package holds the web interface. %package -n %{hyperkitty_pkgname}-web-uwsgi Summary: HyperKitty - uwsgi configuration Requires: %{hyperkitty_pkgname}-web -Requires: uwsgi +%if 0%{suse_version} >= 1550 +Requires: %{mypython}-uwsgi-python3 +%else +Requires: uwsgi-python3 +%endif %description -n %{hyperkitty_pkgname}-web-uwsgi A web user interface for GNU Mailman. @@ -170,8 +195,10 @@ rsync -a example_project/* build_static_files %patch5 -p1 %build -sed -i 's|^#!/usr/bin/env.*|#!%{_bindir}/python3|' \ +sed -i 's|^#!/usr/bin/env.*|#!%{__mypython}|' \ example_project/manage.py +sed -i 's|/usr/bin/python3|%{__mypython}|' %{SOURCE10} %{SOURCE20} %{SOURCE21} +sed -i 's|python3|%{mypython}|' %{SOURCE12} %python_build @@ -296,11 +323,11 @@ fi %postun -n %{hyperkitty_pkgname}-web %service_del_postun %{hyperkitty_services} -%files %{python_files} +%files -n %{hyperkitty_pkgname} %doc AUTHORS.txt README.rst example_project doc/*.rst %license COPYING.txt -%{python_sitelib}/hyperkitty -%{python_sitelib}/HyperKitty*.egg-info +%{mypython_sitelib}/hyperkitty +%{mypython_sitelib}/HyperKitty-%{version}*-info %files -n %{hyperkitty_pkgname}-web %doc README.SUSE.md From 24e07ee08230901a072d556889cb6ff8188012afedb0b1690a065874769802fa Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Thu, 6 Oct 2022 12:13:14 +0000 Subject: [PATCH 2/2] - Add fix-django41.patch to fix issues with django4.1 - Add fix-elasticsearch8.patch to fix issues with elasticsearch 8.0.0 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:mailman/python-HyperKitty?expand=0&rev=58 --- fix-django41.patch | 67 +++++++++++++++++++++++++++++++++++++++ fix-elasticsearch8.patch | 34 ++++++++++++++++++++ python-HyperKitty.changes | 6 ++++ python-HyperKitty.spec | 6 ++++ 4 files changed, 113 insertions(+) create mode 100644 fix-django41.patch create mode 100644 fix-elasticsearch8.patch diff --git a/fix-django41.patch b/fix-django41.patch new file mode 100644 index 0000000..7972f15 --- /dev/null +++ b/fix-django41.patch @@ -0,0 +1,67 @@ +From 94194e0f5eeacf1be2a88a28bfed62dbc6c5d5a2 Mon Sep 17 00:00:00 2001 +From: Daniel Garcia Moreno +Date: Thu, 6 Oct 2022 12:53:56 +0200 +Subject: [PATCH] Fix django4.1 compatibility issues with related fields + +In Django4.1 a ValueError exception is raised when trying to access to +foreign keys for unsaved model instances: + +https://docs.djangoproject.com/en/4.1/releases/4.1/#reverse-foreign-key-changes-for-unsaved-model-instances + +This patch ensures that everything is saved before trying to use related +models and handles the exception correctly in the Thread model pre_save. +--- + hyperkitty/models/thread.py | 8 ++++++++ + hyperkitty/tests/models/test_email.py | 6 ++++++ + 2 files changed, 14 insertions(+) + +diff --git a/hyperkitty/models/thread.py b/hyperkitty/models/thread.py +index b550cdb8..e49954a7 100644 +--- a/hyperkitty/models/thread.py ++++ b/hyperkitty/models/thread.py +@@ -148,10 +148,18 @@ class Thread(models.Model): + from .email import Email # circular import + if self.starting_email is not None: + return ++ + try: + self.starting_email = self.emails.get(parent_id__isnull=True) + except Email.DoesNotExist: + self.starting_email = self.emails.order_by("date").first() ++ except ValueError: ++ # If the Thread is not created yet, the self.emails will raise a ++ # ValueError exception. This happens at creation time because this ++ # method is called by on_pre_save ++ # ++ # https://docs.djangoproject.com/en/4.1/releases/4.1/#reverse-foreign-key-changes-for-unsaved-model-instances ++ return + + def on_pre_save(self): + self.find_starting_email() +diff --git a/hyperkitty/tests/models/test_email.py b/hyperkitty/tests/models/test_email.py +index 7bcac390..f194e2b1 100644 +--- a/hyperkitty/tests/models/test_email.py ++++ b/hyperkitty/tests/models/test_email.py +@@ -195,6 +195,9 @@ class EmailTestCase(TestCase): + subject="This is a folded\n subject", + in_reply_to="\n ", + content="Dummy message") ++ sender.save() ++ mlist.save() ++ email.save() + msg = email.as_message() + self.assertEqual(msg["Subject"], "This is a folded subject") + +@@ -210,6 +213,9 @@ class EmailTestCase(TestCase): + mailinglist=mlist, + subject="Message subject", + content="Dummy message") ++ sender.save() ++ mlist.save() ++ email.save() + msg = email.as_message() + self.assertEqual(msg['from'], '"Team: J.Q. Doe" ') + +-- +2.37.3 + diff --git a/fix-elasticsearch8.patch b/fix-elasticsearch8.patch new file mode 100644 index 0000000..3b896da --- /dev/null +++ b/fix-elasticsearch8.patch @@ -0,0 +1,34 @@ +From 0e86f9cc40bf05cb819087f1fb0ee56f43968e1b Mon Sep 17 00:00:00 2001 +From: Daniel Garcia Moreno +Date: Thu, 6 Oct 2022 14:01:54 +0200 +Subject: [PATCH] Make it compatible with elasticsearch 8.0.0 + +--- + hyperkitty/tests/views/test_search.py | 10 +++++++++- + tox.ini | 2 +- + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/hyperkitty/tests/views/test_search.py b/hyperkitty/tests/views/test_search.py +index ad0e9632..cad76fe6 100644 +--- a/hyperkitty/tests/views/test_search.py ++++ b/hyperkitty/tests/views/test_search.py +@@ -211,10 +211,18 @@ class SearchViewsTestCase(SearchEnabledTestCase): + + # For elasticsearch backend + from elasticsearch import RequestError ++ from elasticsearch import VERSION ++ mayor, _minor, _p = VERSION ++ ++ search_error = "dummy parsing failure" ++ if mayor > 7: ++ class ElasticError: ++ status = search_error ++ search_error = ElasticError + + class CrashingIterator(list): + def __len__(self): +- raise RequestError(400, "dummy parsing failure", {}) ++ raise RequestError(400, search_error, {}) + query = Mock() + + with self.settings(HAYSTACK_CONNECTIONS={ diff --git a/python-HyperKitty.changes b/python-HyperKitty.changes index 2b8291b..12730c4 100644 --- a/python-HyperKitty.changes +++ b/python-HyperKitty.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Oct 6 12:07:43 UTC 2022 - Daniel Garcia + +- Add fix-django41.patch to fix issues with django4.1 +- Add fix-elasticsearch8.patch to fix issues with elasticsearch 8.0.0 + ------------------------------------------------------------------- Mon Jul 4 11:02:04 UTC 2022 - Ben Greiner diff --git a/python-HyperKitty.spec b/python-HyperKitty.spec index 7f69e7a..913ab21 100644 --- a/python-HyperKitty.spec +++ b/python-HyperKitty.spec @@ -78,6 +78,10 @@ Patch3: python-HyperKitty-no-mock.patch Patch4: hyperkitty-fix-qcluster-timeout.patch # https://gitlab.com/mailman/hyperkitty/-/merge_requests/381 + https://gitlab.com/mailman/hyperkitty/-/merge_requests/449 Patch5: hyperkitty-fix-py310-tests.patch +# PATCH-FIX-UPSTREAM fix-django41.patch gl#mailman/hyperkitty#467 +Patch6: fix-django41.patch +# PATCH-FIX-UPSTREAM fix-elasticsearch8.patch gl#mailman/hyperkitty#468 +Patch7: fix-elasticsearch8.patch # BuildRequires: %{python_module django-debug-toolbar >= 2.2} BuildRequires: %{python_module isort} @@ -193,6 +197,8 @@ rsync -a example_project/* build_static_files %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 +%patch7 -p1 %build sed -i 's|^#!/usr/bin/env.*|#!%{__mypython}|' \