Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions src/batou/lib/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def verify(self):
)
# Is this Python (still) functional 'enough'
# from a setuptools/distribute perspective?
self.assert_cmd('bin/python -c "import pkg_resources"')
self.assert_cmd('bin/python -c "import pip"')

def update(self):
Expand All @@ -71,30 +70,13 @@ def update(self):

def verify_pkg(self, pkg):
try:
self.cmd(
'bin/python -c "'
"import pkg_resources; "
"assert pkg_resources.require('{}')[0].parsed_version == "
"pkg_resources.parse_version('{}')\"".format(
pkg.package, pkg.version
)
)
self.cmd('bin/python -c \''
'import importlib.metadata; '
f'assert importlib.metadata.version("{pkg.package}") == '
f' "{pkg.version}"'
'\'')
except CmdExecutionError:
raise batou.UpdateNeeded()
# Is the package usable? Is the package a module? This might be
# overspecific - I'm looking for a way to deal with:
# https://github.com/pypa/pip/issues/3 if a namespace package was not
# installed cleanly. This only works (currently), when the package name
# corresponds with what it contains. I.E. it works for zc.buildout but
# not for distribute, which installs a setuptools package.
if pkg.check_package_is_module:
try:
self.cmd(
'bin/python -c "import pkg_resources; '
'import {0};{0}.__file__"'.format(pkg.package)
)
except CmdExecutionError:
raise batou.UpdateNeeded()

def update_pkg(self, pkg):
if self.installer == "pip":
Expand Down
Loading