feat: add installer to InstalledDist (#1762)
## Summary Add `installer` method to `InstalledDist` to distinguish between different installers. Might be nice to add an enum for all possible installers, but this might be too hard to keep up to date :). The `INSTALLER` file is a file that can be added to the `.dist-info` folder with the installer name. Closes: #1759 ## Test Plan Not sure if there is a place I can automatically test it, if you have a pointer I would be happy to add a test.
This commit is contained in:
@@ -111,6 +111,16 @@ impl InstalledDist {
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the `INSTALLER` of the distribution.
|
||||
pub fn installer(&self) -> Result<Option<String>> {
|
||||
let path = self.path().join("INSTALLER");
|
||||
match fs::read_to_string(path) {
|
||||
Ok(installer) => Ok(Some(installer)),
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(None),
|
||||
Err(err) => Err(err.into()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the [`Url`] of the distribution, if it is editable.
|
||||
pub fn as_editable(&self) -> Option<&Url> {
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user