Repository: pypa/pipenv

Issue:
ModuleNotFoundError: No module named 'XXXXX'.  version 2018.6.25
After updating to version: 2018.6.25. I get the error as shown in the image attached. `facematic` is the package name in setup.py. I get the error while running the command `pipenv install -e .`

![screen shot 2018-06-26 at 02 56 04](https://user-images.githubusercontent.com/5145715/41904689-e3225cde-78ed-11e8-8eb4-ea6160f0b0d0.png)
##### Steps to replicate
1. Get a python package
2. Run `pipenv install -e .`



Discussion:
On a different package. This time I used the command `pipenv install --dev`

![screen shot 2018-06-26 at 03 10 01](https://user-images.githubusercontent.com/5145715/41904923-83def98e-78ee-11e8-9fd3-60e6bd869387.png)
I've had the same error after upgrading to v2018.6.25.
Could you share your `setup.py`?
Hi @ikosenn, thanks for using pipenv!  In addition to the setup.py can we see the directory structure? 
I'm having the exact same issue:

```python
ModuleNotFoundError: No module named 'versioneer'
```

See https://gist.github.com/seglberg/97c47832d2997d47b345c189fbb1aad4
@seglberg is your repo public and something I could pull down for testing?  I can't seem to replicate the issue.
No, it is private. I can create a sample repository that reproduces the error. Hang tight.
I would first point out it is against best practice to import your library in its `setup.py`. It creates a chicken-egg problem—Usually the user cannot import dependencies before your package is installed, but without running `setup.py` pip cannot resolve dependencies for the user.

I would recommend adopting on of the top solutions mentioned in the [Python Packaging User Guide](https://packaging.python.org/guides/single-sourcing-package-version/).
See https://github.com/seglberg/pipenv-repro
`pipenv install` fails inside the python directory

We are not importing any of the package's modules inside setup, we import a top-level, standalone module which generates our version information. My initial thought is that its a python path issue.
Ah, I see, sorry for the misunderstanding. Indeed this seems to be a path issue. Also we should probably be more resilient when reading the package name.
If I modify my setup.py, it works:

```python
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.append(HERE)
import versioneer
```

So definitely a path issue.
Thanks for the reports all, fix will be out shortly

Resolving patch:
diff --git a/pipenv/vendor/requirementslib/__init__.py b/pipenv/vendor/requirementslib/__init__.py
--- a/pipenv/vendor/requirementslib/__init__.py
+++ b/pipenv/vendor/requirementslib/__init__.py
@@ -1,5 +1,5 @@
 # -*- coding=utf-8 -*-
-__version__ = "1.0.6"
+__version__ = "1.0.7"
 
 
 from .exceptions import RequirementError
diff --git a/pipenv/vendor/requirementslib/models/requirements.py b/pipenv/vendor/requirementslib/models/requirements.py
--- a/pipenv/vendor/requirementslib/models/requirements.py
+++ b/pipenv/vendor/requirementslib/models/requirements.py
@@ -236,12 +236,14 @@ def get_name(self):
         ):
             from distutils.core import run_setup
 
+            old_curdir = os.path.abspath(os.getcwd())
             try:
+                os.chdir(str(self.setup_path.parent))
                 dist = run_setup(self.setup_path.as_posix(), stop_after="init")
                 name = dist.get_name()
             except (FileNotFoundError, IOError) as e:
                 dist = None
-            except (NameError, RuntimeError) as e:
+            except Exception as e:
                 from .._compat import InstallRequirement, make_abstract_dist
 
                 try:
@@ -257,6 +259,8 @@ def get_name(self):
                     name = dist.project_name
                 except (TypeError, ValueError, AttributeError) as e:
                     dist = None
+            finally:
+                os.chdir(old_curdir)
         hashed_loc = hashlib.sha256(loc.encode("utf-8")).hexdigest()
         hashed_name = hashed_loc[-7:]
         if not name or name == "UNKNOWN":


Test patch:
diff --git a/tests/integration/test_install_uri.py b/tests/integration/test_install_uri.py
--- a/tests/integration/test_install_uri.py
+++ b/tests/integration/test_install_uri.py
@@ -182,8 +182,8 @@ def test_install_local_vcs_not_in_lockfile(PipenvInstance, pip_src_dir):
         # This is the hash of ./six
         assert six_key in p.pipfile['packages']
         assert six_key in p.lockfile['default']
-        # Make sure we didn't put six in the lockfile by accident as a vcs ref
-        assert 'six' not in p.lockfile['default']
+        # The hash isn't a hash anymore, its actually the name of the package (we now resolve this)
+        assert 'six' in p.pipfile['packages']
 
 
 @pytest.mark.vcs