diff --git a/pipenv/shells.py b/pipenv/shells.py index 17a4d871..ed2690ac 100644 --- a/pipenv/shells.py +++ b/pipenv/shells.py @@ -134,6 +134,9 @@ def _iter_python(venv): class Bash(Shell): + def _format_path(self, python): + return python.parent.as_posix() + # The usual PATH injection technique does not work with Bash. # https://github.com/berdario/pew/issues/58#issuecomment-102182346 @contextlib.contextmanager @@ -146,15 +149,25 @@ class Bash(Shell): base_rc_src = 'source "{0}"\n'.format(bashrc_path.as_posix()) rcfile.write(base_rc_src) - export_path = 'export PATH="{0}:$PATH"\n'.format( - ":".join(python.parent.as_posix() for python in _iter_python(venv)) - ) + export_path = 'export PATH="{0}:$PATH"\n'.format(":".join( + self._format_path(python) + for python in _iter_python(venv) + )) rcfile.write(export_path) rcfile.flush() self.args.extend(["--rcfile", rcfile.name]) yield +class MsysBash(Bash): + def _format_path(self, python): + s = super(MsysBash, self)._format_path(python) + if not python.drive: + return s + # Convert "C:/something" to "/c/something". + return '/{drive}{path}'.format(drive=s[0].lower(), path=s[2:]) + + class CmderEmulatedShell(Shell): def fork(self, venv, cwd, args): if cwd: @@ -194,7 +207,7 @@ SHELL_LOOKUP = collections.defaultdict( lambda: collections.defaultdict(lambda: Shell), { "bash": collections.defaultdict( - lambda: Bash, + lambda: Bash, {"msys": MsysBash}, ), "cmd": collections.defaultdict( lambda: Shell, {"cmder": CmderCommandPrompt},