Commit ae1773d6 by Sébastien Eustace

Fixed wrong executable being picked up on Windows in poetry run

parent eec9a33b
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
- Fixed a `UnicodeDecodeError` when an error occurs in venv. - Fixed a `UnicodeDecodeError` when an error occurs in venv.
- Fixed Python requirements not properly set when resolving dependencies. - Fixed Python requirements not properly set when resolving dependencies.
- Fixed terminal coloring being activated even if not supported. - Fixed terminal coloring being activated even if not supported.
- Fixed wrong executable being picked up on Windows in `poetry run`.
## [0.10.1] - 2018-05-28 ## [0.10.1] - 2018-05-28
......
...@@ -235,6 +235,9 @@ class Venv(object): ...@@ -235,6 +235,9 @@ class Venv(object):
""" """
Run a command inside the virtual env. Run a command inside the virtual env.
""" """
if self._windows:
bin = self._bin(bin)
cmd = [bin] + list(args) cmd = [bin] + list(args)
shell = kwargs.get("shell", False) shell = kwargs.get("shell", False)
call = kwargs.pop("call", False) call = kwargs.pop("call", False)
...@@ -276,6 +279,9 @@ class Venv(object): ...@@ -276,6 +279,9 @@ class Venv(object):
if not self.is_venv(): if not self.is_venv():
return subprocess.call([bin] + list(args)) return subprocess.call([bin] + list(args))
else: else:
if self._windows:
bin = self._bin(bin)
with self.temp_environ(): with self.temp_environ():
os.environ["PATH"] = self._path() os.environ["PATH"] = self._path()
os.environ["VIRTUAL_ENV"] = str(self._venv) os.environ["VIRTUAL_ENV"] = str(self._venv)
...@@ -313,7 +319,11 @@ class Venv(object): ...@@ -313,7 +319,11 @@ class Venv(object):
if not self.is_venv(): if not self.is_venv():
return bin return bin
return str(self._bin_dir / bin) + (".exe" if self._windows else "") bin_path = (self._bin_dir / bin).with_suffix(".exe" if self._windows else "")
if not bin_path.exists():
return bin
return str(bin_path)
def is_venv(self): # type: () -> bool def is_venv(self): # type: () -> bool
return self._venv is not None return self._venv is not None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment