From 2a08049c1e50ca7504d2950c72c54a10fc6858eb Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 8 Jul 2023 18:20:37 +0200 Subject: [PATCH 1/2] [fix] Failed to start Jedi EPC server / DeprecationWarning: pkg_resources Jedi EPC server won't start due to a deprication warning:: Error (jedi): ================================ Failed to start Jedi EPC server. ================================ *** EPC Error *** Server may raise an error. Use "M-x epc:pop-to-last-server-process-buffer RET" to see full traceback: ../jediepcserver.py:38: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import pkg_resources Signed-off-by: Markus Heiser --- jediepcserver.py | 23 +++++++++++------------ setup.py | 1 + 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jediepcserver.py b/jediepcserver.py index 693eea4..91a24e7 100755 --- a/jediepcserver.py +++ b/jediepcserver.py @@ -34,8 +34,8 @@ import re import site import sys -import pkg_resources from collections import namedtuple +import packaging.version import jedi import jedi.api @@ -127,8 +127,8 @@ def jedi_create_environment(venv, safe=False): return jedienv jedi_script_wrapper = jedi.Script -JEDI_VERSION = pkg_resources.parse_version(jedi.__version__) -if JEDI_VERSION < pkg_resources.parse_version('0.16.0'): +JEDI_VERSION = packaging.version.parse(jedi.__version__) +if JEDI_VERSION < packaging.version.parse('0.16.0'): class JediScriptCompatWrapper: def __init__(self, code, path, **kwargs): self.source = code @@ -382,19 +382,18 @@ def get_names_recursively(definition, parent=None): def get_module_version(module): - notfound = object() - for key in ['__version__', 'version']: - version = getattr(module, key, notfound) - if version is not notfound: - return version try: - from pkg_resources import get_distribution, DistributionNotFound + from importlib.metadata import version, PackageNotFoundError try: - return get_distribution(module.__name__).version - except DistributionNotFound: + return version(module.__name__) + except PackageNotFoundError: pass except ImportError: - pass + notfound = object() + for key in ['__version__', 'version']: + version = getattr(module, key, notfound) + if version is not notfound: + return version def path_expand_vars_and_user(p): diff --git a/setup.py b/setup.py index 78641d1..053092b 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ "epc>=0.0.4", "argparse", "setuptools", + "packaging", ], entry_points={ 'console_scripts': ['jediepcserver = jediepcserver:main'], From 6c36a91cd0cec35d1714929d4e74aff2b23b9367 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 9 Jul 2023 11:38:15 +0200 Subject: [PATCH 2/2] [fix] remove unused imports Signed-off-by: Markus Heiser --- jediepcserver.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/jediepcserver.py b/jediepcserver.py index 91a24e7..e6b0ef2 100755 --- a/jediepcserver.py +++ b/jediepcserver.py @@ -26,13 +26,10 @@ """ import argparse -import glob -import itertools import logging import logging.handlers import os import re -import site import sys from collections import namedtuple import packaging.version