File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed
openwisp_utils/admin_theme Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change 11import platform
2+ import sys
23from collections import OrderedDict
34
4- import pkg_resources
55from django .conf import settings
66from django .utils .module_loading import import_string
77
88EXTRA_OPENWISP_PACKAGES = ["netdiff" , "netjsonconfig" ]
99
1010
11- def get_installed_openwisp_packages ():
12- dists = pkg_resources .working_set
13- return {
14- dist .key : dist .version
15- for dist in dists
16- if dist .key .startswith ("openwisp" ) or dist .key in EXTRA_OPENWISP_PACKAGES
17- }
11+ # python 3.10+
12+ if sys .version_info > (3 , 9 ):
13+ import importlib
14+
15+ def get_installed_openwisp_packages ():
16+ dists = importlib .metadata .distributions ()
17+ return {
18+ dist .name : dist .version
19+ for dist in dists
20+ if dist .name .startswith ("openwisp" ) or dist .name in EXTRA_OPENWISP_PACKAGES
21+ }
22+
23+
24+ # legacy python 3.9, deprecated on recent python versions
25+ else :
26+ import pkg_resources
27+
28+ def get_installed_openwisp_packages ():
29+ dists = pkg_resources .working_set
30+ return {
31+ dist .key : dist .version
32+ for dist in dists
33+ if dist .key .startswith ("openwisp" ) or dist .key in EXTRA_OPENWISP_PACKAGES
34+ }
1835
1936
2037def _get_openwisp2_detail (attribute_name , fallback = None ):
You can’t perform that action at this time.
0 commit comments