Accepting request 1107098 from devel:languages:python:mailman

OBS-URL: https://build.opensuse.org/request/show/1107098
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-mailman?expand=0&rev=27
This commit is contained in:
Ana Guerrero 2023-08-28 15:18:09 +00:00 committed by Git OBS Bridge
commit ea4b58d574
3 changed files with 673 additions and 1 deletions

View File

@ -0,0 +1,656 @@
From 1346ffdbd2ad36e3f37732f3217be3b34dc7bc48 Mon Sep 17 00:00:00 2001
From: Abhilash Raj <raj.abhilash1@gmail.com>
Date: Sun, 9 Jul 2023 16:03:17 +0530
Subject: [PATCH 1/6] fix: Remove dependency on importlib_resources
---
_ext/configplugin.py | 2 +-
setup.py | 1 -
src/mailman/archiving/tests/test_mhonarc.py | 2 +-
src/mailman/bin/tests/test_mailman.py | 2 +-
src/mailman/bin/tests/test_master.py | 2 +-
src/mailman/chains/tests/test_hold.py | 2 +-
src/mailman/commands/docs/import.rst | 2 +-
src/mailman/commands/tests/test_cli_control.py | 2 +-
src/mailman/commands/tests/test_cli_import.py | 2 +-
src/mailman/config/config.py | 2 +-
src/mailman/config/tests/test_configuration.py | 2 +-
src/mailman/core/initialize.py | 2 +-
src/mailman/email/tests/test_message.py | 2 +-
src/mailman/handlers/tests/test_decorate.py | 2 +-
src/mailman/handlers/tests/test_mimedel.py | 2 +-
src/mailman/plugins/docs/intro.rst | 2 +-
src/mailman/plugins/testing/layer.py | 2 +-
src/mailman/rules/dmarc.py | 2 +-
src/mailman/rules/tests/test_dmarc.py | 2 +-
src/mailman/runners/tests/test_digest.py | 2 +-
src/mailman/testing/i18n.py | 2 +-
src/mailman/testing/layers.py | 2 +-
src/mailman/utilities/filesystem.py | 10 +++++-----
src/mailman/utilities/modules.py | 2 +-
src/mailman/utilities/tests/test_import.py | 2 +-
src/mailman/utilities/tests/test_scrubber.py | 2 +-
27 files changed, 29 insertions(+), 40 deletions(-)
diff --git a/_ext/configplugin.py b/_ext/configplugin.py
index 9ed5c98526..1979ce855e 100644
--- a/_ext/configplugin.py
+++ b/_ext/configplugin.py
@@ -23,7 +23,7 @@ import configparser
from docutils import nodes
from docutils.parsers.rst import Directive, directives
from docutils.statemachine import ViewList
-from importlib_resources import files
+from importlib.resources import files
from sphinx.util.nodes import nested_parse_with_titles
diff --git a/setup.py b/setup.py
index 5448b7cf95..714468cc4b 100644
--- a/setup.py
+++ b/setup.py
@@ -121,7 +121,6 @@ case second 'm'. Any other spelling is incorrect.""",
'flufl.bounce>=4.0',
'flufl.i18n>=3.2',
'flufl.lock>=5.1',
- 'importlib_resources>=1.1.0',
'gunicorn',
'lazr.config',
'python-dateutil>=2.0',
diff --git a/src/mailman/archiving/tests/test_mhonarc.py b/src/mailman/archiving/tests/test_mhonarc.py
index 7cb19f35bd..b6c009e361 100644
--- a/src/mailman/archiving/tests/test_mhonarc.py
+++ b/src/mailman/archiving/tests/test_mhonarc.py
@@ -23,7 +23,7 @@ import shutil
import tempfile
import unittest
-from importlib_resources import path
+from importlib.resources import path
from mailman.app.lifecycle import create_list
from mailman.archiving.mhonarc import MHonArc
from mailman.database.transaction import transaction
diff --git a/src/mailman/bin/tests/test_mailman.py b/src/mailman/bin/tests/test_mailman.py
index 13c02c7c90..9247877f7b 100644
--- a/src/mailman/bin/tests/test_mailman.py
+++ b/src/mailman/bin/tests/test_mailman.py
@@ -21,7 +21,7 @@ import unittest
from click.testing import CliRunner
from datetime import timedelta
-from importlib_resources import path
+from importlib.resources import path
from mailman.app.lifecycle import create_list
from mailman.bin.mailman import main
from mailman.config import config
diff --git a/src/mailman/bin/tests/test_master.py b/src/mailman/bin/tests/test_master.py
index 092c337c9c..75041dd591 100644
--- a/src/mailman/bin/tests/test_master.py
+++ b/src/mailman/bin/tests/test_master.py
@@ -27,7 +27,7 @@ from click.testing import CliRunner
from contextlib import ExitStack, suppress
from datetime import timedelta
from flufl.lock import Lock, TimeOutError
-from importlib_resources import path
+from importlib.resources import path
from io import StringIO
from mailman.bin import master
from mailman.config import config
diff --git a/src/mailman/chains/tests/test_hold.py b/src/mailman/chains/tests/test_hold.py
index da579605d7..42da9ed8be 100644
--- a/src/mailman/chains/tests/test_hold.py
+++ b/src/mailman/chains/tests/test_hold.py
@@ -20,7 +20,7 @@
import unittest
from email import message_from_bytes as mfb
-from importlib_resources import read_binary
+from importlib.resources import read_binary
from mailman.app.lifecycle import create_list
from mailman.chains.builtin import BuiltInChain
from mailman.chains.hold import autorespond_to_sender, HoldChain
diff --git a/src/mailman/commands/docs/import.rst b/src/mailman/commands/docs/import.rst
index 66f72be163..e4f741dbb2 100644
--- a/src/mailman/commands/docs/import.rst
+++ b/src/mailman/commands/docs/import.rst
@@ -26,7 +26,7 @@ You must also specify a pickle file to import.
Too bad the list doesn't exist.
- >>> from importlib_resources import path
+ >>> from importlib.resources import path
>>> with path('mailman.testing', 'config.pck') as pickle_path:
... pickle_file = str(pickle_path)
... command('mailman import21 import@example.com ' + pickle_file)
diff --git a/src/mailman/commands/tests/test_cli_control.py b/src/mailman/commands/tests/test_cli_control.py
index 43364490d6..b6fdbc10cd 100644
--- a/src/mailman/commands/tests/test_cli_control.py
+++ b/src/mailman/commands/tests/test_cli_control.py
@@ -29,7 +29,7 @@ from click.testing import CliRunner
from contextlib import ExitStack, suppress
from datetime import datetime, timedelta
from flufl.lock import SEP
-from importlib_resources import path
+from importlib.resources import path
from mailman.bin.master import WatcherState
from mailman.commands.cli_control import reopen, restart, start
from mailman.config import config
diff --git a/src/mailman/commands/tests/test_cli_import.py b/src/mailman/commands/tests/test_cli_import.py
index 5e26a2d9eb..bf35d9b7a3 100644
--- a/src/mailman/commands/tests/test_cli_import.py
+++ b/src/mailman/commands/tests/test_cli_import.py
@@ -21,7 +21,7 @@ import unittest
from click.testing import CliRunner
from contextlib import ExitStack
-from importlib_resources import path
+from importlib.resources import path
from mailman.app.lifecycle import create_list
from mailman.commands.cli_import import import21
from mailman.testing.layers import ConfigLayer
diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py
index da0f542332..6028b32359 100644
--- a/src/mailman/config/config.py
+++ b/src/mailman/config/config.py
@@ -24,7 +24,7 @@ import mailman.templates
from configparser import ConfigParser
from contextlib import ExitStack
from flufl.lock import Lock
-from importlib_resources import path, read_text
+from importlib.resources import path, read_text
from lazr.config import as_boolean, ConfigSchema
from mailman import version
from mailman.interfaces.configuration import (
diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py
index 7c79574096..00919cf458 100644
--- a/src/mailman/config/tests/test_configuration.py
+++ b/src/mailman/config/tests/test_configuration.py
@@ -22,7 +22,7 @@ import tempfile
import unittest
from contextlib import ExitStack
-from importlib_resources import path
+from importlib.resources import path
from mailman.config.config import (
Configuration,
external_configuration,
diff --git a/src/mailman/core/initialize.py b/src/mailman/core/initialize.py
index c5ff1e219b..5ebbb412bb 100644
--- a/src/mailman/core/initialize.py
+++ b/src/mailman/core/initialize.py
@@ -30,7 +30,7 @@ import logging
import mailman.core.logging
import mailman.config.config
-from importlib_resources import read_text
+from importlib.resources import read_text
from mailman.interfaces.database import IDatabaseFactory
from public import public
from zope.component import getUtility
diff --git a/src/mailman/email/tests/test_message.py b/src/mailman/email/tests/test_message.py
index 439cf64b04..73abfc8445 100644
--- a/src/mailman/email/tests/test_message.py
+++ b/src/mailman/email/tests/test_message.py
@@ -24,7 +24,7 @@ from email import message_from_binary_file
from email.header import Header
from email.parser import FeedParser
from email.utils import _has_surrogates
-from importlib_resources import path
+from importlib.resources import path
from mailman.app.lifecycle import create_list
from mailman.email.message import Message, UserNotification
from mailman.testing.helpers import (
diff --git a/src/mailman/handlers/tests/test_decorate.py b/src/mailman/handlers/tests/test_decorate.py
index 90134329ce..3b8bed2f03 100644
--- a/src/mailman/handlers/tests/test_decorate.py
+++ b/src/mailman/handlers/tests/test_decorate.py
@@ -22,7 +22,7 @@ import re
import email
import unittest
-from importlib_resources import open_binary as resource_open
+from importlib.resources import open_binary as resource_open
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.email.message import Message
diff --git a/src/mailman/handlers/tests/test_mimedel.py b/src/mailman/handlers/tests/test_mimedel.py
index f7bababe22..c21c599d7f 100644
--- a/src/mailman/handlers/tests/test_mimedel.py
+++ b/src/mailman/handlers/tests/test_mimedel.py
@@ -25,7 +25,7 @@ import tempfile
import unittest
from contextlib import contextmanager, ExitStack
-from importlib_resources import open_binary as resource_open, read_text
+from importlib.resources import open_binary as resource_open, read_text
from io import StringIO
from mailman.app.lifecycle import create_list
from mailman.config import config
diff --git a/src/mailman/plugins/docs/intro.rst b/src/mailman/plugins/docs/intro.rst
index b6827627c8..1e65c991e2 100644
--- a/src/mailman/plugins/docs/intro.rst
+++ b/src/mailman/plugins/docs/intro.rst
@@ -20,7 +20,7 @@ enabled by adding a section to your ``mailman.cfg`` file, such as:
We have such a configuration file handy.
- >>> from importlib_resources import path
+ >>> from importlib.resources import path
>>> config_file = str(cleanups.enter_context(
... path('mailman.plugins.testing', 'hooks.cfg')))
diff --git a/src/mailman/plugins/testing/layer.py b/src/mailman/plugins/testing/layer.py
index 1ac00463f4..0d40240ace 100644
--- a/src/mailman/plugins/testing/layer.py
+++ b/src/mailman/plugins/testing/layer.py
@@ -20,7 +20,7 @@
import os
from contextlib import ExitStack
-from importlib_resources import path
+from importlib.resources import path
from mailman.testing.helpers import (
hackenv,
TestableMaster,
diff --git a/src/mailman/rules/dmarc.py b/src/mailman/rules/dmarc.py
index b9a22f39b5..e014937512 100644
--- a/src/mailman/rules/dmarc.py
+++ b/src/mailman/rules/dmarc.py
@@ -24,7 +24,7 @@ import dns.resolver
from dns.exception import DNSException
from email.utils import parseaddr
-from importlib_resources import read_binary
+from importlib.resources import read_binary
from lazr.config import as_timedelta
from mailman.config import config
from mailman.core.i18n import _
diff --git a/src/mailman/rules/tests/test_dmarc.py b/src/mailman/rules/tests/test_dmarc.py
index 73777a11f8..eb31537a08 100644
--- a/src/mailman/rules/tests/test_dmarc.py
+++ b/src/mailman/rules/tests/test_dmarc.py
@@ -27,7 +27,7 @@ from dns.rdatatype import CNAME, TXT
from dns.resolver import NoAnswer, NoNameservers, NXDOMAIN
from email import message_from_bytes
from http.server import BaseHTTPRequestHandler, HTTPServer
-from importlib_resources import path
+from importlib.resources import path
from lazr.config import as_timedelta
from mailman.app.lifecycle import create_list
from mailman.config import config
diff --git a/src/mailman/runners/tests/test_digest.py b/src/mailman/runners/tests/test_digest.py
index 97d587f8a8..fb75175dbd 100644
--- a/src/mailman/runners/tests/test_digest.py
+++ b/src/mailman/runners/tests/test_digest.py
@@ -24,7 +24,7 @@ import unittest
from email import message_from_binary_file, message_from_bytes
from email.iterators import _structure as structure
from email.mime.text import MIMEText
-from importlib_resources import open_binary
+from importlib.resources import open_binary
from io import StringIO
from mailman.app.lifecycle import create_list
from mailman.config import config
diff --git a/src/mailman/testing/i18n.py b/src/mailman/testing/i18n.py
index 9ce0f20f47..42e8e8b21b 100644
--- a/src/mailman/testing/i18n.py
+++ b/src/mailman/testing/i18n.py
@@ -19,7 +19,7 @@
from flufl.i18n import registry
from gettext import GNUTranslations, NullTranslations
-from importlib_resources import open_binary
+from importlib.resources import open_binary
from public import public
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py
index 6ea9f67f9e..8afd35752f 100644
--- a/src/mailman/testing/layers.py
+++ b/src/mailman/testing/layers.py
@@ -32,7 +32,7 @@ import logging
import datetime
import tempfile
-from importlib_resources import files, read_text
+from importlib.resources import files, read_text
from lazr.config import as_boolean
from mailman.config import config
from mailman.core import initialize
diff --git a/src/mailman/utilities/filesystem.py b/src/mailman/utilities/filesystem.py
index 226d54dfe6..af9bef88a6 100644
--- a/src/mailman/utilities/filesystem.py
+++ b/src/mailman/utilities/filesystem.py
@@ -116,12 +116,12 @@ def first_inexistent_directory(path):
def path(package, module, *args, **kw):
"""Wrap around importlib.resources.path.
- importlib_resources.path (PyPI package we use for compatibility in Python <
+ importlib.resources.path (PyPI package we use for compatibility in Python <
3.7) has now diverged in behavior from importlib.resources.path (in Python
>= 3.7), especially in terms of supporting directories. Even though we can
just jump to the new version of the library, many distributions packaging
- Mailman do not package importlib_resources at all and instead patch the
- source code to simply replace importlib_resources with importlib.resources.
+ Mailman do not package importlib.resources at all and instead patch the
+ source code to simply replace importlib.resources with importlib.resources.
This utility method is meant to keep that patching ability without any
complicated patches to make Mailman work with standard library
@@ -129,7 +129,7 @@ def path(package, module, *args, **kw):
behavior causes problems for us.
"""
# Note to packaging teams: This function will handle both standard library
- # and 3rd party importlib_resources package. Please do not patch it.
+ # and 3rd party importlib.resources package. Please do not patch it.
if module:
module_package = '{}.{}'.format(package, module)
else:
@@ -143,5 +143,5 @@ def path(package, module, *args, **kw):
from importlib.resources import files # pragma: nocover
return files(module_package, *args, **kw) # pragma: nocover
except ImportError: # pragma: nocover
- from importlib_resources import files # pragma: nocover
+ from importlib.resources import files # pragma: nocover
return files(module_package, *args, **kw) # pragma: nocover
diff --git a/src/mailman/utilities/modules.py b/src/mailman/utilities/modules.py
index 0ec9e679b7..dc40376719 100644
--- a/src/mailman/utilities/modules.py
+++ b/src/mailman/utilities/modules.py
@@ -22,7 +22,7 @@ import sys
from contextlib import contextmanager
from importlib import import_module
-from importlib_resources import contents, is_resource, path
+from importlib.resources import contents, is_resource, path
from public import public
diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py
index e104c95091..9ffdebba0c 100644
--- a/src/mailman/utilities/tests/test_import.py
+++ b/src/mailman/utilities/tests/test_import.py
@@ -23,7 +23,7 @@ import unittest
from contextlib import ExitStack, redirect_stderr
from datetime import datetime, timedelta
from enum import Enum
-from importlib_resources import open_binary
+from importlib.resources import open_binary
from io import StringIO
from mailman.app.lifecycle import create_list
from mailman.config import config
diff --git a/src/mailman/utilities/tests/test_scrubber.py b/src/mailman/utilities/tests/test_scrubber.py
index 8f6de03cdb..9fa2862b10 100644
--- a/src/mailman/utilities/tests/test_scrubber.py
+++ b/src/mailman/utilities/tests/test_scrubber.py
@@ -19,7 +19,7 @@
import unittest
-from importlib_resources import open_text
+from importlib.resources import open_text
from mailman.testing.helpers import specialized_message_from_string as mfs
from mailman.utilities import scrubber
--
GitLab
From 974da30f392d8cfb3bc9d7fd7ce168a707af139e Mon Sep 17 00:00:00 2001
From: Abhilash Raj <raj.abhilash1@gmail.com>
Date: Sun, 9 Jul 2023 16:08:37 +0530
Subject: [PATCH 2/6] remove compat function to handle patching to
importlib.resources
---
src/mailman/utilities/filesystem.py | 35 -------------------
src/mailman/utilities/i18n.py | 2 +-
src/mailman/utilities/tests/test_modules.py | 2 +-
src/mailman/utilities/tests/test_templates.py | 2 +-
4 files changed, 3 insertions(+), 38 deletions(-)
diff --git a/src/mailman/utilities/filesystem.py b/src/mailman/utilities/filesystem.py
index af9bef88a6..cc4b3e3218 100644
--- a/src/mailman/utilities/filesystem.py
+++ b/src/mailman/utilities/filesystem.py
@@ -110,38 +110,3 @@ def first_inexistent_directory(path):
"The path %s exists but is not a directory.",
directory)
directory, rhs = os.path.split(directory)
-
-
-@public
-def path(package, module, *args, **kw):
- """Wrap around importlib.resources.path.
-
- importlib.resources.path (PyPI package we use for compatibility in Python <
- 3.7) has now diverged in behavior from importlib.resources.path (in Python
- >= 3.7), especially in terms of supporting directories. Even though we can
- just jump to the new version of the library, many distributions packaging
- Mailman do not package importlib.resources at all and instead patch the
- source code to simply replace importlib.resources with importlib.resources.
-
- This utility method is meant to keep that patching ability without any
- complicated patches to make Mailman work with standard library
- importlib.resources. This is only supposed to be used where the divergent
- behavior causes problems for us.
- """
- # Note to packaging teams: This function will handle both standard library
- # and 3rd party importlib.resources package. Please do not patch it.
- if module:
- module_package = '{}.{}'.format(package, module)
- else:
- module_package = package
-
- try:
- if sys.version_info < (3, 9):
- from importlib.resources import path
- return path(package, module, *args, **kw)
- else:
- from importlib.resources import files # pragma: nocover
- return files(module_package, *args, **kw) # pragma: nocover
- except ImportError: # pragma: nocover
- from importlib.resources import files # pragma: nocover
- return files(module_package, *args, **kw) # pragma: nocover
diff --git a/src/mailman/utilities/i18n.py b/src/mailman/utilities/i18n.py
index 9f2bb1dea0..cbc3f8392b 100644
--- a/src/mailman/utilities/i18n.py
+++ b/src/mailman/utilities/i18n.py
@@ -21,11 +21,11 @@ import os
import sys
from contextlib import ExitStack
+from importlib.resources import path
from itertools import product
from mailman.config import config
from mailman.core.constants import system_preferences
from mailman.interfaces.errors import MailmanError
-from mailman.utilities.filesystem import path
from public import public
diff --git a/src/mailman/utilities/tests/test_modules.py b/src/mailman/utilities/tests/test_modules.py
index ac5aae8ffb..f5db1697f9 100644
--- a/src/mailman/utilities/tests/test_modules.py
+++ b/src/mailman/utilities/tests/test_modules.py
@@ -22,11 +22,11 @@ import sys
import unittest
from contextlib import contextmanager, ExitStack
+from importlib.resources import path
from mailman.interfaces.rules import IRule
from mailman.interfaces.styles import IStyle
from mailman.testing.helpers import configuration
from mailman.testing.layers import ConfigLayer
-from mailman.utilities.filesystem import path
from mailman.utilities.modules import (
find_components,
find_pluggable_components,
diff --git a/src/mailman/utilities/tests/test_templates.py b/src/mailman/utilities/tests/test_templates.py
index 251a5d392b..60b12858a9 100644
--- a/src/mailman/utilities/tests/test_templates.py
+++ b/src/mailman/utilities/tests/test_templates.py
@@ -23,11 +23,11 @@ import tempfile
import unittest
from contextlib import ExitStack
+from importlib.resources import path as resource_path
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.interfaces.languages import ILanguageManager
from mailman.testing.layers import ConfigLayer
-from mailman.utilities.filesystem import path as resource_path
from mailman.utilities.i18n import find, search, TemplateNotFoundError
from zope.component import getUtility
--
GitLab
From 0b9dbc5cbff7813b21cbeb4716ea64eca5177f51 Mon Sep 17 00:00:00 2001
From: Abhilash Raj <raj.abhilash1@gmail.com>
Date: Sun, 9 Jul 2023 16:20:52 +0530
Subject: [PATCH 3/6] qa fixes
---
src/mailman/utilities/filesystem.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/mailman/utilities/filesystem.py b/src/mailman/utilities/filesystem.py
index cc4b3e3218..ae110dd5af 100644
--- a/src/mailman/utilities/filesystem.py
+++ b/src/mailman/utilities/filesystem.py
@@ -18,7 +18,6 @@
"""Filesystem utilities."""
import os
-import sys
from contextlib import suppress
from public import public
--
GitLab
From edabcae8d05909c21ae9b923b75b4f6fa92853a8 Mon Sep 17 00:00:00 2001
From: Mark Sapiro <mark@msapiro.net>
Date: Fri, 4 Aug 2023 18:54:06 -0700
Subject: [PATCH 5/6] Fix to avoid IsADirectoryError from
importlib.resources.path with Python 3.9
---
src/mailman/utilities/i18n.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/mailman/utilities/i18n.py b/src/mailman/utilities/i18n.py
index cbc3f8392b..913412320f 100644
--- a/src/mailman/utilities/i18n.py
+++ b/src/mailman/utilities/i18n.py
@@ -21,7 +21,7 @@ import os
import sys
from contextlib import ExitStack
-from importlib.resources import path
+from importlib.resources import files
from itertools import product
from mailman.config import config
from mailman.core.constants import system_preferences
@@ -114,7 +114,7 @@ def search(resources, template_file, mlist=None, language=None):
languages.append(language)
languages.reverse()
# The non-language qualified $template_dir paths in search order.
- templates_dir = str(resources.enter_context(path('mailman', 'templates')))
+ templates_dir = files('mailman').joinpath('templates')
paths = [templates_dir, os.path.join(config.TEMPLATE_DIR, 'site')]
if mlist is not None:
# Don't forget these are in REVERSE search order!
--
GitLab
From edd4a5e8d4b0a6fa1b5f0ba40b2dab66de30102b Mon Sep 17 00:00:00 2001
From: Mark Sapiro <mark@msapiro.net>
Date: Fri, 4 Aug 2023 22:41:49 -0700
Subject: [PATCH 6/6] More importlib.resources.path fixes.
---
src/mailman/mta/tests/data/__init__.py | 0
src/mailman/utilities/i18n.py | 3 ++-
src/mailman/utilities/tests/test_modules.py | 6 +++---
src/mailman/utilities/tests/test_templates.py | 4 ++--
4 files changed, 7 insertions(+), 6 deletions(-)
create mode 100644 src/mailman/mta/tests/data/__init__.py
diff --git a/src/mailman/mta/tests/data/__init__.py b/src/mailman/mta/tests/data/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/mailman/utilities/i18n.py b/src/mailman/utilities/i18n.py
index 913412320f..a694ae8ddc 100644
--- a/src/mailman/utilities/i18n.py
+++ b/src/mailman/utilities/i18n.py
@@ -114,7 +114,8 @@ def search(resources, template_file, mlist=None, language=None):
languages.append(language)
languages.reverse()
# The non-language qualified $template_dir paths in search order.
- templates_dir = files('mailman').joinpath('templates')
+ templates_dir = str(resources.enter_context(
+ files('mailman').joinpath('templates')))
paths = [templates_dir, os.path.join(config.TEMPLATE_DIR, 'site')]
if mlist is not None:
# Don't forget these are in REVERSE search order!
diff --git a/src/mailman/utilities/tests/test_modules.py b/src/mailman/utilities/tests/test_modules.py
index f5db1697f9..baa39417b3 100644
--- a/src/mailman/utilities/tests/test_modules.py
+++ b/src/mailman/utilities/tests/test_modules.py
@@ -22,7 +22,7 @@ import sys
import unittest
from contextlib import contextmanager, ExitStack
-from importlib.resources import path
+from importlib.resources import files
from mailman.interfaces.rules import IRule
from mailman.interfaces.styles import IStyle
from mailman.testing.helpers import configuration
@@ -165,7 +165,7 @@ class AbstractStyle:
def test_find_pluggable_components_by_plugin_name(self):
with ExitStack() as resources:
testing_path = resources.enter_context(
- path('mailman.plugins.testing', ''))
+ files('mailman.plugins.testing'))
resources.enter_context(hack_syspath(0, str(testing_path)))
resources.enter_context(configuration('plugin.example', **{
'class': 'example.hooks.ExamplePlugin',
@@ -177,7 +177,7 @@ class AbstractStyle:
def test_find_pluggable_components_by_component_package(self):
with ExitStack() as resources:
testing_path = resources.enter_context(
- path('mailman.plugins.testing', ''))
+ files('mailman.plugins.testing'))
resources.enter_context(hack_syspath(0, str(testing_path)))
resources.enter_context(configuration('plugin.example', **{
'class': 'example.hooks.ExamplePlugin',
diff --git a/src/mailman/utilities/tests/test_templates.py b/src/mailman/utilities/tests/test_templates.py
index 60b12858a9..43c680b23e 100644
--- a/src/mailman/utilities/tests/test_templates.py
+++ b/src/mailman/utilities/tests/test_templates.py
@@ -23,7 +23,7 @@ import tempfile
import unittest
from contextlib import ExitStack
-from importlib.resources import path as resource_path
+from importlib.resources import files as resource_path
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.interfaces.languages import ILanguageManager
@@ -64,7 +64,7 @@ class TestSearchOrder(unittest.TestCase):
# /m/ as the root.
with ExitStack() as resources:
in_tree = str(resources.enter_context(
- resource_path('mailman', 'templates')).parent)
+ resource_path('mailman').joinpath('templates')).parent)
raw_search_order = search(
resources, template_file, mailing_list, language)
for path in raw_search_order:
--
GitLab

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Fri Aug 18 11:00:46 UTC 2023 - Andreas Schneider <asn@cryptomilk.org>
- Fix issues with importlib_resources for Python 3.11
* Added mailman-fix-importlib-resources.patch
-------------------------------------------------------------------
Sat Jul 1 12:49:02 UTC 2023 - Andreas Schneider <asn@cryptomilk.org>
- Add missing require for psycopg2
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Jun 7 15:40:27 UTC 2023 - Andreas Schneider <asn@cryptomilk.org> Wed Jun 7 15:40:27 UTC 2023 - Andreas Schneider <asn@cryptomilk.org>

View File

@ -70,6 +70,10 @@ Source31: python-mailman.rpmlintrc
# #
Source100: https://gitlab.com/mailman/mailman/-/raw/master/src/mailman/testing/ssl_test_cert.crt Source100: https://gitlab.com/mailman/mailman/-/raw/master/src/mailman/testing/ssl_test_cert.crt
Source101: https://gitlab.com/mailman/mailman/-/raw/master/src/mailman/testing/ssl_test_key.key Source101: https://gitlab.com/mailman/mailman/-/raw/master/src/mailman/testing/ssl_test_key.key
#
# Backport of https://gitlab.com/mailman/mailman/-/merge_requests/1130.patch
Patch0: mailman-fix-importlib-resources.patch
#
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
@ -106,6 +110,7 @@ Requires: %{mypython}-gunicorn
Requires: %{mypython}-importlib-resources >= 1.1.0 Requires: %{mypython}-importlib-resources >= 1.1.0
Requires: %{mypython}-lazr.config Requires: %{mypython}-lazr.config
Requires: %{mypython}-passlib Requires: %{mypython}-passlib
Requires: %{mypython}-psycopg2
Requires: %{mypython}-python-dateutil >= 2.0 Requires: %{mypython}-python-dateutil >= 2.0
Requires: %{mypython}-requests Requires: %{mypython}-requests
Requires: %{mypython}-setuptools Requires: %{mypython}-setuptools
@ -277,7 +282,7 @@ done
%endif %endif
%dir %attr(750,root,mailman) %{_sysconfdir}/%{mailman_name}.d %dir %attr(750,root,mailman) %{_sysconfdir}/%{mailman_name}.d
%dir %attr(750,mailman,mailman) %{mailman_homedir} %dir %attr(750,mailman,mailman) %{mailman_homedir}
%dir %attr(770,mailman,mailman) %{mailman_homedir}/data %dir %attr(770,mailman,mail) %{mailman_homedir}/data
%dir %attr(750,mailman,mailman) %{mailman_spooldir} %dir %attr(750,mailman,mailman) %{mailman_spooldir}
%dir %attr(750,mailman,mailman) %{mailman_logdir} %dir %attr(750,mailman,mailman) %{mailman_logdir}
%ghost %dir %{mailman_rundir} %ghost %dir %{mailman_rundir}