mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Use COMSPEC for shell detection fallback
The subshell logic now considers: * PIPENV_SHELL * Auto detection * SHELL (should very likely work for POSIX) * PYENV_SHELL * COMSPEC (should always work for Windows)
This commit is contained in:
@@ -207,7 +207,11 @@ if "PIPENV_ACTIVE" not in os.environ and not PIPENV_IGNORE_VIRTUALENVS:
|
||||
PIPENV_SKIP_VALIDATION = True
|
||||
|
||||
# Internal, the default shell to use if shell detection fails.
|
||||
PIPENV_SHELL = os.environ.get("SHELL") or os.environ.get("PYENV_SHELL")
|
||||
PIPENV_SHELL = (
|
||||
os.environ.get("SHELL") or
|
||||
os.environ.get("PYENV_SHELL") or
|
||||
os.environ.get("COMSPEC")
|
||||
)
|
||||
|
||||
# Internal, to tell if pyenv is installed.
|
||||
PYENV_ROOT = os.environ.get("PYENV_ROOT", os.path.expanduser("~/.pyenv"))
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ def detect_info():
|
||||
raise ShellDetectionFailure
|
||||
|
||||
|
||||
def _get_activate_script(venv):
|
||||
def _get_activate_script(cmd, venv):
|
||||
"""Returns the string to activate a virtualenv.
|
||||
|
||||
This is POSIX-only at the moment since the compat (pexpect-based) shell
|
||||
@@ -37,11 +37,11 @@ def _get_activate_script(venv):
|
||||
"""
|
||||
# Suffix and source command for other shells.
|
||||
# Support for fish shell.
|
||||
if PIPENV_SHELL and "fish" in PIPENV_SHELL:
|
||||
if "fish" in cmd:
|
||||
suffix = ".fish"
|
||||
command = "source"
|
||||
# Support for csh shell.
|
||||
elif PIPENV_SHELL and "csh" in PIPENV_SHELL:
|
||||
elif "csh" in cmd:
|
||||
suffix = ".csh"
|
||||
command = "source"
|
||||
else:
|
||||
@@ -104,7 +104,7 @@ class Shell(object):
|
||||
dims = get_terminal_size()
|
||||
with temp_environ():
|
||||
c = pexpect.spawn(self.cmd, ["-i"], dimensions=(dims.lines, dims.columns))
|
||||
c.sendline(_get_activate_script(venv))
|
||||
c.sendline(_get_activate_script(self.cmd, venv))
|
||||
if args:
|
||||
c.sendline(" ".join(args))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user