Skip to content

Commit c8945eb

Browse files
radoeringneersighted
authored andcommitted
installer: deprecate old installer (setting experimental.new-installer to false)
1 parent b304b0d commit c8945eb

File tree

12 files changed

+53
-45
lines changed

12 files changed

+53
-45
lines changed

src/poetry/console/application.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,10 @@ def configure_installer_for_command(command: InstallerCommand, io: IO) -> None:
335335
poetry.config,
336336
disable_cache=poetry.disable_cache,
337337
)
338-
installer.use_executor(poetry.config.get("experimental.new-installer", False))
338+
use_executor = poetry.config.get("experimental.new-installer", False)
339+
if not use_executor:
340+
# only set if false because the method is deprecated
341+
installer.use_executor(False)
339342
command.set_installer(installer)
340343

341344
def _load_plugins(self, io: IO | None = None) -> None:

src/poetry/console/commands/install.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ def handle(self) -> int:
9595

9696
from poetry.masonry.builders.editable import EditableBuilder
9797

98-
self.installer.use_executor(
99-
self.poetry.config.get("experimental.new-installer", False)
100-
)
98+
use_executor = self.poetry.config.get("experimental.new-installer", False)
99+
if not use_executor:
100+
# only set if false because the method is deprecated
101+
self.installer.use_executor(False)
101102

102103
if self.option("extras") and self.option("all-extras"):
103104
self.line_error(

src/poetry/console/commands/lock.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ class LockCommand(InstallerCommand):
3535
loggers = ["poetry.repositories.pypi_repository"]
3636

3737
def handle(self) -> int:
38-
self.installer.use_executor(
39-
self.poetry.config.get("experimental.new-installer", False)
40-
)
38+
use_executor = self.poetry.config.get("experimental.new-installer", False)
39+
if not use_executor:
40+
# only set if false because the method is deprecated
41+
self.installer.use_executor(False)
4142

4243
if self.option("check"):
4344
if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh():

src/poetry/console/commands/update.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ class UpdateCommand(InstallerCommand):
4141
def handle(self) -> int:
4242
packages = self.argument("packages")
4343

44-
self.installer.use_executor(
45-
self.poetry.config.get("experimental.new-installer", False)
46-
)
44+
use_executor = self.poetry.config.get("experimental.new-installer", False)
45+
if not use_executor:
46+
# only set if false because the method is deprecated
47+
self.installer.use_executor(False)
4748

4849
if packages:
4950
self.installer.whitelist({name: "*" for name in packages})

src/poetry/installation/installer.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import warnings
4+
35
from typing import TYPE_CHECKING
46

57
from cleo.io.null_io import NullIO
@@ -71,7 +73,7 @@ def __init__(
7173
)
7274

7375
self._executor = executor
74-
self._use_executor = False
76+
self._use_executor = True
7577

7678
self._installer = self._get_installer()
7779
if installed is None:
@@ -180,6 +182,14 @@ def extras(self, extras: list[str]) -> Installer:
180182
return self
181183

182184
def use_executor(self, use_executor: bool = True) -> Installer:
185+
warnings.warn(
186+
(
187+
"Calling use_executor() is deprecated since it's true by default now"
188+
" and deactivating it will be removed in a future release."
189+
),
190+
DeprecationWarning,
191+
stacklevel=2,
192+
)
183193
self._use_executor = use_executor
184194

185195
return self
@@ -366,6 +376,14 @@ def _execute(self, operations: list[Operation]) -> int:
366376
if self._use_executor:
367377
return self._executor.execute(operations)
368378

379+
self._io.write_error(
380+
"<warning>"
381+
"Setting `experimental.new-installer` to false is deprecated and"
382+
" slated for removal in an upcoming minor release.\n"
383+
"(Despite of the setting's name the new installer is not experimental!)"
384+
"</warning>"
385+
)
386+
369387
if not operations and (self._execute_operations or self._dry_run):
370388
self._io.write_line("No dependencies to install or update")
371389

src/poetry/utils/env.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,17 @@ def __init__(
19171917
self._execute = execute
19181918
self.executed: list[list[str]] = []
19191919

1920+
@property
1921+
def paths(self) -> dict[str, str]:
1922+
if self._paths is None:
1923+
self._paths = self.get_paths()
1924+
self._paths["platlib"] = str(self._path / "platlib")
1925+
self._paths["purelib"] = str(self._path / "purelib")
1926+
self._paths["scripts"] = str(self._path / "scripts")
1927+
self._paths["data"] = str(self._path / "data")
1928+
1929+
return self._paths
1930+
19201931
def _run(self, cmd: list[str], **kwargs: Any) -> int | str:
19211932
self.executed.append(cmd)
19221933

@@ -2044,17 +2055,6 @@ def sys_path(self) -> list[str]:
20442055

20452056
return self._sys_path
20462057

2047-
@property
2048-
def paths(self) -> dict[str, str]:
2049-
if self._paths is None:
2050-
self._paths = self.get_paths()
2051-
self._paths["platlib"] = str(self._path / "platlib")
2052-
self._paths["purelib"] = str(self._path / "purelib")
2053-
self._paths["scripts"] = str(self._path / "scripts")
2054-
self._paths["data"] = str(self._path / "data")
2055-
2056-
return self._paths
2057-
20582058
def get_marker_env(self) -> dict[str, Any]:
20592059
if self._mock_marker_env is not None:
20602060
return self._mock_marker_env

tests/console/commands/test_add.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
5050

5151
@pytest.fixture()
5252
def old_tester(tester: CommandTester) -> CommandTester:
53-
tester.command.installer.use_executor(False)
53+
with pytest.warns(DeprecationWarning):
54+
tester.command.installer.use_executor(False)
5455

5556
return tester
5657

tests/console/conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ def _tester(
166166
executor=executor
167167
or TestExecutor(env, poetry.pool, poetry.config, tester.io),
168168
)
169-
installer.use_executor(True)
170169
command.set_installer(installer)
171170

172171
return tester

tests/installation/test_installer.py

-21
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ def installer(
197197
installed=installed,
198198
executor=Executor(env, pool, config, NullIO()),
199199
)
200-
installer.use_executor(True)
201-
202200
return installer
203201

204202

@@ -1961,8 +1959,6 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
19611959
installed=installed,
19621960
executor=Executor(env, pool, config, NullIO()),
19631961
)
1964-
installer.use_executor()
1965-
19661962
installer.update(True)
19671963
installer.whitelist(["D"])
19681964
installer.run()
@@ -1996,7 +1992,6 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
19961992
installed=installed,
19971993
executor=Executor(env, pool, config, NullIO()),
19981994
)
1999-
installer.use_executor()
20001995

20011996
package.add_dependency(Factory.create_dependency("poetry", {"version": "^0.12.0"}))
20021997

@@ -2025,8 +2020,6 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
20252020
installed=installed,
20262021
executor=Executor(env, pool, config, NullIO()),
20272022
)
2028-
installer.use_executor()
2029-
20302023
installer.update(True)
20312024
installer.whitelist(["pytest"])
20322025
installer.run()
@@ -2057,8 +2050,6 @@ def test_installer_required_extras_should_be_installed(
20572050
installed=installed,
20582051
executor=Executor(env, pool, config, NullIO()),
20592052
)
2060-
installer.use_executor()
2061-
20622053
package.add_dependency(
20632054
Factory.create_dependency(
20642055
"cachecontrol", {"version": "^0.12.5", "extras": ["filecache"]}
@@ -2085,8 +2076,6 @@ def test_installer_required_extras_should_be_installed(
20852076
installed=installed,
20862077
executor=Executor(env, pool, config, NullIO()),
20872078
)
2088-
installer.use_executor()
2089-
20902079
installer.update(True)
20912080
installer.run()
20922081

@@ -2200,8 +2189,6 @@ def test_installer_can_install_dependencies_from_forced_source(
22002189
installed=installed,
22012190
executor=Executor(env, pool, config, NullIO()),
22022191
)
2203-
installer.use_executor()
2204-
22052192
installer.update(True)
22062193
installer.run()
22072194

@@ -2267,7 +2254,6 @@ def test_run_installs_with_same_version_url_files(
22672254
NullIO(),
22682255
),
22692256
)
2270-
installer.use_executor(True)
22712257
installer.run()
22722258

22732259
expected = fixture("with-same-version-url-dependencies")
@@ -2332,8 +2318,6 @@ def test_installer_can_handle_old_lock_files(
23322318
installed=installed,
23332319
executor=Executor(MockEnv(), pool, config, NullIO()),
23342320
)
2335-
installer.use_executor()
2336-
23372321
installer.run()
23382322

23392323
assert installer.executor.installations_count == 6
@@ -2353,8 +2337,6 @@ def test_installer_can_handle_old_lock_files(
23532337
NullIO(),
23542338
),
23552339
)
2356-
installer.use_executor()
2357-
23582340
installer.run()
23592341

23602342
# funcsigs will be added
@@ -2375,8 +2357,6 @@ def test_installer_can_handle_old_lock_files(
23752357
NullIO(),
23762358
),
23772359
)
2378-
installer.use_executor()
2379-
23802360
installer.run()
23812361

23822362
# colorama will be added
@@ -2640,7 +2620,6 @@ def test_installer_distinguishes_locked_packages_by_source(
26402620
NullIO(),
26412621
),
26422622
)
2643-
installer.use_executor(True)
26442623
installer.run()
26452624

26462625
# Results of installation are consistent with the platform requirements.

tests/installation/test_installer_old.py

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from pathlib import Path
66
from typing import TYPE_CHECKING
7+
from typing import Any
78

89
import pytest
910

@@ -40,6 +41,10 @@
4041

4142

4243
class Installer(BaseInstaller):
44+
def __init__(self, *args: Any, **kwargs: Any) -> None:
45+
super().__init__(*args, **kwargs)
46+
self._use_executor = False
47+
4348
def _get_installer(self) -> NoopInstaller:
4449
return NoopInstaller()
4550

Binary file not shown.

0 commit comments

Comments
 (0)