From 6927fdcf07f877032fee7670e7ace4943a330027 Mon Sep 17 00:00:00 2001 From: nicoo Date: Wed, 6 Jan 2021 13:08:30 +0100 Subject: [PATCH] Add a `dependencies` command, which dumps the list of dependencies This is useful for automating things like installing only a project's dependencies, in CI. --- bork/api.py | 6 ++++++ bork/cli.py | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/bork/api.py b/bork/api.py index 2a28da1..914daaf 100644 --- a/bork/api.py +++ b/bork/api.py @@ -4,6 +4,7 @@ import subprocess import sys +import pep517 # type:ignore import toml from . import builder @@ -40,6 +41,11 @@ def clean(): try_delete(name) +def dependencies(): + """Get the list of dependencies.""" + return pep517.meta.load('.').metadata.get_all('Requires-Dist') + + def download(package, release_tag, file_pattern, directory): if file_pattern is None or len(file_pattern) == 0: raise ValueError('file_pattern must be non-empty.') diff --git a/bork/cli.py b/bork/cli.py index 3b18313..c6c6698 100644 --- a/bork/cli.py +++ b/bork/cli.py @@ -40,6 +40,14 @@ def clean(): api.clean() +@cli.command() +@click.option('-o', '--output', type=click.File('w'), default='-', + help='File in which to save the list of dependencies.') +def dependencies(output): + for dep in api.dependencies(): + print(dep, file=output) + + @cli.command() @click.option('--files', default='*.pyz', help='Comma-separated list of filenames to download. Supports '