File tree Expand file tree Collapse file tree 3 files changed +28
-5
lines changed
Expand file tree Collapse file tree 3 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 1212- Fixes:
1313 - Fix unexpected 'No active span' IllegalStateError (#311 )
1414 - ** Tentative** : Set upper bound <=5.9.5 for psutil package due to test failure. (#326 )
15+ - Remove ` DeprecationWarning ` from ` pkg_resources ` by replace it with ` importlib_metadata ` (#329 )
1516
1617### 1.0.1
1718
Original file line number Diff line number Diff line change 2020import re
2121import traceback
2222
23- import pkg_resources
23+ import sys
24+
25+ if sys .version_info < (3 , 8 ):
26+ import pkg_resources
27+ PackageNotFoundException = pkg_resources .DistributionNotFound
28+
29+ def get_pkg_version (pkg_name ):
30+ return pkg_resources .get_distribution (pkg_name ).version
31+
32+ else :
33+ import importlib .metadata
34+ PackageNotFoundException = importlib .metadata .PackageNotFoundError
35+
36+ def get_pkg_version (pkg_name ):
37+ return importlib .metadata .version (pkg_name )
38+
2439from packaging import version
2540
2641import skywalking
@@ -78,8 +93,8 @@ def pkg_version_check(plugin):
7893 rules = plugin .version_rule .get ('rules' )
7994
8095 try :
81- current_pkg_version = pkg_resources . get_distribution (pkg_name ). version
82- except pkg_resources . DistributionNotFound :
96+ current_pkg_version = get_pkg_version (pkg_name )
97+ except PackageNotFoundException :
8398 # when failed to get the version, we consider it as supported.
8499 return supported
85100
Original file line number Diff line number Diff line change 1818import os
1919import re
2020
21- import pkg_resources
2221from grpc_tools import protoc
2322from packaging import version
23+ import sys
24+
25+ if sys .version_info < (3 , 8 ):
26+ import pkg_resources
27+ grpc_tools_version = pkg_resources .get_distribution ('grpcio-tools' ).version
28+
29+ else :
30+ import importlib .metadata
31+ grpc_tools_version = importlib .metadata .version ('grpcio-tools' )
2432
25- grpc_tools_version = pkg_resources .get_distribution ('grpcio-tools' ).version
2633dest_dir = 'skywalking/protocol'
2734src_dir = 'protocol'
2835
You can’t perform that action at this time.
0 commit comments