Commit 3bdc3972 by Randy Döring

refactor(env): remove duplicated implementations of get_pip_command()

parent 40780824
......@@ -1393,7 +1393,7 @@ class Env:
raise NotImplementedError()
def get_pip_command(self, embedded: bool = False) -> list[str]:
raise NotImplementedError()
return [self.python, self.pip_embedded if embedded else self.pip]
def get_supported_tags(self) -> list[Tag]:
raise NotImplementedError()
......@@ -1556,11 +1556,6 @@ class SystemEnv(Env):
def get_python_implementation(self) -> str:
return platform.python_implementation()
def get_pip_command(self, embedded: bool = False) -> list[str]:
# If we're not in a venv, assume the interpreter we're running on
# has a pip and use that
return [sys.executable, self.pip_embedded if embedded else self.pip]
def get_paths(self) -> dict[str, str]:
# We can't use sysconfig.get_paths() because
# on some distributions it does not return the proper paths
......@@ -1672,14 +1667,6 @@ class VirtualEnv(Env):
implementation: str = self.marker_env["platform_python_implementation"]
return implementation
def get_pip_command(self, embedded: bool = False) -> list[str]:
# We're in a virtualenv that is known to be sane,
# so assume that we have a functional pip
return [
self._bin(self._executable),
self.pip_embedded if embedded else self.pip,
]
def get_supported_tags(self) -> list[Tag]:
output = self.run_python_script(GET_SYS_TAGS)
assert isinstance(output, str)
......@@ -1858,12 +1845,6 @@ class NullEnv(SystemEnv):
self._execute = execute
self.executed: list[list[str]] = []
def get_pip_command(self, embedded: bool = False) -> list[str]:
return [
self._bin(self._executable),
self.pip_embedded if embedded else self.pip,
]
def _run(self, cmd: list[str], **kwargs: Any) -> int | str:
self.executed.append(cmd)
......
......@@ -1392,7 +1392,7 @@ def test_build_environment_called_build_script_specified(
assert env == ephemeral_env
assert env.executed == [
[
"python",
sys.executable,
env.pip_embedded,
"install",
"--disable-pip-version-check",
......
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