Skip to content

Commit 7b6b9b2

Browse files
committed
Use pipes directly, no pexpect on Windows
1 parent 1cb0cc5 commit 7b6b9b2

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

conda_spawn/shell.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,34 @@ def executable(self):
169169
return "shell"
170170

171171
def args(self):
172-
return ()
172+
return ("--interact", "--norc")
173+
174+
def spawn_popen(
175+
self, command: Iterable[str] | None = None, **kwargs
176+
) -> subprocess.Popen:
177+
try:
178+
with NamedTemporaryFile(
179+
prefix="conda-spawn-",
180+
suffix=self.Activator.script_extension,
181+
delete=False,
182+
mode="w",
183+
) as f:
184+
f.write(self.script())
185+
#f.write(f"{self.script()}\r\n")
186+
#f.write(f"{self.prompt()}\r\n")
187+
#if command:
188+
# f.write(f"echo {command}\r\n")
189+
# f.write(f"{command}\r\n")
190+
return subprocess.Popen(
191+
[self.executable(), *self.args(), f.name], env=self.env(), **kwargs
192+
)
193+
finally:
194+
self._files_to_remove.append(f.name)
195+
196+
def spawn(self, command: Iterable[str] | None = None) -> int:
197+
proc = self.spawn_popen(command)
198+
proc.communicate()
199+
return proc.wait()
173200

174201

175202
class CshShell(Shell):

0 commit comments

Comments
 (0)