Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installer: remove old installer and config setting experimental.new-installer #7356

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ $ poetry cache clear pypi --all
- Added in info output to `poetry lock --check` ([#5081](https://github.com/python-poetry/poetry/pull/5081)).
- Added new argument `--all` for `poetry env remove` to delete all venv of a project at once ([#3212](https://github.com/python-poetry/poetry/pull/3212)).
- Added new argument `--without-urls` for `poetry export` to exclude source repository urls from the exported file ([#4763](https://github.com/python-poetry/poetry/pull/4763)).
- Added a `new installer.max-workers` property to the configuration ([#3516](https://github.com/python-poetry/poetry/pull/3516)).
- Added a new `installer.max-workers` property to the configuration ([#3516](https://github.com/python-poetry/poetry/pull/3516)).
- Added experimental option `virtualenvs.prefer-active-python` to detect current activated python ([#4852](https://github.com/python-poetry/poetry/pull/4852)).
- Added better windows shell support ([#5053](https://github.com/python-poetry/poetry/pull/5053)).

Expand Down
3 changes: 0 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ specific packages.
| `package[,package,..]` | Disallow binary distributions for specified packages only. |

{{% note %}}
This configuration is only respected when using the new installer. If you have disabled it please
consider re-enabling it.

As with all configurations described here, this is a user specific configuration. This means that this
is not taken into consideration when a lockfile is generated or dependencies are resolved. This is
applied only when selecting which distribution for dependency should be installed into a Poetry managed
Expand Down
2 changes: 0 additions & 2 deletions src/poetry/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class Config:
"prompt": "{project_name}-py{python_version}",
},
"experimental": {
"new-installer": True,
"system-git-client": False,
},
"installer": {
Expand Down Expand Up @@ -276,7 +275,6 @@ def _get_normalizer(name: str) -> Callable[[str], Any]:
"virtualenvs.options.always-copy",
"virtualenvs.options.system-site-packages",
"virtualenvs.options.prefer-active-python",
"experimental.new-installer",
"experimental.system-git-client",
"installer.modern-installation",
"installer.parallel",
Expand Down
4 changes: 0 additions & 4 deletions src/poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,6 @@ def configure_installer_for_command(command: InstallerCommand, io: IO) -> None:
poetry.config,
disable_cache=poetry.disable_cache,
)
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:
Expand Down
1 change: 0 additions & 1 deletion src/poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def unique_config_values(self) -> dict[str, tuple[Any, Any]]:
),
"virtualenvs.path": (str, lambda val: str(Path(val))),
"virtualenvs.prefer-active-python": (boolean_validator, boolean_normalizer),
"experimental.new-installer": (boolean_validator, boolean_normalizer),
"experimental.system-git-client": (boolean_validator, boolean_normalizer),
"installer.modern-installation": (boolean_validator, boolean_normalizer),
"installer.parallel": (boolean_validator, boolean_normalizer),
Expand Down
5 changes: 0 additions & 5 deletions src/poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ def handle(self) -> int:

from poetry.masonry.builders.editable import EditableBuilder

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(
"<error>You cannot specify explicit"
Expand Down
5 changes: 0 additions & 5 deletions src/poetry/console/commands/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class LockCommand(InstallerCommand):
loggers = ["poetry.repositories.pypi_repository"]

def handle(self) -> int:
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():
self.line("poetry.lock is consistent with pyproject.toml.")
Expand Down
6 changes: 0 additions & 6 deletions src/poetry/console/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ class UpdateCommand(InstallerCommand):

def handle(self) -> int:
packages = self.argument("packages")

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})

Expand Down
18 changes: 0 additions & 18 deletions src/poetry/installation/base_installer.py

This file was deleted.

149 changes: 1 addition & 148 deletions src/poetry/installation/installer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import warnings

from typing import TYPE_CHECKING

from cleo.io.null_io import NullIO
Expand All @@ -11,13 +9,11 @@
from poetry.installation.operations import Install
from poetry.installation.operations import Uninstall
from poetry.installation.operations import Update
from poetry.installation.pip_installer import PipInstaller
from poetry.repositories import Repository
from poetry.repositories import RepositoryPool
from poetry.repositories.installed_repository import InstalledRepository
from poetry.repositories.lockfile_repository import LockfileRepository
from poetry.utils.extras import get_extra_package_names
from poetry.utils.helpers import pluralize


if TYPE_CHECKING:
Expand All @@ -28,7 +24,6 @@
from poetry.core.packages.project_package import ProjectPackage

from poetry.config.config import Config
from poetry.installation.base_installer import BaseInstaller
from poetry.installation.operations.operation import Operation
from poetry.packages import Locker
from poetry.utils.env import Env
Expand Down Expand Up @@ -74,9 +69,7 @@ def __init__(
)

self._executor = executor
self._use_executor = True

self._installer = self._get_installer()
if installed is None:
installed = self._get_installed()

Expand All @@ -86,10 +79,6 @@ def __init__(
def executor(self) -> Executor:
return self._executor

@property
def installer(self) -> BaseInstaller:
return self._installer

def set_package(self, package: ProjectPackage) -> Installer:
self._package = package

Expand Down Expand Up @@ -187,19 +176,6 @@ 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

def _do_refresh(self) -> int:
from poetry.puzzle.solver import Solver

Expand Down Expand Up @@ -384,127 +360,7 @@ def _write_lock_file(self, repo: LockfileRepository, force: bool = False) -> Non
self._io.write_line("<info>Writing lock file</>")

def _execute(self, operations: list[Operation]) -> int:
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")

if operations and (self._execute_operations or self._dry_run):
installs = 0
updates = 0
uninstalls = 0
skipped = 0
for op in operations:
if op.skipped:
skipped += 1
elif op.job_type == "install":
installs += 1
elif op.job_type == "update":
updates += 1
elif op.job_type == "uninstall":
uninstalls += 1

self._io.write_line("")
self._io.write("Package operations: ")
self._io.write(f"<info>{installs}</> install{pluralize(installs)}, ")
self._io.write(f"<info>{updates}</> update{pluralize(updates)}, ")
self._io.write(f"<info>{uninstalls}</> removal{pluralize(uninstalls)}")
if skipped and self.is_verbose():
self._io.write(f", <info>{skipped}</> skipped")
self._io.write_line("")

self._io.write_line("")

for op in operations:
self._execute_operation(op)

return 0

def _execute_operation(self, operation: Operation) -> None:
"""
Execute a given operation.
"""
method = operation.job_type

getattr(self, f"_execute_{method}")(operation)

def _execute_install(self, operation: Install) -> None:
target = operation.package
if operation.skipped:
if self.is_verbose() and (self._execute_operations or self.is_dry_run()):
self._io.write_line(
f" - Skipping <c1>{target.pretty_name}</c1>"
f" (<c2>{target.full_pretty_version}</c2>) {operation.skip_reason}"
)

return

if self._execute_operations or self.is_dry_run():
self._io.write_line(
f" - Installing <c1>{target.pretty_name}</c1>"
f" (<c2>{target.full_pretty_version}</c2>)"
)

if not self._execute_operations:
return

self._installer.install(operation.package)

def _execute_update(self, operation: Update) -> None:
source = operation.initial_package
target = operation.target_package

if operation.skipped:
if self.is_verbose() and (self._execute_operations or self.is_dry_run()):
self._io.write_line(
f" - Skipping <c1>{target.pretty_name}</c1> "
f"(<c2>{target.full_pretty_version}</c2>) {operation.skip_reason}"
)

return

if self._execute_operations or self.is_dry_run():
self._io.write_line(
f" - Updating <c1>{target.pretty_name}</c1>"
f" (<c2>{source.full_pretty_version}</c2> ->"
f" <c2>{target.full_pretty_version}</c2>)"
)

if not self._execute_operations:
return

self._installer.update(source, target)

def _execute_uninstall(self, operation: Uninstall) -> None:
target = operation.package
if operation.skipped:
if self.is_verbose() and (self._execute_operations or self.is_dry_run()):
self._io.write_line(
f" - Not removing <c1>{target.pretty_name}</c1>"
f" (<c2>{target.pretty_version}</c2>) {operation.skip_reason}"
)

return

if self._execute_operations or self.is_dry_run():
self._io.write_line(
f" - Removing <c1>{target.pretty_name}</c1>"
f" (<c2>{target.pretty_version}</c2>)"
)

if not self._execute_operations:
return

self._installer.remove(operation.package)
return self._executor.execute(operations)

def _populate_lockfile_repo(
self, repo: LockfileRepository, ops: Iterable[Operation]
Expand Down Expand Up @@ -588,8 +444,5 @@ def _get_extra_packages(self, repo: Repository) -> set[NormalizedName]:

return get_extra_package_names(repo.packages, extras, self._extras)

def _get_installer(self) -> BaseInstaller:
return PipInstaller(self._env, self._io, self._pool)

def _get_installed(self) -> InstalledRepository:
return InstalledRepository.load(self._env)
37 changes: 0 additions & 37 deletions src/poetry/installation/noop_installer.py

This file was deleted.

Loading