From 4d38c8229d8c8aaa1b53512853fd8d17a609d818 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 20 Jan 2017 14:38:10 -0500 Subject: [PATCH] py command --- pipenv.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pipenv.py b/pipenv.py index 6a942594..e22f9703 100644 --- a/pipenv.py +++ b/pipenv.py @@ -3,11 +3,11 @@ import json import os import sys - -import toml -import delegator import click import crayons +import delegator +import pexpect +import toml import _pipfile as pipfile __version__ = '0.0.0' @@ -118,8 +118,6 @@ def multi_split(s, split): return [i for i in s.split('|') if len(i) > 0] - - def convert_deps_from_pip(dep): dependency = {} @@ -177,10 +175,6 @@ def convert_deps_to_pip(deps): - - - - def do_where(virtualenv=False, bare=True): if not virtualenv: location = project.pipfile_location() @@ -215,6 +209,9 @@ def cli(*args, **kwargs): def which_pip(): return os.sep.join([project.virtualenv_location()] + ['bin/pip']) +def which_python(): + return os.sep.join([project.virtualenv_location()] + ['bin/python']) + @click.command() @click.option('--dev', is_flag=True, default=False) def prepare(dev=False): @@ -314,6 +311,12 @@ def freeze(): c = delegator.run('{} freeze'.format(which_pip())) click.echo(crayons.blue(c.out)) +@click.command() +@click.argument('args', nargs=-1) +def py(args): + # Spawn the Python process, and iteract with it. + c = pexpect.spawn('{} {}'.format(which_python(), ' '.join(args))) + c.interact() @@ -323,6 +326,7 @@ cli.add_command(where) cli.add_command(install) cli.add_command(uninstall) cli.add_command(freeze) +cli.add_command(py) if __name__ == '__main__':