From 19133bee6a928a58f09afcc44fa14f4d0bd4d637 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Fri, 23 Dec 2022 20:36:25 +0300 Subject: [PATCH 1/4] Update shell.py fix zsh: poetry shell doesn't work if space character in .venv path https://github.com/python-poetry/poetry/issues/7244 --- src/poetry/utils/shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index d5b23288540..cf92e9abc6f 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -106,7 +106,7 @@ def activate(self, env: VirtualEnv) -> int | None: c.setecho(False) if self._name == "zsh": # Under ZSH the source command should be invoked in zsh's bash emulator - c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'") + c.sendline(f'''emulate bash -c ". {shlex.quote(str(activate_path))}"''') else: c.sendline( f"{self._get_source_command()} {shlex.quote(str(activate_path))}" From 35aa9b6256cc7329c35f351d0a54d5acf9669978 Mon Sep 17 00:00:00 2001 From: Dmitry Cherkashin Date: Wed, 1 Feb 2023 00:00:58 +0400 Subject: [PATCH 2/4] Fix shell.py (python-poetry#7245) --- src/poetry/utils/shell.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index cf92e9abc6f..94a1f2087cd 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -106,7 +106,10 @@ def activate(self, env: VirtualEnv) -> int | None: c.setecho(False) if self._name == "zsh": # Under ZSH the source command should be invoked in zsh's bash emulator - c.sendline(f'''emulate bash -c ". {shlex.quote(str(activate_path))}"''') + quoted_activate_path = shlex.quote(str(activate_path)) + c.sendline( + f"emulate bash -c {shlex.quote(f'. {quoted_activate_path}')}" + ) else: c.sendline( f"{self._get_source_command()} {shlex.quote(str(activate_path))}" From 607d7ed0f79f237d4c86d6a4b4bb76128ebf98be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sat, 20 Jan 2024 13:15:23 +0100 Subject: [PATCH 3/4] Fix merge mistake --- src/poetry/utils/shell.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index fe3e520a55d..b24a0b6eebc 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -123,9 +123,9 @@ def activate(self, env: VirtualEnv) -> int | None: if self._name == "zsh": # Under ZSH the source command should be invoked in zsh's bash emulator quoted_activate_path = shlex.quote(str(activate_path)) - c.sendline( - f"emulate bash -c {shlex.quote(f'. {quoted_activate_path}')}" - ) + c.sendline( + f"emulate bash -c {shlex.quote(f'. {quoted_activate_path}')}" + ) elif self._name == "xonsh": c.sendline(f"vox activate {shlex.quote(str(env.path))}") elif self._name in ["nu", "fish"]: From 315a103ad76cd330fc03b92e24b8647d2d306eff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 20 Jan 2024 12:16:11 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/poetry/utils/shell.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index b24a0b6eebc..8f720962cdb 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -123,9 +123,7 @@ def activate(self, env: VirtualEnv) -> int | None: if self._name == "zsh": # Under ZSH the source command should be invoked in zsh's bash emulator quoted_activate_path = shlex.quote(str(activate_path)) - c.sendline( - f"emulate bash -c {shlex.quote(f'. {quoted_activate_path}')}" - ) + c.sendline(f"emulate bash -c {shlex.quote(f'. {quoted_activate_path}')}") elif self._name == "xonsh": c.sendline(f"vox activate {shlex.quote(str(env.path))}") elif self._name in ["nu", "fish"]: