Skip to content

Commit

Permalink
fix: ignore "editables"
Browse files Browse the repository at this point in the history
Editables are local projects or VCS repositories as dependencies.
  • Loading branch information
darscan committed Aug 16, 2017
1 parent 482f75d commit 7802d53
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
4 changes: 4 additions & 0 deletions plug/pip_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ def matches_environment(requirement):
return match[0].lower() == sys_platform
return True

def is_testable(requirement):
return requirement.editable == False and requirement.vcs == None

def get_requirements_list(requirements_file):
req_list = list(requirements.parse(requirements_file))
req_list = filter(matches_environment, req_list)
req_list = filter(is_testable, req_list)
required = [req.name.replace('_', '-') for req in req_list]
return required

Expand Down
37 changes: 31 additions & 6 deletions test/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ test('uses provided exec command', function (t) {

test('package name differs from requirement', function (t) {
chdirWorkspaces('pip-app-deps-with-dashes');
return subProcess.execute('pip',
['install', '-r', 'requirements.txt', '--disable-pip-version-check']
)
return pipInstall()
.then(function () {
return plugin.inspect('.', 'requirements.txt')
.then(function (result) {
Expand Down Expand Up @@ -140,9 +138,7 @@ test('package name differs from requirement', function (t) {

test('package depends on platform', function (t) {
chdirWorkspaces('pip-app-deps-conditional');
return subProcess.execute('pip',
['install', '-r', 'requirements.txt', '--disable-pip-version-check']
)
return pipInstall()
.then(function () {
return plugin.inspect('.', 'requirements.txt')
.then(function (result) {
Expand All @@ -164,6 +160,35 @@ test('package depends on platform', function (t) {
});
});

test('editables ignored', function (t) {
chdirWorkspaces('pip-app-deps-editable');
return pipInstall()
.then(function () {
return plugin.inspect('.', 'requirements.txt')
.then(function (result) {
var pkg = result.package;
t.notOk(pkg.dependencies['django-munigeo'], 'editable dep ignored');
t.same(pkg.dependencies['posix-ipc'], {
from: [
'[email protected]',
'[email protected]',
],
name: 'posix-ipc',
version: '1.0.0',
}, 'posix-ipc looks ok');
t.end();
});
})
.catch(function (error) {
t.fail(error);
});
});

function pipInstall() {
return subProcess.execute('pip',
['install', '-r', 'requirements.txt', '--disable-pip-version-check']);
}

function chdirWorkspaces(dir) {
process.chdir(path.resolve(__dirname, 'workspaces', dir));
}
1 change: 1 addition & 0 deletions test/workspaces/pip-app-deps-editable/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src
2 changes: 2 additions & 0 deletions test/workspaces/pip-app-deps-editable/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e git+https://github.com/City-of-Helsinki/munigeo#egg=django-munigeo
posix_ipc==1.0.0

0 comments on commit 7802d53

Please sign in to comment.