papi: expose vpp_papi version to client 90/30490/8
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Fri, 18 Dec 2020 23:47:27 +0000 (18:47 -0500)
committerOle Tr�an <otroan@employees.org>
Tue, 9 Feb 2021 18:32:40 +0000 (18:32 +0000)
root@ae2a2e85c5d4:/vpp/src/vpp-api/python# python3
Python 3.6.9 (default, Oct  8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import vpp_papi
>>> vpp_papi.__version__
'1.6.2'

Type: feature

Change-Id: I73025427a58214a842245fceaa77daa7acd3e6f8
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
src/vpp-api/python/vpp_papi/__init__.py

index 609001e..b2b4fc7 100644 (file)
@@ -9,3 +9,9 @@ from . macaddress import MACAddress, mac_pton, mac_ntop  # noqa: F401
 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
+try:
+    __version__ = pkg_resources.get_distribution("vpp_papi").version
+except (pkg_resources.DistributionNotFound):
+    """Can't find vpp_papi via setuptools"""