From bb32f66510b313de3a508ab63064718832df8d87 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Mon, 2 Oct 2017 18:19:53 -0400 Subject: [PATCH] Fix install for local sdist packages * Fixes #817 * Packages werent being identified as local files * Therefore they were not being given a path * We were trying to resolve them with pypi --- pipenv/project.py | 4 ++-- pipenv/utils.py | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pipenv/project.py b/pipenv/project.py index 3205e0e8..f7434358 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -64,10 +64,10 @@ class Project(object): else: ps.update({k: v}) else: - if 'file' not in v and not is_vcs(v) and not is_vcs(k): + if not is_file(v) and not is_file(k) and not is_vcs(v) and not is_vcs(k): ps.update({k: v}) else: - if not is_vcs(k): + if not is_vcs(k) and not is_file(k): ps.update({k: v}) return ps diff --git a/pipenv/utils.py b/pipenv/utils.py index 8d48ff02..2047bddd 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -497,8 +497,12 @@ def convert_deps_from_pip(dep): extras = {'extras': req.extras} # File installs. - if (req.uri or (os.path.exists(req.path) if req.path else False)) and not req.vcs: + if (req.uri or (os.path.exists(req.path) if req.path else False) or + os.path.exists(req.name)) and not req.vcs: # Assign a package name to the file, last 7 of it's sha256 hex digest. + if not req.uri and not req.path: + req.path = os.path.abspath(req.name) + hashable_path = req.uri if req.uri else req.path req.name = hashlib.sha256(hashable_path.encode('utf-8')).hexdigest() req.name = req.name[len(req.name) - 7:] @@ -721,6 +725,9 @@ def is_vcs(pipfile_entry): def is_file(package): """Determine if a package name is for a File dependency.""" + if hasattr(package, 'keys'): + return any(key for key in package.keys() if key in ['file', 'path']) + if os.path.exists(str(package)): return True