Repository: pypa/pipenv

Issue:
Cannot create virtualenv with Python 2 with master
```
$ pipenv --version
pipenv, version 2018.10.14.dev0

$ pipenv --python=2.7
Creating a virtualenv for this project…
Pipfile: C:\Users\uranusjr\Documents\playground\pipenv-venv-try\Pipfile
Using C:/Users/uranusjr/AppData/Local/Programs/Python/Python27/python.exe (2.7.14) to create virtualenv…
Complete Running... Running virtualenv with interpreter C:/Users/uranusjr/AppData/Local/Programs/Python/Python27/python.exe
New python executable in C:\Users\uranusjr\Documents\playground\pipenv-venv-try\.venv\Scripts\python.exe
Installing setuptools, pip, wheel...done.
Running virtualenv with interpreter C:/Users/uranusjr/AppData/Local/Programs/Python/Python27/python.exe
Traceback (most recent call last):
  File "C:\Users\uranusjr\.local\bin\pipenv-script.py", line 11, in <module>
    load_entry_point('pipenv', 'console_scripts', 'pipenv')()
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\vendor\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\vendor\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\vendor\click\core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\vendor\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\vendor\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\vendor\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\vendor\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\vendor\click\decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\cli\command.py", line 203, in cli
    clear=state.clear,
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\core.py", line 595, in ensure_project
    pypi_mirror=pypi_mirror,
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\core.py", line 557, in ensure_virtualenv
    pypi_mirror=pypi_mirror,
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\core.py", line 527, in ensure_virtualenv
    python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\core.py", line 938, in do_create_virtualenv
    fix_venv_site(project.env_paths["lib"])
  File "c:\users\uranusjr\documents\programming\pipenv\pipenv\project.py", line 1137, in env_paths
    _virtualenv = importlib.import_module("virtualenv")
  File "C:\Users\uranusjr\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\uranusjr\.local\venvs\pipenv\lib\site-packages\virtualenv.py", line 2209, in <module>
    maxint = majver == 3 and getattr(sys, 'maxsize') or getattr(sys, 'maxint')
AttributeError: module 'sys' has no attribute 'maxint'
```


Discussion:
I’m assuming this relates to installing virtualenv inside a venv based virtualenv. 

Resolving patch:
diff --git a/pipenv/project.py b/pipenv/project.py
--- a/pipenv/project.py
+++ b/pipenv/project.py
@@ -667,17 +667,21 @@ def lockfile_content(self):
 
     def _get_editable_packages(self, dev=False):
         section = "dev-packages" if dev else "packages"
+        # section = "{0}-editable".format(section)
         packages = {
             k: v
+            # for k, v in self._pipfile[section].items()
             for k, v in self.parsed_pipfile.get(section, {}).items()
-            if is_editable(v)
+            if is_editable(k) or is_editable(v)
         }
         return packages
 
     def _get_vcs_packages(self, dev=False):
         section = "dev-packages" if dev else "packages"
+        # section = "{0}-vcs".format(section)
         packages = {
             k: v
+            # for k, v in self._pipfile[section].items()
             for k, v in self.parsed_pipfile.get(section, {}).items()
             if is_vcs(v) or is_vcs(k)
         }
@@ -1132,42 +1136,22 @@ def env_paths(self):
         prefix = vistir.compat.Path(location)
         import importlib
         py_version = tuple([int(v) for v in self.py_version.split(".")])
+        py_version_short = ".".join([str(v) for v in py_version[:2]])
+        running_version = ".".join([str(v) for v in sys.version_info[:2]])
         try:
-            with sys_version(py_version):
-                _virtualenv = importlib.import_module("virtualenv")
-        except ImportError:
+            _virtualenv = importlib.import_module("virtualenv")
+        except (ImportError, AttributeError):
             with vistir.contextmanagers.temp_path():
-                from string import Formatter
-                formatter = Formatter()
-                import sysconfig
-                if getattr(sys, "real_prefix", None):
-                    scheme = sysconfig._get_default_scheme()
-                    sysconfig._INSTALL_SCHEMES["posix_prefix"]["purelib"]
-                    if not scheme:
-                        scheme = "posix_prefix" if not sys.platform == "win32" else "nt"
-                    is_purelib = "purelib" in sysconfig._INSTALL_SCHEMES[scheme]
-                    lib_key = "purelib" if is_purelib else "platlib"
-                    lib = sysconfig._INSTALL_SCHEMES[scheme][lib_key]
-                    fields = [field for _, field, _, _ in formatter.parse() if field]
-                    config = {
-                        "py_version_short": self._pyversion,
-                    }
-                    for field in fields:
-                        if field not in config:
-                            config[field] = prefix
-                    sys.path = [
-                        os.path.join(sysconfig._INSTALL_SCHEMES[scheme][lib_key], "site-packages"),
-                    ] + sys.path
-                    with sys_version(py_version):
-                        six.reload_module(importlib)
-                        _virtualenv = importlib.import_module("virtualenv")
+                sys.path = vistir.misc.load_path(self.which("python"))
+                six.moves.reload_module(importlib)
+                _virtualenv = importlib.import_module("virtualenv")
         with sys_version(py_version):
             home, lib, inc, bin_ = _virtualenv.path_locations(prefix.absolute().as_posix())
         paths = {
-            "lib": lib,
-            "include": inc,
+            "lib": lib.replace(running_version, py_version_short),
+            "include": inc.replace(running_version, py_version_short),
             "scripts": bin_,
-            "purelib": lib,
+            "purelib": lib.replace(running_version, py_version_short),
             "prefix": home,
             "base": home
         }


Test patch: