Coverage for external_dependencies/cli.py: 61%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-02 11:23 +0200

1from typing import Annotated, Optional 

2 

3import typer 

4 

5from .utils import _filter_external_dependencies, _install_apt, _install_s3, _list_external_dependencies 

6 

7app = typer.Typer(rich_markup_mode='rich') 

8 

9DEFAULT_BUCKET = 'skcr-public-static-build' 

10DEFAUT_INSTALL_DIR = '/usr/local/bin/' 

11 

12 

13@app.command(name='apt') 

14def install_using_apt( 

15 prefix: Annotated[Optional[str], typer.Option(help='Filter out some external dependencies')] = 'pkg:generic/', 

16) -> None: 

17 """Install the required external dependencies using apt.""" 

18 deps = _list_external_dependencies() 

19 filtered = _filter_external_dependencies(deps, prefix) 

20 _install_apt(filtered) 

21 

22 

23@app.command(name='s3') 

24def install_using_s3( 

25 prefix: Annotated[Optional[str], typer.Option(help='Filter out some external dependencies')] = 'pkg:generic/', 

26 bucket: Annotated[str, typer.Option(help='The s3 bucket to download the dependencies from')] = DEFAULT_BUCKET, 

27 install_dir: Annotated[str, typer.Option(help='The directory to install the dependencies to')] = DEFAUT_INSTALL_DIR, 

28) -> None: 

29 """Install the required external dependencies using static builds from an s3 bucket.""" 

30 deps = _list_external_dependencies() 

31 filtered = _filter_external_dependencies(deps, prefix) 

32 _install_s3(filtered, bucket, install_dir) 

33 

34 

35if __name__ == '__main__': 

36 app()