Skip to content

Commit

Permalink
Fix generic environments command execution
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Sep 7, 2021
1 parent 7ca2060 commit b20808d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion poetry/console/commands/env/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _display_complete_info(self, env: "Env") -> None:

self.line("")

system_env = GenericEnv(env.base)
system_env = env.parent_env
self.line("<b>System</b>")
self.line(
"\n".join(
Expand Down
17 changes: 16 additions & 1 deletion poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def remove(self, python: str) -> "Env":

self.remove_venv(venv)

return VirtualEnv(venv)
return VirtualEnv(venv, venv)

def create_venv(
self,
Expand Down Expand Up @@ -1741,6 +1741,21 @@ def get_paths(self) -> Dict[str, str]:

return json.loads(output)

def execute(self, bin: str, *args: str, **kwargs: Any) -> Optional[int]:
command = self.get_command_from_bin(bin) + list(args)
env = kwargs.pop("env", {k: v for k, v in os.environ.items()})

if not self._is_windows:
return os.execvpe(command[0], command, env=env)
else:
exe = subprocess.Popen([command[0]] + command[1:], env=env, **kwargs)
exe.communicate()

return exe.returncode

def _run(self, cmd: List[str], **kwargs: Any) -> Optional[int]:
return super(VirtualEnv, self)._run(cmd, **kwargs)

def is_venv(self) -> bool:
return self._path != self._base

Expand Down

0 comments on commit b20808d

Please sign in to comment.