Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added programmatic pip list #864

Open
wants to merge 16 commits into
base: new-apis_v0.1.0-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions GANDLF/entrypoints/debug_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!usr/bin/env python
# -*- coding: utf-8 -*-
import platform
from pip import main
from deprecated import deprecated
import click

Expand All @@ -9,7 +10,7 @@
from GANDLF.utils import get_git_hash


def _debug_info():
def _debug_info(verbose: bool):
print(f"GANDLF version: {__version__}")
print(f"Git hash: {get_git_hash()}")
print(f"Platform: {platform.platform()}")
Expand All @@ -21,13 +22,22 @@ def _debug_info():
print(f" Implementation: {platform.python_implementation()}")
print(f" Compiler: {platform.python_compiler()}")
print(f" Build: {(' ').join(list(platform.python_build()))}")
if verbose:
print(" Installed packages:")
print(main(["list"]))


@click.command()
@click.option(
"--verbose",
"-v",
is_flag=True,
help="If passed, prints all packages installed as well",
)
@append_copyright_to_help
def new_way():
def new_way(verbose: bool):
"""Displays detailed info about system environment: library versions, settings, etc."""
_debug_info()
_debug_info(verbose=verbose)


# main function
Expand Down
5 changes: 4 additions & 1 deletion testing/entrypoints/test_debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
test_file_system = []
test_cases = [
CliCase(
should_succeed=True, new_way_lines=[""], old_way_lines=[""], expected_args={}
should_succeed=True,
new_way_lines=[""],
old_way_lines=[""],
expected_args={"verbose": True},
)
]

Expand Down