Skip to content

Commit

Permalink
feat: don't include from arrays in tree
Browse files Browse the repository at this point in the history
as the backend doesn't need these anymore,
and it reduces the result json size by factor of ~3x
  • Loading branch information
michael-go committed Apr 26, 2018
1 parent d55bc84 commit 3023d60
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 102 deletions.
8 changes: 0 additions & 8 deletions plug/pip_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def create_tree_of_packages_dependencies(dist_tree, packages_names, req_file_pat
:rtype: dict
"""
DEPENDENCIES = 'dependencies'
FROM = 'from'
VERSION = 'version'
NAME = 'name'
VERSION_SEPARATOR = '@'
Expand Down Expand Up @@ -60,8 +59,6 @@ def create_children_recursive(root_package, key_tree, ancestors):
child_package = {
NAME: child_dist.project_name,
VERSION: child_dist.installed_version,
FROM: root_package[FROM] +
[child_dist.key + VERSION_SEPARATOR + child_dist.installed_version]
}

create_children_recursive(child_package, key_tree, ancestors)
Expand All @@ -76,7 +73,6 @@ def create_dir_as_root():
NAME: name,
VERSION: DIR_VERSION,
DEPENDENCIES: {},
FROM: [name + VERSION_SEPARATOR + DIR_VERSION], DEPENDENCIES: {},
PACKAGE_FORMAT_VERSION: 'pip:0.0.1'
}
return dir_as_root
Expand All @@ -85,10 +81,6 @@ def create_package_as_root(package, dir_as_root):
package_as_root = {
NAME: package.project_name.lower(),
VERSION: package._obj._version,
FROM: ["{}{}{}".format(
dir_as_root[NAME], VERSION_SEPARATOR, dir_as_root[VERSION])] +
["{}{}{}".format(
package.project_name.lower(), VERSION_SEPARATOR, package._obj._version)]
}
return package_as_root
dir_as_root = create_dir_as_root()
Expand Down
94 changes: 0 additions & 94 deletions test/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,20 @@ test('inspect', function (t) {
t.ok(pkg, 'package');
t.equal(pkg.name, 'pip-app', 'name');
t.equal(pkg.version, '0.0.0', 'version');
// t.equal(pkg.full, '[email protected]', 'full'); // do we need this?
t.same(pkg.from, ['[email protected]'], 'from self');
t.end();
});

t.test('package dependencies', function (t) {
t.same(pkg.dependencies.django, {
name: 'django',
version: '1.6.1',
from: [
'[email protected]',
'[email protected]',
],
}, 'django looks ok');

t.match(pkg.dependencies.jinja2, {
name: 'jinja2',
version: '2.7.2',
from: [
'[email protected]',
'[email protected]',
],
dependencies: {
markupsafe: {
from: [
'[email protected]',
'[email protected]',
/markupsafe@.+$/,
],
name: 'markupsafe',
version: /.+$/,
},
Expand All @@ -75,39 +60,21 @@ test('inspect', function (t) {
t.match(pkg.dependencies['python-etcd'], {
name: 'python-etcd',
version: '0.4.5',
from: [
'[email protected]',
'[email protected]',
],
dependencies: {
dnspython: {
name: 'dnspython',
version: /.+$/,
from: [
'[email protected]',
'[email protected]',
/dnspython@.+$/,
],
},
urllib3: {
name: 'urllib3',
version: /.+$/,
from: [
'[email protected]',
'[email protected]',
/urllib3@.+$/,
],
},
},
}, 'python-etcd is ok');

t.match(pkg.dependencies['django-select2'], {
name: 'django-select2',
version: '6.0.1',
from: [
'[email protected]',
'[email protected]',
],
dependencies: {
'django-appconf': {
name: 'django-appconf',
Expand All @@ -118,10 +85,6 @@ test('inspect', function (t) {
t.match(pkg.dependencies['irc'], {
name: 'irc',
version: '16.2',
from: [
"[email protected]",
"[email protected]"
],
dependencies: {
'more-itertools': {},
'jaraco.functools': {},
Expand All @@ -141,10 +104,6 @@ test('inspect', function (t) {
t.match(pkg.dependencies['testtools'], {
name: 'testtools',
version: '2.3.0',
from: [
"[email protected]",
"[email protected]"
],
dependencies: {
'pbr': {},
'extras': {},
Expand Down Expand Up @@ -200,66 +159,39 @@ test('transitive dep not installed, but with allowMissing option', function (t)
t.equal(pkg.name, 'pip-app', 'name');
t.equal(pkg.version, '0.0.0', 'version');
// t.equal(pkg.full, '[email protected]', 'full'); // do we need this?
t.same(pkg.from, ['[email protected]'], 'from self');
t.end();
});

t.test('package dependencies', function (t) {
t.same(pkg.dependencies.django, {
name: 'django',
version: '1.6.1',
from: [
'[email protected]',
'[email protected]',
],
}, 'django looks ok');

t.match(pkg.dependencies.jinja2, {
name: 'jinja2',
version: '2.7.2',
from: [
'[email protected]',
'[email protected]',
],
dependencies: {},
}, 'jinja2 looks ok');

t.match(pkg.dependencies['python-etcd'], {
name: 'python-etcd',
version: '0.4.5',
from: [
'[email protected]',
'[email protected]',
],
dependencies: {
dnspython: {
name: 'dnspython',
version: /.+$/,
from: [
'[email protected]',
'[email protected]',
/dnspython@.+$/,
],
},
urllib3: {
name: 'urllib3',
version: /.+$/,
from: [
'[email protected]',
'[email protected]',
/urllib3@.+$/,
],
},
},
}, 'python-etcd is ok');

t.match(pkg.dependencies['django-select2'], {
name: 'django-select2',
version: '6.0.1',
from: [
'[email protected]',
'[email protected]',
],
dependencies: {
'django-appconf': {
name: 'django-appconf',
Expand Down Expand Up @@ -305,7 +237,6 @@ test('deps not installed, but with allowMissing option', function (t) {
t.ok(pkg, 'package');
t.equal(pkg.name, 'pip-app-deps-not-installed', 'name');
t.equal(pkg.version, '0.0.0', 'version');
t.same(pkg.from, ['[email protected]'], 'from self');
t.end();
});
});
Expand Down Expand Up @@ -336,18 +267,10 @@ test('package name differs from requirement', function (t) {
.then(function (result) {
var pkg = result.package;
t.same(pkg.dependencies['dj-database-url'], {
from: [
'[email protected]',
'[email protected]',
],
name: 'dj-database-url',
version: '0.4.2',
}, 'dj-database-url looks ok');
t.same(pkg.dependencies['posix-ipc'], {
from: [
'[email protected]',
'[email protected]',
],
name: 'posix-ipc',
version: '1.0.0',
}, 'posix-ipc looks ok');
Expand All @@ -368,10 +291,6 @@ test('package depends on platform', function (t) {
var pkg = result.package;
t.notOk(pkg.dependencies.pypiwin32, 'win32 dep ignored');
t.same(pkg.dependencies['posix-ipc'], {
from: [
'[email protected]',
'[email protected]',
],
name: 'posix-ipc',
version: '1.0.0',
}, 'posix-ipc looks ok');
Expand All @@ -393,10 +312,6 @@ test('editables ignored', function (t) {
t.notOk(pkg.dependencies['simple'], 'editable dep ignored');
t.notOk(pkg.dependencies['sample'], 'editable subdir dep ignored');
t.same(pkg.dependencies['posix-ipc'], {
from: [
'[email protected]',
'[email protected]',
],
name: 'posix-ipc',
version: '1.0.0',
}, 'posix-ipc looks ok');
Expand Down Expand Up @@ -429,27 +344,18 @@ test('deps withs options', function (t) {
t.ok(pkg, 'package');
t.equal(pkg.name, 'pip-app-with-options', 'name');
t.equal(pkg.version, '0.0.0', 'version');
t.same(pkg.from, ['[email protected]'], 'from self');
t.end();
});

t.test('package dependencies', function (t) {
t.match(pkg.dependencies.markupsafe, {
name: 'markupsafe',
version: '1.0',
from: [
'[email protected]',
'[email protected]',
],
}, 'MarkupSafe looks ok');

t.match(pkg.dependencies.dnspython, {
name: 'dnspython',
version: '1.13.0',
from: [
'[email protected]',
'[email protected]',
],
}, 'dnspython looks ok');

t.end();
Expand Down

0 comments on commit 3023d60

Please sign in to comment.