From 70f10cefc45a683057d72ccbcaf6b41ff8e9bfeb Mon Sep 17 00:00:00 2001 From: Michael Gokhman Date: Thu, 11 Jan 2018 20:42:25 +0200 Subject: [PATCH] fix: better handling of case sensetivity some packags like Django-Select2 install as lowercase, and the code didn't expect that --- plug/pip_resolve.py | 5 ++++- test/inspect.test.js | 28 ++++++++++++++++++++++++ test/workspaces/pip-app/requirements.txt | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/plug/pip_resolve.py b/plug/pip_resolve.py index 5cdce2ad..12276424 100644 --- a/plug/pip_resolve.py +++ b/plug/pip_resolve.py @@ -28,8 +28,11 @@ def create_tree_of_packages_dependencies(dist_tree, packages_names, req_file_pat key_tree = dict((k.key, v) for k, v in tree.items()) def get_children(n): return key_tree.get(n.key, []) + lowercase_pkgs_names = [p.lower() for p in packages_names] packages_as_dist_obj = [ - p for p in nodes if p.key in packages_names or p.project_name in packages_names] + p for p in nodes if + p.key.lower() in lowercase_pkgs_names or + (p.project_name and p.project_name.lower()) in lowercase_pkgs_names] def create_children_recursive(root_package, key_tree): root_name = root_package[NAME].lower() diff --git a/test/inspect.test.js b/test/inspect.test.js index 012733a4..9643c4f4 100644 --- a/test/inspect.test.js +++ b/test/inspect.test.js @@ -101,6 +101,20 @@ test('inspect', function (t) { }, }, 'python-etcd is ok'); + t.match(pkg.dependencies['django-select2'], { + name: 'django-select2', + version: '6.0.1', + from: [ + 'pip-app@0.0.0', + 'django-select2@6.0.1', + ], + dependencies: { + 'django-appconf': { + name: 'django-appconf', + }, + }, + }, 'django-select2 looks ok'); + t.end(); }); @@ -199,6 +213,20 @@ test('transitive dep not installed, but with allowMissing option', function (t) }, }, 'python-etcd is ok'); + t.match(pkg.dependencies['django-select2'], { + name: 'django-select2', + version: '6.0.1', + from: [ + 'pip-app@0.0.0', + 'django-select2@6.0.1', + ], + dependencies: { + 'django-appconf': { + name: 'django-appconf', + }, + }, + }, 'django-select2 looks ok'); + t.end(); }); diff --git a/test/workspaces/pip-app/requirements.txt b/test/workspaces/pip-app/requirements.txt index ae279847..86768d71 100644 --- a/test/workspaces/pip-app/requirements.txt +++ b/test/workspaces/pip-app/requirements.txt @@ -1,4 +1,4 @@ Jinja2==2.7.2 Django==1.6.1 python-etcd==0.4.5 - +Django-Select2==6.0.1 # this version installs with lowercase so it catches a previous bug in pip_resolve.py