diff --git a/src/poetry/console/application.py b/src/poetry/console/application.py index 2dd422573fa..8c246b369bf 100644 --- a/src/poetry/console/application.py +++ b/src/poetry/console/application.py @@ -335,7 +335,10 @@ def configure_installer_for_command(command: InstallerCommand, io: IO) -> None: 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: diff --git a/src/poetry/console/commands/install.py b/src/poetry/console/commands/install.py index 453feaf55d0..844ec37176f 100644 --- a/src/poetry/console/commands/install.py +++ b/src/poetry/console/commands/install.py @@ -95,9 +95,10 @@ def handle(self) -> int: 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( diff --git a/src/poetry/console/commands/lock.py b/src/poetry/console/commands/lock.py index d1009a265e8..2d74c109fba 100644 --- a/src/poetry/console/commands/lock.py +++ b/src/poetry/console/commands/lock.py @@ -35,9 +35,10 @@ class LockCommand(InstallerCommand): 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(): diff --git a/src/poetry/console/commands/update.py b/src/poetry/console/commands/update.py index 714a924e5bd..955438a5474 100644 --- a/src/poetry/console/commands/update.py +++ b/src/poetry/console/commands/update.py @@ -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}) diff --git a/src/poetry/installation/installer.py b/src/poetry/installation/installer.py index 9b906f7678f..b5aa54f7072 100644 --- a/src/poetry/installation/installer.py +++ b/src/poetry/installation/installer.py @@ -1,5 +1,7 @@ from __future__ import annotations +import warnings + from typing import TYPE_CHECKING from cleo.io.null_io import NullIO @@ -71,7 +73,7 @@ def __init__( ) self._executor = executor - self._use_executor = False + self._use_executor = True self._installer = self._get_installer() if installed is None: @@ -180,6 +182,14 @@ def extras(self, extras: list[str]) -> 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 @@ def _execute(self, operations: list[Operation]) -> int: if self._use_executor: return self._executor.execute(operations) + self._io.write_error( + "" + "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!)" + "" + ) + if not operations and (self._execute_operations or self._dry_run): self._io.write_line("No dependencies to install or update") diff --git a/src/poetry/utils/env.py b/src/poetry/utils/env.py index 1c01a455c48..8d897fd2ac9 100644 --- a/src/poetry/utils/env.py +++ b/src/poetry/utils/env.py @@ -1917,6 +1917,17 @@ def __init__( 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 @@ def sys_path(self) -> list[str]: 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 diff --git a/tests/console/commands/test_add.py b/tests/console/commands/test_add.py index a654e835579..b7ffde8ae1b 100644 --- a/tests/console/commands/test_add.py +++ b/tests/console/commands/test_add.py @@ -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 diff --git a/tests/console/conftest.py b/tests/console/conftest.py index a78ceaa89f9..eed6665335e 100644 --- a/tests/console/conftest.py +++ b/tests/console/conftest.py @@ -166,7 +166,6 @@ def _tester( executor=executor or TestExecutor(env, poetry.pool, poetry.config, tester.io), ) - installer.use_executor(True) command.set_installer(installer) return tester diff --git a/tests/installation/test_installer.py b/tests/installation/test_installer.py index 70761e48ebf..76e11ecd611 100644 --- a/tests/installation/test_installer.py +++ b/tests/installation/test_installer.py @@ -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. diff --git a/tests/installation/test_installer_old.py b/tests/installation/test_installer_old.py index 2b7bbc22afa..e76fabb21f3 100644 --- a/tests/installation/test_installer_old.py +++ b/tests/installation/test_installer_old.py @@ -4,6 +4,7 @@ from pathlib import Path from typing import TYPE_CHECKING +from typing import Any import pytest @@ -40,6 +41,10 @@ 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() diff --git a/tests/repositories/fixtures/pypi.org/dists/importlib_metadata-1.7.0-py2.py3-none-any.whl b/tests/repositories/fixtures/pypi.org/dists/importlib_metadata-1.7.0-py2.py3-none-any.whl new file mode 100644 index 00000000000..cfcb2db4d4a Binary files /dev/null and b/tests/repositories/fixtures/pypi.org/dists/importlib_metadata-1.7.0-py2.py3-none-any.whl differ diff --git a/tests/repositories/fixtures/pypi.org/dists/zipp-3.5.0-py3-none-any.whl b/tests/repositories/fixtures/pypi.org/dists/zipp-3.5.0-py3-none-any.whl new file mode 100644 index 00000000000..9b606195459 Binary files /dev/null and b/tests/repositories/fixtures/pypi.org/dists/zipp-3.5.0-py3-none-any.whl differ