2
2
from AccessControl .class_init import InitializeClass
3
3
from AccessControl .requestmethod import postonly
4
4
from App .config import getConfiguration
5
+ from importlib .metadata import distribution
6
+ from importlib .metadata import PackageNotFoundError
5
7
from io import StringIO
6
8
from OFS .SimpleItem import SimpleItem
7
9
from plone .base .interfaces import IMigrationTool
15
17
from zope .interface import implementer
16
18
17
19
import logging
18
- import pkg_resources
19
20
import sys
20
21
import transaction
21
22
@@ -149,7 +150,7 @@ def getInstanceVersion(self):
149
150
150
151
if version == "unknown" :
151
152
if _version :
152
- # Instance version was not pkg_resources compatible ...
153
+ # Instance version was not standard ...
153
154
_version = _version .replace ("devel (svn/unreleased)" , "dev" )
154
155
_version = _version .rstrip ("-final" )
155
156
_version = _version .rstrip ("final" )
@@ -185,7 +186,7 @@ def getFileSystemVersion(self):
185
186
186
187
def getSoftwareVersion (self ):
187
188
# The software version.
188
- dist = pkg_resources . get_distribution ("Products.CMFPlone" )
189
+ dist = distribution ("Products.CMFPlone" )
189
190
return dist .version
190
191
191
192
security .declareProtected (ManagePortal , "needUpgrading" )
@@ -199,24 +200,23 @@ def needUpgrading(self):
199
200
def coreVersions (self ):
200
201
# Useful core information.
201
202
vars = {}
202
- get_dist = pkg_resources .get_distribution
203
- vars ["Zope" ] = get_dist ("Zope" ).version
203
+ vars ["Zope" ] = distribution ("Zope" ).version
204
204
vars ["Python" ] = sys .version
205
205
vars ["Platform" ] = sys .platform
206
- vars ["Plone" ] = get_dist ("Products.CMFPlone" ).version
206
+ vars ["Plone" ] = distribution ("Products.CMFPlone" ).version
207
207
vars ["Plone Instance" ] = self .getInstanceVersion ()
208
208
vars ["Plone File System" ] = self .getFileSystemVersion ()
209
- vars ["CMF" ] = get_dist ("Products.CMFCore" ).version
209
+ vars ["CMF" ] = distribution ("Products.CMFCore" ).version
210
210
vars ["Debug mode" ] = getConfiguration ().debug_mode and "Yes" or "No"
211
211
try :
212
- vars ["PIL" ] = get_dist ("PIL" ).version
213
- except pkg_resources . DistributionNotFound :
212
+ vars ["PIL" ] = distribution ("PIL" ).version
213
+ except PackageNotFoundError :
214
214
try :
215
- vars ["PIL" ] = get_dist ("PILwoTK" ).version
216
- except pkg_resources . DistributionNotFound :
215
+ vars ["PIL" ] = distribution ("PILwoTK" ).version
216
+ except PackageNotFoundError :
217
217
try :
218
- vars ["PIL" ] = "%s (Pillow)" % get_dist ("Pillow" ).version
219
- except pkg_resources . DistributionNotFound :
218
+ vars ["PIL" ] = "%s (Pillow)" % distribution ("Pillow" ).version
219
+ except PackageNotFoundError :
220
220
try :
221
221
import _imaging
222
222
0 commit comments