Skip to content

Commit

Permalink
Fix install for local sdist packages
Browse files Browse the repository at this point in the history
* Fixes pypa#817
* Packages werent being identified as local files
* Therefore they were not being given a path
* We were trying to resolve them with pypi
  • Loading branch information
techalchemy committed Oct 2, 2017
1 parent 7b2144c commit bb32f66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def _build_package_list(self, package_section):
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

Expand Down
9 changes: 8 additions & 1 deletion pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bb32f66

Please sign in to comment.