Skip to content

Commit

Permalink
installer: remove old installer and config setting `experimental.new-…
Browse files Browse the repository at this point in the history
…installer`
  • Loading branch information
radoering committed Jan 15, 2023
1 parent a5c3846 commit 77d58a2
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 3,692 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,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 @@ -208,9 +208,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
3 changes: 1 addition & 2 deletions src/poetry/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Config:
"prefer-active-python": False,
"prompt": "{project_name}-py{python_version}",
},
"experimental": {"new-installer": True, "system-git-client": False},
"experimental": {"system-git-client": False},
"installer": {"parallel": True, "max-workers": None, "no-binary": None},
}

Expand Down Expand Up @@ -265,7 +265,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.parallel",
}:
Expand Down
1 change: 0 additions & 1 deletion src/poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ 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))
command.set_installer(installer)

def _load_plugins(self, io: IO | None = None) -> None:
Expand Down
5 changes: 0 additions & 5 deletions src/poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ def unique_config_values(self) -> dict[str, tuple[Any, Any, Any]]:
boolean_normalizer,
False,
),
"experimental.new-installer": (
boolean_validator,
boolean_normalizer,
True,
),
"experimental.system-git-client": (
boolean_validator,
boolean_normalizer,
Expand Down
4 changes: 0 additions & 4 deletions src/poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ def handle(self) -> int:

from poetry.masonry.builders.editable import EditableBuilder

self.installer.use_executor(
self.poetry.config.get("experimental.new-installer", False)
)

if self.option("extras") and self.option("all-extras"):
self.line_error(
"<error>You cannot specify explicit"
Expand Down
4 changes: 0 additions & 4 deletions src/poetry/console/commands/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class LockCommand(InstallerCommand):
loggers = ["poetry.repositories.pypi_repository"]

def handle(self) -> int:
self.installer.use_executor(
self.poetry.config.get("experimental.new-installer", 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
5 changes: 0 additions & 5 deletions src/poetry/console/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ class UpdateCommand(InstallerCommand):

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

self.installer.use_executor(
self.poetry.config.get("experimental.new-installer", 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.

131 changes: 1 addition & 130 deletions src/poetry/installation/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,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 @@ -26,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 @@ -71,9 +68,7 @@ def __init__(
)

self._executor = executor
self._use_executor = False

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

Expand All @@ -83,10 +78,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 @@ -179,11 +170,6 @@ def extras(self, extras: list[str]) -> Installer:

return self

def use_executor(self, use_executor: bool = True) -> Installer:
self._use_executor = use_executor

return self

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

Expand Down Expand Up @@ -363,119 +349,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)

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 @@ -562,8 +436,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

0 comments on commit 77d58a2

Please sign in to comment.