Repository: pypa/pipenv

Issue:
Pipenv does not support installing from local source packages
I created a virtualenv with pipenv, and installed some required packages from PyPI with it, which works well. However, I also have in my project a Python source distribution tarball (created by running `python setup.py sdist` in another project), that I'd like to install in the virtualenv. When running `pipenv install mytarball.tar.gz`, the source tarball is successfully installed in the virtualenv, but then I get an error at the end of the process:

```
Adding tarball-1.5.2.tar.gz to Pipfile's [packages]…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Traceback (most recent call last):
  File "/Users/christianhudon/miniconda3/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/cli.py", line 1852, in install
    do_lock(system=system, pre=pre)
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/cli.py", line 1083, in do_lock
    pre=pre
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/utils.py", line 421, in resolve_deps
    resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 88, in resolve
    self.their_constraints))
  File "/Users/christianhudon/miniconda3/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 125, in check_constraints
    raise UnsupportedConstraint(msg, constraint)
piptools.exceptions.UnsupportedConstraint: pip-compile does not support URLs as packages, unless they are editable. Perhaps add -e option? (constraint was: file:///Users/christianhudon/test/tarball-1.5.2.tar.gz (from -r /var/folders/t0/_kvmbqhs4n92fg18mvdyd12w0000gq/T/pipenv-9i1ndzrb-requirement.txt (line 1)))
```


Discussion:
I think this is related to #806 and can be fixed with a similar approach to #807 

Resolving patch:
diff --git a/pipenv/project.py b/pipenv/project.py
--- a/pipenv/project.py
+++ b/pipenv/project.py
@@ -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
 
diff --git a/pipenv/utils.py b/pipenv/utils.py
--- 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
 


Test patch: