fix(remove collection of dependencies)
https://github.com/steven-omaha/pacdef/pull/50#issuecomment-1912284202 Signed-off-by: innocentzero <isfarulhaque@proton.me>
This commit is contained in:
@@ -40,18 +40,7 @@ impl Backend for Python {
|
|||||||
let output = run_pip_command(&mut cmd, self.get_switches_runtime())?;
|
let output = run_pip_command(&mut cmd, self.get_switches_runtime())?;
|
||||||
match self.get_binary(){
|
match self.get_binary(){
|
||||||
"pip" => extract_pacdef_packages(output),
|
"pip" => extract_pacdef_packages(output),
|
||||||
"pipx" => {
|
"pipx" => extract_pacdef_packages_pipx(output),
|
||||||
let packs = extract_pacdef_packages_pipx(&output);
|
|
||||||
let deps = extract_pacdef_packages_deps(&output);
|
|
||||||
match (packs, deps) {
|
|
||||||
(Ok(mut pack), Ok(deps)) => {
|
|
||||||
pack.extend(deps.into_iter());
|
|
||||||
Ok(pack)
|
|
||||||
}
|
|
||||||
(Ok(pack), Err(_)) => Ok(pack),
|
|
||||||
(Err(pack), _) => Err(pack),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => panic!("Cannot use {} for package management in python. Please use a valid package manager like pip or pipx", self.get_binary()),
|
_ => panic!("Cannot use {} for package management in python. Please use a valid package manager like pip or pipx", self.get_binary()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +50,7 @@ impl Backend for Python {
|
|||||||
let output = run_pip_command(&mut cmd, self.get_switches_explicit())?;
|
let output = run_pip_command(&mut cmd, self.get_switches_explicit())?;
|
||||||
match self.get_binary(){
|
match self.get_binary(){
|
||||||
"pip" => extract_pacdef_packages(output),
|
"pip" => extract_pacdef_packages(output),
|
||||||
"pipx" => extract_pacdef_packages_pipx(&output),
|
"pipx" => extract_pacdef_packages_pipx(output),
|
||||||
_ => panic!("Cannot use {} for package management in python. Please use a valid package manager like pip or pipx", self.get_binary()),
|
_ => panic!("Cannot use {} for package management in python. Please use a valid package manager like pip or pipx", self.get_binary()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +102,7 @@ fn extract_pacdef_packages(value: Value) -> Result<HashSet<Package>> {
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_pacdef_packages_pipx(value: &Value) -> Result<HashSet<Package>> {
|
fn extract_pacdef_packages_pipx(value: Value) -> Result<HashSet<Package>> {
|
||||||
let result = value["venvs"]
|
let result = value["venvs"]
|
||||||
.as_object()
|
.as_object()
|
||||||
.context("getting inner json object")?
|
.context("getting inner json object")?
|
||||||
@@ -122,24 +111,3 @@ fn extract_pacdef_packages_pipx(value: &Value) -> Result<HashSet<Package>> {
|
|||||||
.collect();
|
.collect();
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_pacdef_packages_deps(value: &Value) -> Result<HashSet<Package>> {
|
|
||||||
let mut alldeps: HashSet<Package> = HashSet::new();
|
|
||||||
let _ = value["venvs"]
|
|
||||||
.as_object()
|
|
||||||
.context("getting inner json object")?
|
|
||||||
.iter()
|
|
||||||
.map(|(_, deps_obj)| -> Result<()> {
|
|
||||||
let deps: HashSet<Package> = deps_obj["metadata"]["main_package"]
|
|
||||||
["apps_paths_of_dependencies"]
|
|
||||||
.as_object()
|
|
||||||
.context("getting inner dependencies")?
|
|
||||||
.iter()
|
|
||||||
.map(|(name, _)| Package::from(name.as_str()))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
alldeps.extend(deps);
|
|
||||||
Ok(())
|
|
||||||
});
|
|
||||||
Ok(alldeps)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user