Skip to content

Commit

Permalink
Merge pull request #165 from snyk/fix/repeating-dependency
Browse files Browse the repository at this point in the history
fix: fix 'key psutil not found in packageToDepTreeMap' error
  • Loading branch information
admons authored Sep 9, 2021
2 parents d4f6396 + d5d8433 commit 7033b60
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pysrc/pip_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def create_children_recursive(root_package, key_tree, ancestors, all_packages_ma
if DEPENDENCIES not in root_package:
root_package[DEPENDENCIES] = {}

if child_project_name in all_packages_map:
if child_project_name in all_packages_map and child_project_name not in root_package[DEPENDENCIES]:
root_package[DEPENDENCIES][child_project_name] = 'true'
continue

Expand Down
23 changes: 23 additions & 0 deletions test/system/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,29 @@ test('package installed conditionally based on python version', (t) => {
});
});

test('should return correct package info when a single package has a dependency more than once', (t) => {
return Promise.resolve()
.then(() => {
chdirWorkspaces('pip-app-with-repeating-dependency');
const venvCreated = testUtils.ensureVirtualenv(
'pip-app-with-repeating-dependency'
);
t.teardown(
testUtils.activateVirtualenv('pip-app-with-repeating-dependency')
);
if (venvCreated) {
testUtils.pipInstall();
}
})
.then(() => {
return plugin.inspect('.', 'requirements.txt');
})
.then(async (result) => {
t.ok(result.dependencyGraph, 'graph generated');
t.end();
});
});

test('Pipfile package found conditionally based on python version', (t) => {
return Promise.resolve()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# the gevent package has 'psutil' twice as a dependency (probably with different requirements)
gevent==21.1.2

0 comments on commit 7033b60

Please sign in to comment.