From f0596c5928746d45984ee50dbc527d591803e9b1 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 6 Feb 2020 15:03:29 +0530 Subject: [PATCH] feat: bench pip * Directly install/update/remove packages from your env using bench pip commands. Pretty much just like using pip To check help don't add the --help flag, use the -h flag instead, use the pip help command. For example, checking help for pip install can be done by bench pip help install bench pip install -h --- bench/commands/__init__.py | 3 ++- bench/commands/make.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bench/commands/__init__.py b/bench/commands/__init__.py index 4572a42b..65757f6a 100755 --- a/bench/commands/__init__.py +++ b/bench/commands/__init__.py @@ -31,11 +31,12 @@ def bench_command(bench_path='.'): setup_logging(bench_path=bench_path) -from bench.commands.make import init, get_app, new_app, remove_app +from bench.commands.make import init, get_app, new_app, remove_app, pip bench_command.add_command(init) bench_command.add_command(get_app) bench_command.add_command(new_app) bench_command.add_command(remove_app) +bench_command.add_command(pip) from bench.commands.update import update, retry_upgrade, switch_to_branch, switch_to_master, switch_to_develop diff --git a/bench/commands/make.py b/bench/commands/make.py index a3bbd2e4..b9b01b3e 100755 --- a/bench/commands/make.py +++ b/bench/commands/make.py @@ -93,3 +93,14 @@ def include_app_for_update(app_name): "Include app from updating" from bench.app import remove_from_excluded_apps_txt remove_from_excluded_apps_txt(app_name) + + +@click.command('pip', context_settings={"ignore_unknown_options": True}, help="For pip help use `bench pip help [COMMAND]` or `bench pip [COMMAND] -h`") +@click.argument('args', nargs=-1) +@click.pass_context +def pip(ctx, args): + "Run pip commands in bench env" + import os + from bench.utils import get_env_cmd + env_pip = get_env_cmd('pip') + os.execv(env_pip, (env_pip,) + args)