From 94b20eb3f5cc23c0df70a9d85b2d9313d0373002 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 13 Feb 2018 12:16:15 -0500 Subject: [PATCH] add --system support to pipenv check Signed-off-by: Kenneth Reitz --- pipenv/cli.py | 5 +++-- pipenv/core.py | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 94477626..ec055e41 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -314,12 +314,13 @@ def run(command, args, three=None, python=False): )) @click.option('--three/--two', is_flag=True, default=None, help="Use Python 3/2 when creating virtualenv.") @click.option('--python', default=False, nargs=1, help="Specify which version of Python virtualenv should use.") +@click.option('--system', is_flag=True, default=False, help="Use system Python.") @click.option('--unused', nargs=1, default=False, help="Given a code path, show potentially unused dependencies.") @click.option('--style', nargs=1, default=False, help="Given a code path, show Flake8 errors.") @click.argument('args', nargs=-1) -def check(three=None, python=False, unused=False, style=False, args=None): +def check(three=None, python=False, system=False, unused=False, style=False, args=None): from . import core - core.do_check(three=three, python=python, unused=unused, style=style, args=args) + core.do_check(three=three, python=python, system=system, unused=unused, style=style, args=args) @click.command(short_help=u"Displays currently–installed dependency graph information.") diff --git a/pipenv/core.py b/pipenv/core.py index fa9bf1a1..2dccee92 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -2027,10 +2027,11 @@ def do_run(command, args, three=None, python=False): pass -def do_check(three=None, python=False, unused=False, style=False, args=None): +def do_check(three=None, python=False, system=False, unused=False, style=False, args=None): - # Ensure that virtualenv is available. - ensure_project(three=three, python=python, validate=False, warn=False) + if not system: + # Ensure that virtualenv is available. + ensure_project(three=three, python=python, validate=False, warn=False) if not args: args = [] @@ -2099,7 +2100,12 @@ def do_check(three=None, python=False, unused=False, style=False, args=None): path = pep508checker.__file__.rstrip('cdo') path = os.sep.join(__file__.split(os.sep)[:-1] + ['patched', 'safety.zip']) - c = delegator.run('"{0}" {1} check --json'.format(which('python'), shellquote(path))) + if not system: + python = which('python') + else: + python = system_which('python') + + c = delegator.run('"{0}" {1} check --json'.format(python, shellquote(path))) try: results = simplejson.loads(c.out) except ValueError: