From 5f67bb99a8bc84519bf260ce992fac02aa1d803b Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Tue, 14 Nov 2023 00:50:32 +0100 Subject: [PATCH] Full cleanup of pkg_resources (#9797) Fixes #9606 This PRs removes some elements that were related to pkg_resources dependency and its deprecation. --- .pylintrc | 2 +- .../_internal/tests/dns_gehirn_test.py | 1 - .../certbot_dns_ovh/_internal/tests/dns_ovh_test.py | 1 + certbot/docs/contributing.rst | 8 ++++---- pytest.ini | 10 +--------- tools/pinning/current/pyproject.toml | 5 ----- tools/requirements.txt | 2 +- 7 files changed, 8 insertions(+), 21 deletions(-) diff --git a/.pylintrc b/.pylintrc index 05f34fb1f..e37ba1fc7 100644 --- a/.pylintrc +++ b/.pylintrc @@ -524,7 +524,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace, # List of module names for which member attributes should not be checked # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis -ignored-modules=pkg_resources,confargparse,argparse +ignored-modules=confargparse,argparse # Show a hint with possible names when a member name was not found. The aspect # of finding the hint is based on edit distance. diff --git a/certbot-dns-gehirn/certbot_dns_gehirn/_internal/tests/dns_gehirn_test.py b/certbot-dns-gehirn/certbot_dns_gehirn/_internal/tests/dns_gehirn_test.py index 3df3c5431..331059a60 100644 --- a/certbot-dns-gehirn/certbot_dns_gehirn/_internal/tests/dns_gehirn_test.py +++ b/certbot-dns-gehirn/certbot_dns_gehirn/_internal/tests/dns_gehirn_test.py @@ -1,7 +1,6 @@ """Tests for certbot_dns_gehirn._internal.dns_gehirn.""" import sys -import unittest from unittest import mock import pytest diff --git a/certbot-dns-ovh/certbot_dns_ovh/_internal/tests/dns_ovh_test.py b/certbot-dns-ovh/certbot_dns_ovh/_internal/tests/dns_ovh_test.py index a5d553cd9..15ae728f2 100644 --- a/certbot-dns-ovh/certbot_dns_ovh/_internal/tests/dns_ovh_test.py +++ b/certbot-dns-ovh/certbot_dns_ovh/_internal/tests/dns_ovh_test.py @@ -22,6 +22,7 @@ class AuthenticatorTest(test_util.TempDirTestCase, DOMAIN_NOT_FOUND = Exception('Domain example.com not found') LOGIN_ERROR = HTTPError('403 Client Error: Forbidden for url: https://eu.api.ovh.com/1.0/...', response=Response()) + def setUp(self): super().setUp() diff --git a/certbot/docs/contributing.rst b/certbot/docs/contributing.rst index 296ccf2fb..1a6c402af 100644 --- a/certbot/docs/contributing.rst +++ b/certbot/docs/contributing.rst @@ -328,8 +328,8 @@ Writing your own plugin for one example of that. Certbot client supports dynamic discovery of plugins through the -`setuptools entry points`_ using the `certbot.plugins` group. This -way you can, for example, create a custom implementation of +`importlib.metadata entry points`_ using the `certbot.plugins` group. +This way you can, for example, create a custom implementation of `~certbot.interfaces.Authenticator` or the `~certbot.interfaces.Installer` without having to merge it with the core upstream source code. An example is provided in @@ -352,8 +352,8 @@ users install it system-wide with `pip install`. Note that this will only work for users who have Certbot installed from OS packages or via pip. -.. _`setuptools entry points`: - https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points +.. _`importlib.metadata entry points`: + https://importlib-metadata.readthedocs.io/en/latest/using.html#entry-points Writing your own plugin snap ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pytest.ini b/pytest.ini index c2bfe4da9..699902177 100644 --- a/pytest.ini +++ b/pytest.ini @@ -21,13 +21,7 @@ # updated. # 4) Ignore our own PendingDeprecationWarning about update_symlinks soon to be dropped. # See https://github.com/certbot/certbot/issues/6284. -# 5) Ignore pkg_resources.declare_namespace used in a large number of Google's Python -# libs. e.g. https://github.com/googleapis/google-auth-library-python/issues/1229. -# It is also is used in sphinxcontrib-devhelp 1.0.2 which as of writing this -# is the latest version of that library. See -# https://github.com/sphinx-doc/sphinxcontrib-devhelp/blob/1.0.2/setup.py#L69. -# 6) Ignore DeprecationWarning from using pkg_resources API -# 7) Ignore DeprecationWarning for datetime.utcfromtimestamp() triggered +# 5) Ignore DeprecationWarning for datetime.utcfromtimestamp() triggered # when importing the pytz.tzinfo module # https://github.com/stub42/pytz/issues/105 filterwarnings = @@ -36,6 +30,4 @@ filterwarnings = ignore:.*rsyncdir:DeprecationWarning ignore:'urllib3.contrib.pyopenssl:DeprecationWarning:requests_toolbelt ignore:update_symlinks is deprecated:PendingDeprecationWarning - ignore:.*declare_namespace\(':DeprecationWarning - ignore:pkg_resources is deprecated as an API:DeprecationWarning ignore:.*datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning:pytz.tzinfo diff --git a/tools/pinning/current/pyproject.toml b/tools/pinning/current/pyproject.toml index 2d908679c..74547a1a5 100644 --- a/tools/pinning/current/pyproject.toml +++ b/tools/pinning/current/pyproject.toml @@ -70,11 +70,6 @@ cryptography = "!= 37.0.3" # https://github.com/python-poetry/poetry-plugin-export/issues/168 is resolved. poetry = "<1.3.0" -# setuptools 67.5.0 deprecated pkg_resources which we still use. Let's pin it -# back until this is fixed. Doing this work is being tracked by -# https://github.com/certbot/certbot/issues/9606. -setuptools = "<67.5.0" - # Branch 4.x of tox introduces backward incompatibility changes. The tox.ini # file in the project must be adapted accordingly before moving out of the 3.x # branch. Once done, the following constraint should become tox >= 4 to keep diff --git a/tools/requirements.txt b/tools/requirements.txt index 1ed0ca0ee..e424f2782 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -147,7 +147,7 @@ s3transfer==0.7.0 ; python_version >= "3.8" and python_version < "4.0" secretstorage==3.3.3 ; python_version >= "3.8" and python_version < "4.0" and sys_platform == "linux" semantic-version==2.10.0 ; python_version >= "3.8" and python_version < "4.0" setuptools-rust==1.7.0 ; python_version >= "3.8" and python_version < "4.0" -setuptools==67.4.0 ; python_version >= "3.8" and python_version < "4.0" +setuptools==68.2.2 ; python_version >= "3.8" and python_version < "4.0" shellingham==1.5.3 ; python_version >= "3.8" and python_version < "4.0" six==1.16.0 ; python_version >= "3.8" and python_version < "4.0" snowballstemmer==2.2.0 ; python_version >= "3.8" and python_version < "4.0"