PackageStillNeededError: add pkg that needs spec to exception msg (#43845)
* PackageStillNeededError: add pkg that needs spec to exception msg * PackageStillNeededError: f-string with short fmt and hash * PackageStillNeededError: split long string
This commit is contained in:
parent
49d3eb1723
commit
f2d0ba8fcc
1 changed files with 6 additions and 1 deletions
|
@ -2555,7 +2555,12 @@ class PackageStillNeededError(InstallError):
|
||||||
"""Raised when package is still needed by another on uninstall."""
|
"""Raised when package is still needed by another on uninstall."""
|
||||||
|
|
||||||
def __init__(self, spec, dependents):
|
def __init__(self, spec, dependents):
|
||||||
super().__init__("Cannot uninstall %s" % spec)
|
spec_fmt = spack.spec.DEFAULT_FORMAT + " /{hash:7}"
|
||||||
|
dep_fmt = "{name}{@versions} /{hash:7}"
|
||||||
|
super().__init__(
|
||||||
|
f"Cannot uninstall {spec.format(spec_fmt)}, "
|
||||||
|
f"needed by {[dep.format(dep_fmt) for dep in dependents]}"
|
||||||
|
)
|
||||||
self.spec = spec
|
self.spec = spec
|
||||||
self.dependents = dependents
|
self.dependents = dependents
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue