Repository: pypa/pipenv

Issue:
pipenv ignores PIPENV_INSTALL_TIMEOUT
### Issue description

It appears that setting PIPENV_INSTALL_TIMEOUT as an environment variable doesn't change the installation timeout used by pipenv.  I have a remote location where the internet connection is quite slow and the default of 15 minutes is not long enough.

Looking at pipenv/pipenv/environments.py I see:
 `PIPENV_INSTALL_TIMEOUT = 60 * 15`

Unlike other variables in this file, PIPENV_INSTALL_TIMEOUT doesn't look at the environment for an override.  I would have expected something like:

`PIPENV_INSTALL_TIMEOUT = os.environ.get("PIPENV_INSTALL_TIMEOUT", 60 * 15)`

### Expected result

```
PIPENV_INSTALL_TIMEOUT=$(( 60 * 20 )) pipenv lock
```

-or-

```
PIPENV_INSTALL_TIMEOUT=$(( 60 * 20 )) pipenv install
```

Shouldn't timeout until 20 minutes have passed.

### Actual result

pipenv times out after 15 minutes:

```
Creating a virtualenv for this project…
Pipfile: /opt/myproj/debian/Pipfile
Using /usr/bin/python3.6m (3.6.7) to create virtualenv…
⠼ Creating virtual environment...Using base prefix '/usr'
New python executable in /opt/myproj/debian/.venv/bin/python3.6m
Also creating executable in /opt/myproj/debian/.venv/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /usr/bin/python3.6m

✔ Successfully created virtual environment! 
Virtualenv location: /opt/myproj/debian/.venv
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/pexpect/expect.py", line 109, in expect_loop
    return self.timeout()
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/pexpect/expect.py", line 82, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0x7ff15ee07278>
searcher: searcher_re:
    0: re.compile('\n')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/cli/command.py", line 332, in lock
    pypi_mirror=state.pypi_mirror,
  File "/usr/local/lib/python3.6/dist-packages/pipenv/core.py", line 1068, in do_lock
    lockfile=lockfile
  File "/usr/local/lib/python3.6/dist-packages/pipenv/utils.py", line 649, in venv_resolve_deps
    c = resolve(cmd, sp)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/utils.py", line 517, in resolve
    result = c.expect(u"\n", timeout=environments.PIPENV_INSTALL_TIMEOUT)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/delegator.py", line 215, in expect
    self.subprocess.expect(pattern=pattern, timeout=timeout)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/pexpect/spawnbase.py", line 341, in expect
    timeout, searchwindowsize, async_)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/pexpect/spawnbase.py", line 369, in expect_list
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/pexpect/expect.py", line 119, in expect_loop
    return self.timeout(e)
  File "/usr/local/lib/python3.6/dist-packages/pipenv/vendor/pexpect/expect.py", line 82, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0x7ff15ee07278>
searcher: searcher_re:
    0: re.compile('\n')
<pexpect.popen_spawn.PopenSpawn object at 0x7ff15ee07278>
searcher: searcher_re:
    0: re.compile('\n')
```

### Steps to replicate

```
PIPENV_INSTALL_TIMEOUT=$(( 60 * 20 )) pipenv lock
```

or similar with a very slow internet connection such that the installation lasts longer than 15 minutes.

-------------------------------------------------------------------------------

 ~/src/myproj  pipenv --support                                                                                                                                                                                                               ✔  13.65 Dur  3024  09:17:34
<details><summary>$ pipenv --support</summary>

Pipenv version: `'2018.11.26'`

Pipenv location: `'/home/agelter/.local/lib/python3.6/site-packages/pipenv'`

Python location: `'/usr/bin/python3'`

Python installations found:

  - `3.6.7`: `/usr/bin/python3.6m`
  - `3.6.7`: `/usr/bin/python3`
  - `3.4.3`: `/home/agelter/.pyenv/versions/3.4.3/bin/python`
  - `3.4.3`: `/home/agelter/.pyenv/versions/3.4.3/bin/python3.4m`
  - `2.7.15rc1`: `/usr/bin/python`

PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '3.6.7',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.15.0-45-generic',
 'platform_system': 'Linux',
 'platform_version': '#48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019',
 'python_full_version': '3.6.7',
 'python_version': '3.6',
 'sys_platform': 'linux'}
```

System environment variables:

  - `DBUS_SESSION_BUS_ADDRESS`
  - `DISPLAY`
  - `HOME`
  - `LANG`
  - `LOGNAME`
  - `MAIL`
  - `OLDPWD`
  - `PATH`
  - `PWD`
  - `SHELL`
  - `SHLVL`
  - `SSH_CLIENT`
  - `SSH_CONNECTION`
  - `SSH_TTY`
  - `TERM`
  - `TMUX`
  - `TMUX_PANE`
  - `USER`
  - `XDG_RUNTIME_DIR`
  - `XDG_SESSION_ID`
  - `_`
  - `ZSH`
  - `PAGER`
  - `LESS`
  - `LC_CTYPE`
  - `LSCOLORS`
  - `LS_COLORS`
  - `PYENV_SHELL`
  - `EDITOR`
  - `OD_USER`
  - `AF_API_KEY`
  - `CCACHE_BASEDIR`
  - `CCACHE_CPP2`
  - `CCACHE_DIR`
  - `PYENV_VIRTUALENV_INIT`
  - `SCCACHE_REDIS`
  - `PIP_DISABLE_PIP_VERSION_CHECK`
  - `PYTHONDONTWRITEBYTECODE`
  - `PIP_SHIMS_BASE_MODULE`
  - `PIP_PYTHON_PATH`
  - `PYTHONFINDER_IGNORE_UNSUPPORTED`

Pipenv–specific environment variables:


Debug–specific environment variables:

  - `PATH`: `/home/agelter/.pyenv/plugins/pyenv-virtualenv/shims:/home/agelter/.pyenv/shims:/home/agelter/.pyenv/bin:/home/agelter/.local/bin:/usr/lib/ccache:/home/agelter/.pyenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/agelter/.pyenv/bin:/Applications/MacVim.app/Contents/bin/:/home/agelter/bin`
  - `SHELL`: `/bin/zsh`
  - `EDITOR`: `vim`
  - `LANG`: `en_US.UTF-8`
  - `PWD`: `/home/agelter/src/myproj`


---------------------------

</details>



Discussion:
I believe `PIPENV_INSTALL_TIMEOUT` is for installing *Python* (via pyenv), not packages. The naming is poor, but it is what it is. Also `pipenv lock` does not install anything.
@uranusjr yes, `pipenv lock` doesn't install anything, but it does download and parse setup.py files and that's what's timing out for me on a slow connection.  As you can see from the console output, it's timing out with

>     File "/usr/local/lib/python3.6/dist-packages/pipenv/utils.py", line 517, in resolve
>         result = c.expect(u"\n", timeout=environments.PIPENV_INSTALL_TIMEOUT)`

Are you sure PIPENV_INSTALL_TIMEOUT doesn't play a part in creation of the Pipfile.lock file?  If it doesn't, is there any way I can increase the timeout so that I can give `pipenv lock` more time on a slow connection?

Resolving patch:
diff --git a/pipenv/environments.py b/pipenv/environments.py
--- a/pipenv/environments.py
+++ b/pipenv/environments.py
@@ -99,7 +99,7 @@ def _is_env_truthy(name):
 and enables the user to use any user-built environments with Pipenv.
 """
 
-PIPENV_INSTALL_TIMEOUT = 60 * 15
+PIPENV_INSTALL_TIMEOUT = int(os.environ.get("PIPENV_INSTALL_TIMEOUT", 60 * 15))
 """Max number of seconds to wait for package installation.
 
 Defaults to 900 (15 minutes), a very long arbitrary time.


Test patch: