papi: remove deprecated pkg_resources
Replace use of pkg_resources with new supported APIs under importlib. Type: fix Change-Id: I67a7d936c634107c1ae87c0a06bea2355d906739 Signed-off-by: Ole Troan <otroan@employees.org>
This commit is contained in:
@ -21,7 +21,7 @@ requirements = []
|
||||
|
||||
setup(
|
||||
name="vpp_papi",
|
||||
version="2.1.0",
|
||||
version="2.2.0",
|
||||
description="VPP Python binding",
|
||||
author="Ole Troan",
|
||||
author_email="ot@cisco.com",
|
||||
|
@ -10,9 +10,10 @@ from .vpp_serializer import BaseTypes # noqa: F401
|
||||
from .vpp_serializer import VPPEnumType, VPPType, VPPTypeAlias # noqa: F401
|
||||
from .vpp_serializer import VPPMessage, VPPUnionType # noqa: F401
|
||||
|
||||
import pkg_resources # part of setuptools
|
||||
import importlib.metadata as metadata
|
||||
|
||||
try:
|
||||
__version__ = pkg_resources.get_distribution("vpp_papi").version
|
||||
except pkg_resources.DistributionNotFound:
|
||||
"""Can't find vpp_papi via setuptools"""
|
||||
__version__ = metadata.version("vpp_papi")
|
||||
except metadata.PackageNotFoundError:
|
||||
# Can't find vpp_papi via importlib.metadata
|
||||
__version__ = "0.0.0"
|
||||
|
@ -29,7 +29,8 @@ import fnmatch
|
||||
import weakref
|
||||
import atexit
|
||||
import time
|
||||
import pkg_resources
|
||||
import importlib.resources as resources
|
||||
|
||||
from .vpp_format import verify_enum_hint
|
||||
from .vpp_serializer import VPPType, VPPEnumType, VPPEnumFlagType, VPPUnionType
|
||||
from .vpp_serializer import VPPMessage, vpp_get_type, VPPTypeAlias
|
||||
@ -502,10 +503,10 @@ class VPPApiClient:
|
||||
raise e
|
||||
else:
|
||||
# Bootstrap the API (memclnt.api bundled with VPP PAPI)
|
||||
resource_path = "/".join(("data", "memclnt.api.json"))
|
||||
file_content = pkg_resources.resource_string(__name__, resource_path)
|
||||
with resources.open_text("vpp_papi.data", "memclnt.api.json") as f:
|
||||
resource_content = f.read()
|
||||
self.messages, self.services = VPPApiJSONFiles.process_json_str(
|
||||
file_content
|
||||
resource_content
|
||||
)
|
||||
|
||||
# Basic sanity check
|
||||
|
Reference in New Issue
Block a user