diff --git a/jediepcserver.py b/jediepcserver.py index 693eea4..e6b0ef2 100755 --- a/jediepcserver.py +++ b/jediepcserver.py @@ -26,16 +26,13 @@ """ import argparse -import glob -import itertools import logging import logging.handlers import os import re -import site import sys -import pkg_resources from collections import namedtuple +import packaging.version import jedi import jedi.api @@ -127,8 +124,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 +379,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'],