From f57d1753868d4fa8eb5c94a8d68eebdd13fddc9e Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Tue, 30 May 2017 13:41:13 -0600 Subject: [PATCH] simplify installation separation for regular vs vcs dependencies We previously divided our dependencies into two separate lists. This was to allow us to require hashes for pypi packages, but ignore them for VCS dependencies since they won't exist. Now that we're installing one package at a time, we can bundle dependencies back together earlier and reduce the code duplication. --- pipenv/cli.py | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 60c2db18..a06dec03 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -249,20 +249,19 @@ def do_install_dependencies(dev=False, only=False, bare=False, requirements=Fals del v['hash'] # Convert the deps to pip-compatible arguments. - hashed_deps = convert_deps_to_pip(deps, r=False) - vcs_deps_path = convert_deps_to_pip(vcs_deps) + deps_list = [(d, ignore_hashes) for d in convert_deps_to_pip(deps, r=False)] + if len(vcs_deps): + deps_list.extend((d, True) for d in convert_deps_to_pip(vcs_deps, r=False)) # --requirements was passed. if requirements: - click.echo('\n'.join(hashed_deps)) - with open(vcs_deps_path) as f: - click.echo(f.read()) + click.echo('\n'.join(deps_list)) sys.exit(0) # pip install: - for dep in progress.bar(hashed_deps): + for dep, ignore_hash in progress.bar(deps_list): - c = pip_install(dep, ignore_hashes=ignore_hashes, allow_global=allow_global) + c = pip_install(dep, ignore_hashes=ignore_hash, allow_global=allow_global) if c.return_code != 0: click.echo(crayons.red('An error occured while installing!')) @@ -271,25 +270,9 @@ def do_install_dependencies(dev=False, only=False, bare=False, requirements=Fals click.echo(crayons.blue(format_pip_error(c.err))) if 'PACKAGES DO NOT MATCH THE HASHES' in c.err: click.echo(crayons.yellow('You can supply the --ignore-hashes option to ' - '\'pipenv install\' to bypass this feature.')) + '\'pipenv install\' to bypass this feature.')) sys.exit(c.return_code) - if len(vcs_deps): - with spinner(): - c = pip_install(r=vcs_deps_path, ignore_hashes=True, allow_global=allow_global) - - if c.return_code != 0: - click.echo(crayons.red('An error occured while installing!')) - click.echo(crayons.blue(format_pip_error(c.err))) - if 'PACKAGES DO NOT MATCH THE HASHES' in c.err: - click.echo(crayons.yellow('You can supply the --ignore-hashes option to ' - '\'pipenv install\' to bypass this feature.')) - sys.exit(c.return_code) - - # Cleanup the temp requirements file. - if requirements: - os.remove(vcs_deps_path) - def do_download_dependencies(dev=False, only=False, bare=False): """"Executes the download functionality."""