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