Commit 80581105 by Sébastien Eustace Committed by GitHub

use run_pip of env in executor (#2701) (#2714)

This ensures to use the correct python executable.
Using `run` simply uses `sys.prefix` with a bin suffix, which is not necessarily the currently used python executable.

E.g. when linking a specific python version to a custom directory, using `sys.prefix` may point to the wrong python version:
* /usr/bin/python2.7
* /usr/bin/python3.6
* /usr/bin/python is a symlink to 2.7
* /usr/bin/local/python (or any other location) is a symlink to 3.6 which shadows the former symlink
`sys.prefix` is `/usr` in this case, which is correct, but the `python` executable there points to the wrong version.

`run_pip` in the env fixes this already by using `sys.executable`, see https://github.com/python-poetry/poetry/blob/develop/poetry/utils/env.py#L964
This should be used in the executor as well.

Co-authored-by: Jonathan Striebel <jstriebel@users.noreply.github.com>
parent 2ba36c82
...@@ -280,7 +280,7 @@ class Executor(object): ...@@ -280,7 +280,7 @@ class Executor(object):
def run_pip(self, *args, **kwargs): # type: (...) -> int def run_pip(self, *args, **kwargs): # type: (...) -> int
try: try:
self._env.run("python", "-m", "pip", *args, **kwargs) self._env.run_pip(*args, **kwargs)
except EnvCommandError as e: except EnvCommandError as e:
output = decode(e.e.output) output = decode(e.e.output)
if ( if (
......
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