Skip to content

Commit

Permalink
fix: fix 'key psutil not found in packageToDepTreeMap' error
Browse files Browse the repository at this point in the history
In #159 we introduced a change to use dep graph instead of dep tree
In specific scenarios, we see a direct dependency more than once for a specific package.
This change will make sure we're setting it correctly
  • Loading branch information
admons committed Sep 9, 2021
1 parent d4f6396 commit fe799f9
Show file tree
Hide file tree
Showing 3 changed files with 21 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
18 changes: 18 additions & 0 deletions test/system/inspect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SpawnSyncReturns } from 'child_process';
import * as depGraphLib from '@snyk/dep-graph';
import * as fs from 'fs';
import * as path from 'path';
import * as testUtils from '../test-utils';

// TODO: jestify tap tests in ./inspect.test.js here
describe('inspect', () => {
Expand Down Expand Up @@ -199,4 +200,21 @@ describe('inspect', () => {
});
});
});

it('should return correct package info when a single package has a dependency more than once', async () => {
let revertActivateVirtualenv;
try {
const dir = 'pip-app-with-repeating-dependency';
chdirWorkspaces(dir);
const venvCreated = testUtils.ensureVirtualenv(dir);
revertActivateVirtualenv = testUtils.activateVirtualenv(dir);
if (venvCreated) {
testUtils.pipInstall();
}
const result = await inspect('.', 'requirements.txt');
expect(result.dependencyGraph).toBeTruthy();
} finally {
revertActivateVirtualenv && revertActivateVirtualenv();
}
});
});
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 fe799f9

Please sign in to comment.