Skip to content

Commit

Permalink
Use bypass_when and env.Check to evaluate the environment and bypass …
Browse files Browse the repository at this point in the history
…the behavior.
  • Loading branch information
jaraco committed May 29, 2023
1 parent 8f9ccc4 commit 7688eae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions pip_run/commands.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import pathlib
import contextlib
import argparse

from more_itertools import locate, split_at
from jaraco.functools import bypass_when
from jaraco import env

from ._py38compat import files

Expand Down Expand Up @@ -75,6 +76,7 @@ def separate(args):
return _separate_script(args)


@bypass_when(env.Check('PIP_RUN_IPYTHON_MODE', default='infer', expect='ignore'))
def infer_ipython(sep_args):
"""
Check for the presence of the argument 'ipython' in pip_args.
Expand All @@ -96,9 +98,6 @@ def infer_ipython(sep_args):
>>> infer_ipython((['ipython', 'foo'], []))
(['ipython', 'foo'], ['-m', 'IPython'])
"""
if os.environ.get('PIP_RUN_IPYTHON_MODE', 'infer') == 'ignore':
return sep_args

pip_args, py_args = sep_args
use_ipython = not py_args and 'ipython' in pip_args

Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ install_requires =
jaraco.text
platformdirs
importlib_resources; python_version < "3.9"
jaraco.functools
jaraco.functools >= 3.7
jaraco.env

[options.packages.find]
exclude =
Expand Down

0 comments on commit 7688eae

Please sign in to comment.