From 4d713e7ffe2fb312a46d0ab2abcb167187bbbf51 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Wed, 21 Nov 2018 18:32:23 -0500 Subject: [PATCH] Fix bug in lockfile generation Signed-off-by: Dan Ryan --- pipenv/project.py | 9 +++++---- pipenv/utils.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pipenv/project.py b/pipenv/project.py index 26ec696c..142c5862 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -785,10 +785,11 @@ class Project(object): def get_lockfile_meta(self): from .vendor.plette.lockfiles import PIPFILE_SPEC_CURRENT - sources = self.lockfile_content.get("_meta", {}).get("sources", []) - if not sources: - sources = self.pipfile_sources - elif not isinstance(sources, list): + if self.lockfile_exists: + sources = self.lockfile_content.get("_meta", {}).get("sources", []) + else: + sources = [dict(source) for source in self.parsed_pipfile["source"]] + if not isinstance(sources, list): sources = [sources,] return { "hash": {"sha256": self.calculate_pipfile_hash()}, diff --git a/pipenv/utils.py b/pipenv/utils.py index e1ed77b3..0fbbc539 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -320,7 +320,7 @@ class Resolver(object): if self.sources: requirementstxt_sources = " ".join(self.pip_args) if self.pip_args else "" requirementstxt_sources = requirementstxt_sources.replace(" --", "\n--") - constraints_file.write(u"{0}\n".format(requirementstxt_sources)) + constraints_file.write(u"{0}\n".format(requirementstxt_sources)) constraints = self.initial_constraints constraints_file.write(u"\n".join([c for c in constraints])) constraints_file.close() @@ -855,7 +855,7 @@ def mkdir_p(newdir): if exn.errno != errno.EEXIST: raise - + def is_required_version(version, specified_version): """Check to see if there's a hard requirement for version number provided in the Pipfile.