43 lines
851 B
Python
43 lines
851 B
Python
import sys
|
|
import click
|
|
|
|
def print_list(name, l):
|
|
print(f"{name}:")
|
|
for v in l: print("\t", v)
|
|
print()
|
|
|
|
def print_dict(name, d):
|
|
print(f"{name}:")
|
|
for k, v in d.items():
|
|
print(f"\t{k:10}: {v}")
|
|
print()
|
|
|
|
sys_vars = (
|
|
"path",
|
|
"meta_path",
|
|
"orig_argv",
|
|
"executable",
|
|
"version",
|
|
#"implementation",
|
|
"prefix",
|
|
"_is_gil_enabled",
|
|
)
|
|
|
|
@click.command()
|
|
def info():
|
|
"""Show info about the current python environment."""
|
|
for var in sys_vars:
|
|
name = f"sys.{var}"
|
|
value = getattr(sys, var)
|
|
if callable(value):
|
|
value = value()
|
|
name += "()"
|
|
|
|
if isinstance(value, list): print_list(name, value)
|
|
elif isinstance(value, dict): print_dict(name, value)
|
|
else: print(f"{name:25}: {value}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
info()
|