From 6e32b6fc49b44c1018d1f18d84e54ad0f8675b7b Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sun, 1 Oct 2017 22:58:49 -0400 Subject: [PATCH 1/2] Refactor project package code and add VCS checks --- pipenv/project.py | 56 ++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/pipenv/project.py b/pipenv/project.py index 5b7c90fb..3205e0e8 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -51,6 +51,26 @@ class Project(object): return os.sep.join([self._original_dir, p]) + def _build_package_list(self, package_section): + """Returns a list of packages for pip-tools to consume.""" + ps = {} + for k, v in self.parsed_pipfile.get(package_section, {}).items(): + # Skip editable VCS deps. + if hasattr(v, 'keys'): + # When a vcs url is gven without editable it only appears as a key + if is_vcs(v) or is_vcs(k): + if 'editable' not in v: + continue + else: + ps.update({k: v}) + else: + if 'file' not in v and not is_vcs(v) and not is_vcs(k): + ps.update({k: v}) + else: + if not is_vcs(k): + ps.update({k: v}) + return ps + @property def name(self): if self._name is None: @@ -301,7 +321,7 @@ class Project(object): """Returns a list of VCS packages, for not pip-tools to consume.""" ps = {} for k, v in self.parsed_pipfile.get('packages', {}).items(): - if is_vcs(v): + if is_vcs(v) or is_vcs(k): ps.update({k: v}) return ps @@ -310,7 +330,7 @@ class Project(object): """Returns a list of VCS packages, for not pip-tools to consume.""" ps = {} for k, v in self.parsed_pipfile.get('dev-packages', {}).items(): - if is_vcs(v): + if is_vcs(v) or is_vcs(k): ps.update({k: v}) return ps @@ -324,40 +344,12 @@ class Project(object): @property def packages(self): """Returns a list of packages, for pip-tools to consume.""" - ps = {} - for k, v in self.parsed_pipfile.get('packages', {}).items(): - # Skip editable VCS deps. - if hasattr(v, 'keys'): - if is_vcs(v): - if 'editable' not in v: - continue - else: - ps.update({k: v}) - else: - if 'file' not in v: - ps.update({k: v}) - else: - ps.update({k: v}) - return ps + return self._build_package_list('packages') @property def dev_packages(self): """Returns a list of dev-packages, for pip-tools to consume.""" - ps = {} - for k, v in self.parsed_pipfile.get('dev-packages', {}).items(): - # Skip editable VCS deps. - if hasattr(v, 'keys'): - if is_vcs(v): - if 'editable' not in v: - continue - else: - ps.update({k: v}) - else: - if 'file' not in v: - ps.update({k: v}) - else: - ps.update({k: v}) - return ps + return self._build_package_list('dev-packages') def touch_pipfile(self): """Simply touches the Pipfile, for later use.""" From ec57146f42240677652e304e5460b8676f63596a Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sun, 1 Oct 2017 23:07:58 -0400 Subject: [PATCH 2/2] Add more VCS checks, fixes #806 --- pipenv/cli.py | 2 +- pipenv/utils.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index ef7527d3..d0606c6e 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -1800,7 +1800,7 @@ def install( # Warn if --editable wasn't passed. converted = convert_deps_from_pip(package_name) key = [k for k in converted.keys()][0] - if is_vcs(converted[key]) and not converted[key].get('editable'): + if is_vcs(key) or is_vcs(converted[key]) and not converted[key].get('editable'): click.echo( '{0}: You installed a VCS dependency in non–editable mode. ' 'This will work fine, but sub-depdendencies will not be resolved by {1}.' diff --git a/pipenv/utils.py b/pipenv/utils.py index e7339c14..8d48ff02 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -714,6 +714,8 @@ def is_vcs(pipfile_entry): if hasattr(pipfile_entry, 'keys'): return any(key for key in pipfile_entry.keys() if key in VCS_LIST) + elif isinstance(pipfile_entry, six.string_types): + return pipfile_entry.startswith(VCS_LIST) return False