Files
pipenv/pipenv/shells.py
T
Tzu-ping Chung adcb4974ee Upgrade Click and make use of shell detection
This introduces an additional environment variable "PIPENV_SHELL". If
set, shell detection is skipped completely. The old "SHELL"
introspection is kept as a fallback if detection fails.
2018-06-15 17:40:40 +08:00

24 lines
584 B
Python

import os
from .environments import PIPENV_SHELL_EXPLICIT, PIPENV_SHELL
from .vendor import shellingham
class ShellDetectionFailure(shellingham.ShellDetectionFailure):
pass
def _build_info(value):
return (os.path.splitext(os.path.basename(value))[0], value)
def detect_info():
if PIPENV_SHELL_EXPLICIT:
return _build_info(PIPENV_SHELL_EXPLICIT)
try:
return shellingham.detect_shell()
except (shellingham.ShellDetectionFailure, TypeError):
if PIPENV_SHELL:
return _build_info(PIPENV_SHELL)
raise ShellDetectionFailure