Commit c8945eb1 by Randy Döring Committed by Bjorn Neergaard

installer: deprecate old installer (setting `experimental.new-installer` to false)

parent b304b0d5
......@@ -335,7 +335,10 @@ class Application(BaseApplication):
poetry.config,
disable_cache=poetry.disable_cache,
)
installer.use_executor(poetry.config.get("experimental.new-installer", False))
use_executor = poetry.config.get("experimental.new-installer", False)
if not use_executor:
# only set if false because the method is deprecated
installer.use_executor(False)
command.set_installer(installer)
def _load_plugins(self, io: IO | None = None) -> None:
......
......@@ -95,9 +95,10 @@ dependencies and not including the current project, run the command with the
from poetry.masonry.builders.editable import EditableBuilder
self.installer.use_executor(
self.poetry.config.get("experimental.new-installer", False)
)
use_executor = self.poetry.config.get("experimental.new-installer", False)
if not use_executor:
# only set if false because the method is deprecated
self.installer.use_executor(False)
if self.option("extras") and self.option("all-extras"):
self.line_error(
......
......@@ -35,9 +35,10 @@ file.
loggers = ["poetry.repositories.pypi_repository"]
def handle(self) -> int:
self.installer.use_executor(
self.poetry.config.get("experimental.new-installer", False)
)
use_executor = self.poetry.config.get("experimental.new-installer", False)
if not use_executor:
# only set if false because the method is deprecated
self.installer.use_executor(False)
if self.option("check"):
if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh():
......
......@@ -41,9 +41,10 @@ class UpdateCommand(InstallerCommand):
def handle(self) -> int:
packages = self.argument("packages")
self.installer.use_executor(
self.poetry.config.get("experimental.new-installer", False)
)
use_executor = self.poetry.config.get("experimental.new-installer", False)
if not use_executor:
# only set if false because the method is deprecated
self.installer.use_executor(False)
if packages:
self.installer.whitelist({name: "*" for name in packages})
......
from __future__ import annotations
import warnings
from typing import TYPE_CHECKING
from cleo.io.null_io import NullIO
......@@ -71,7 +73,7 @@ class Installer:
)
self._executor = executor
self._use_executor = False
self._use_executor = True
self._installer = self._get_installer()
if installed is None:
......@@ -180,6 +182,14 @@ class Installer:
return self
def use_executor(self, use_executor: bool = True) -> Installer:
warnings.warn(
(
"Calling use_executor() is deprecated since it's true by default now"
" and deactivating it will be removed in a future release."
),
DeprecationWarning,
stacklevel=2,
)
self._use_executor = use_executor
return self
......@@ -366,6 +376,14 @@ class Installer:
if self._use_executor:
return self._executor.execute(operations)
self._io.write_error(
"<warning>"
"Setting `experimental.new-installer` to false is deprecated and"
" slated for removal in an upcoming minor release.\n"
"(Despite of the setting's name the new installer is not experimental!)"
"</warning>"
)
if not operations and (self._execute_operations or self._dry_run):
self._io.write_line("No dependencies to install or update")
......
......@@ -1917,6 +1917,17 @@ class NullEnv(SystemEnv):
self._execute = execute
self.executed: list[list[str]] = []
@property
def paths(self) -> dict[str, str]:
if self._paths is None:
self._paths = self.get_paths()
self._paths["platlib"] = str(self._path / "platlib")
self._paths["purelib"] = str(self._path / "purelib")
self._paths["scripts"] = str(self._path / "scripts")
self._paths["data"] = str(self._path / "data")
return self._paths
def _run(self, cmd: list[str], **kwargs: Any) -> int | str:
self.executed.append(cmd)
......@@ -2044,17 +2055,6 @@ class MockEnv(NullEnv):
return self._sys_path
@property
def paths(self) -> dict[str, str]:
if self._paths is None:
self._paths = self.get_paths()
self._paths["platlib"] = str(self._path / "platlib")
self._paths["purelib"] = str(self._path / "purelib")
self._paths["scripts"] = str(self._path / "scripts")
self._paths["data"] = str(self._path / "data")
return self._paths
def get_marker_env(self) -> dict[str, Any]:
if self._mock_marker_env is not None:
return self._mock_marker_env
......
......@@ -50,7 +50,8 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
@pytest.fixture()
def old_tester(tester: CommandTester) -> CommandTester:
tester.command.installer.use_executor(False)
with pytest.warns(DeprecationWarning):
tester.command.installer.use_executor(False)
return tester
......
......@@ -166,7 +166,6 @@ def command_tester_factory(
executor=executor
or TestExecutor(env, poetry.pool, poetry.config, tester.io),
)
installer.use_executor(True)
command.set_installer(installer)
return tester
......
......@@ -197,8 +197,6 @@ def installer(
installed=installed,
executor=Executor(env, pool, config, NullIO()),
)
installer.use_executor(True)
return installer
......@@ -1961,8 +1959,6 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
installed=installed,
executor=Executor(env, pool, config, NullIO()),
)
installer.use_executor()
installer.update(True)
installer.whitelist(["D"])
installer.run()
......@@ -1996,7 +1992,6 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
installed=installed,
executor=Executor(env, pool, config, NullIO()),
)
installer.use_executor()
package.add_dependency(Factory.create_dependency("poetry", {"version": "^0.12.0"}))
......@@ -2025,8 +2020,6 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
installed=installed,
executor=Executor(env, pool, config, NullIO()),
)
installer.use_executor()
installer.update(True)
installer.whitelist(["pytest"])
installer.run()
......@@ -2057,8 +2050,6 @@ def test_installer_required_extras_should_be_installed(
installed=installed,
executor=Executor(env, pool, config, NullIO()),
)
installer.use_executor()
package.add_dependency(
Factory.create_dependency(
"cachecontrol", {"version": "^0.12.5", "extras": ["filecache"]}
......@@ -2085,8 +2076,6 @@ def test_installer_required_extras_should_be_installed(
installed=installed,
executor=Executor(env, pool, config, NullIO()),
)
installer.use_executor()
installer.update(True)
installer.run()
......@@ -2200,8 +2189,6 @@ def test_installer_can_install_dependencies_from_forced_source(
installed=installed,
executor=Executor(env, pool, config, NullIO()),
)
installer.use_executor()
installer.update(True)
installer.run()
......@@ -2267,7 +2254,6 @@ def test_run_installs_with_same_version_url_files(
NullIO(),
),
)
installer.use_executor(True)
installer.run()
expected = fixture("with-same-version-url-dependencies")
......@@ -2332,8 +2318,6 @@ def test_installer_can_handle_old_lock_files(
installed=installed,
executor=Executor(MockEnv(), pool, config, NullIO()),
)
installer.use_executor()
installer.run()
assert installer.executor.installations_count == 6
......@@ -2353,8 +2337,6 @@ def test_installer_can_handle_old_lock_files(
NullIO(),
),
)
installer.use_executor()
installer.run()
# funcsigs will be added
......@@ -2375,8 +2357,6 @@ def test_installer_can_handle_old_lock_files(
NullIO(),
),
)
installer.use_executor()
installer.run()
# colorama will be added
......@@ -2640,7 +2620,6 @@ def test_installer_distinguishes_locked_packages_by_source(
NullIO(),
),
)
installer.use_executor(True)
installer.run()
# Results of installation are consistent with the platform requirements.
......
......@@ -4,6 +4,7 @@ import itertools
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
import pytest
......@@ -40,6 +41,10 @@ RESERVED_PACKAGES = ("pip", "setuptools", "wheel")
class Installer(BaseInstaller):
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
self._use_executor = False
def _get_installer(self) -> NoopInstaller:
return NoopInstaller()
......
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