Install optional non-open-source Ocean packages.
(list_all, install_all, update_all, accept_license, verbose, packages)
| 805 | help='Increase output verbosity (additive, up to 4 times)') |
| 806 | @click.argument('packages', nargs=-1) |
| 807 | def install(list_all, install_all, update_all, accept_license, verbose, packages): |
| 808 | """Install optional non-open-source Ocean packages.""" |
| 809 | |
| 810 | contrib = get_contrib_packages() |
| 811 | |
| 812 | if list_all: |
| 813 | if verbose: |
| 814 | # ~YAML output |
| 815 | for pkg, specs in contrib.items(): |
| 816 | click.echo("Package: {}".format(pkg)) |
| 817 | click.echo(" Title: {}".format(specs['title'])) |
| 818 | click.echo(" Description: {}".format(specs['description'])) |
| 819 | click.echo(" License: {}".format(specs['license']['name'])) |
| 820 | click.echo(" License-URL: {}".format(specs['license']['url'])) |
| 821 | click.echo(" Requires: {}".format(', '.join(specs['requirements']))) |
| 822 | click.echo() |
| 823 | else: |
| 824 | # concise list of available packages |
| 825 | if contrib: |
| 826 | click.echo("Available packages: {}.".format(', '.join(contrib.keys()))) |
| 827 | else: |
| 828 | click.echo("No available packages.") |
| 829 | return |
| 830 | |
| 831 | if install_all: |
| 832 | packages = list(contrib) |
| 833 | |
| 834 | if update_all: |
| 835 | packages = list(filter(_contrib_package_maybe_installed, contrib)) |
| 836 | |
| 837 | if not packages: |
| 838 | click.echo('Nothing to do. Try "dwave install --help".') |
| 839 | return |
| 840 | |
| 841 | # check all packages requested are registered/available |
| 842 | for pkg in packages: |
| 843 | if pkg not in contrib: |
| 844 | click.echo("Package {!r} not found.".format(pkg)) |
| 845 | return 1 |
| 846 | |
| 847 | for pkg in packages: |
| 848 | _install_contrib_package(pkg, verbose=verbose, prompt=not accept_license) |
| 849 | |
| 850 | |
| 851 | def _contrib_package_maybe_installed(name: str) -> bool: |
nothing calls this directly
no test coverage detected