Skip to content

Commit

Permalink
Merge #241
Browse files Browse the repository at this point in the history
241: Add a `dependencies` command, which dumps the list of dependencies r=duckinator a=nbraud

This is useful for automating things like installing only a project's
dependencies.  The specific usecase I just ran into, was generating container
images for CI with all dependencies preinstalled.

Obviously, this doesn't work well with pipelines that trigger actions if a file
changed in the source repo, but it's still much better than nothing.

Co-authored-by: nicoo <nicoo@mur.at>
  • Loading branch information
bors[bot] and nbraud authored Jan 6, 2021
2 parents 8a82d32 + 3cc8bf2 commit 41c4c12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bork/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import subprocess
import sys

import pep517 # type:ignore
import toml

from . import builder
Expand Down Expand Up @@ -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.')
Expand Down
8 changes: 8 additions & 0 deletions bork/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ python_requires = >=3.6
install_requires =
wheel==0.36.2
build==0.1.0
pep517==0.9.1
packaging==20.8
toml==0.10.2
twine==3.3.0
Expand Down

0 comments on commit 41c4c12

Please sign in to comment.