Commit a3348f28 by Arun Babu Neelicattu

Use utils.pip for executor installs

parent 6400f423
......@@ -24,6 +24,7 @@ from poetry.utils.env import EnvCommandError
from poetry.utils.helpers import safe_rmtree
from poetry.utils.pip import pip_editable_install
from ..utils.pip import pip_install
from .authenticator import Authenticator
from .chef import Chef
from .chooser import Chooser
......@@ -475,12 +476,9 @@ class Executor(object):
)
)
self._write(operation, message)
args = ["install", "--no-deps", str(archive)]
if operation.job_type == "update":
args.insert(2, "-U")
return self.run_pip(*args)
return pip_install(
str(archive), self._env, upgrade=operation.job_type == "update"
)
def _update(self, operation: Union[Install, Update]) -> int:
return self._install(operation)
......@@ -538,8 +536,6 @@ class Executor(object):
else:
req = os.path.realpath(package.source_url)
args = ["install", "--no-deps", "-U"]
pyproject = PyProjectTOML(os.path.join(req, "pyproject.toml"))
if pyproject.is_poetry_project():
......@@ -574,17 +570,12 @@ class Executor(object):
with builder.setup_py():
if package.develop:
return pip_editable_install(req, self._env)
args.append(req)
return self.run_pip(*args)
return pip_install(req, self._env, upgrade=True)
if package.develop:
return pip_editable_install(req, self._env)
args.append(req)
return self.run_pip(*args)
return pip_install(req, self._env, upgrade=True)
def _install_git(self, operation: Union[Install, Update]) -> int:
from poetry.core.vcs import Git
......
from pathlib import Path
from typing import Union
from poetry.exceptions import PoetryException
from poetry.utils._compat import Path
from poetry.utils.env import Env
from poetry.utils.env import ephemeral_environment
def pip_install(
path, environment, editable=False, deps=False, upgrade=False
): # type: (Path, Env, bool, bool, bool) -> None
path: Union[Path, str],
environment: Env,
editable: bool = False,
deps: bool = False,
upgrade: bool = False,
) -> Union[int, str]:
path = Path(path) if isinstance(path, str) else path
args = ["pip", "install", "--prefix", str(environment.path)]
args = ["install", "--prefix", str(environment.path)]
if upgrade:
args.append("--upgrade")
......@@ -26,13 +32,19 @@ def pip_install(
args.append(str(path))
if path.is_file() and path.suffix == ".whl":
return environment.run_pip(*args)
with ephemeral_environment(
executable=environment.python, pip=True, setuptools=True
) as env:
return env.run(*args)
return env.run(
"pip",
*args,
)
def pip_editable_install(directory, environment): # type: (Path, Env) -> None
def pip_editable_install(directory: Path, environment: Env) -> Union[int, str]:
return pip_install(
path=directory, environment=environment, editable=True, deps=False, upgrade=True
)
......@@ -13,6 +13,7 @@ from cleo.io.buffered_io import BufferedIO
from poetry.config.config import Config
from poetry.core.packages.package import Package
from poetry.core.utils._compat import PY36
from poetry.installation.executor import Executor
from poetry.installation.operations import Install
from poetry.installation.operations import Uninstall
......@@ -69,7 +70,7 @@ def test_execute_executes_a_batch_of_operations(
mocker, config, pool, io, tmp_dir, mock_file_downloads, env
):
pip_editable_install = mocker.patch(
"poetry.installation.executor.pip_editable_install"
"poetry.installation.executor.pip_editable_install", unsafe=not PY36
)
config = Config()
......
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