Skip to content

Commit

Permalink
Merge 4cea621 into 0982b0c
Browse files Browse the repository at this point in the history
  • Loading branch information
lorencarvalho committed Dec 21, 2018
2 parents 0982b0c + 4cea621 commit 4f61072
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def readme():
entry_points={
'console_scripts': [
'shiv = shiv.cli:main',
'shiv-info = shiv.info:main',
],
},
include_package_data=True,
Expand Down
4 changes: 4 additions & 0 deletions src/shiv/bootstrap/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ class Environment:

def __init__(
self,
built_at,
shiv_version,
build_id=None,
entry_point=None,
always_write_cache=False,
compile_pyc=True,
extend_pythonpath=False,
):
self.shiv_version = shiv_version
self.built_at = built_at
self.build_id = build_id
self.always_write_cache = always_write_cache

Expand Down
3 changes: 3 additions & 0 deletions src/shiv/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import importlib_resources # type: ignore

from configparser import ConfigParser
from datetime import datetime
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Optional, List, no_type_check
Expand Down Expand Up @@ -176,10 +177,12 @@ def main(

# create runtime environment metadata
env = Environment(
built_at=str(datetime.now()),
build_id=str(uuid.uuid4()),
entry_point=entry_point,
compile_pyc=compile_pyc,
extend_pythonpath=extend_pythonpath,
shiv_version=__version__,
)

Path(working_path, "environment.json").write_text(env.to_json())
Expand Down
28 changes: 28 additions & 0 deletions src/shiv/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import click
import json
import zipfile


@click.command(context_settings=dict(help_option_names=["-h", "--help", "--halp"]))
@click.option("--json", "-j", "json_", is_flag=True, help="output as plain json")
@click.argument("pyz")
def main(json_, pyz):
"""A simple utility to print debugging information about PYZ files created with ``shiv``"""

zip_file = zipfile.ZipFile(pyz)
data = json.loads(zip_file.read("environment.json"))

if json_:
click.echo(json.dumps(data, indent=4, sort_keys=True))

else:
click.echo()
click.secho(f"pyz file: ", fg="green", bold=True, nl=False)
click.secho(pyz, fg="white")
click.echo()

for key, value in data.items():
click.secho(f"{key}: ", fg="blue", bold=True, nl=False)
click.secho(f"{value}", fg="white")

click.echo()

0 comments on commit 4f61072

Please sign in to comment.