Skip to content

Commit

Permalink
Drop direct dependency on crashtest (#9108)
Browse files Browse the repository at this point in the history
Co-authored-by: Arun Babu Neelicattu <arun.neelicattu@gmail.com>
  • Loading branch information
Secrus and abn authored Mar 3, 2024
1 parent b8fd4a1 commit 748883e
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 216 deletions.
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ poetry-plugin-export = "^1.6.0"
build = "^1.0.3"
cachecontrol = { version = "^0.14.0", extras = ["filecache"] }
cleo = "^2.1.0"
crashtest = "^0.4.1"
dulwich = "^0.21.2"
fastjsonschema = "^2.18.0"
importlib-metadata = { version = ">=4.4", python = "<3.10" }
Expand Down
24 changes: 0 additions & 24 deletions src/poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
from cleo.io.inputs.input import Input
from cleo.io.io import IO
from cleo.io.outputs.output import Output
from crashtest.solution_providers.solution_provider_repository import (
SolutionProviderRepository,
)

from poetry.console.commands.installer_command import InstallerCommand
from poetry.poetry import Poetry
Expand Down Expand Up @@ -174,13 +171,6 @@ def create_io(

return io

def render_error(self, error: Exception, io: IO) -> None:
# We set the solution provider repository here to load providers
# only when an error occurs
self.set_solution_provider_repository(self._get_solution_provider_repository())

super().render_error(error, io)

def _run(self, io: IO) -> int:
self._disable_plugins = io.input.parameter_option("--no-plugins")
self._disable_cache = io.input.has_parameter_option("--no-cache")
Expand Down Expand Up @@ -392,20 +382,6 @@ def _default_definition(self) -> Definition:

return definition

def _get_solution_provider_repository(self) -> SolutionProviderRepository:
from crashtest.solution_providers.solution_provider_repository import (
SolutionProviderRepository,
)

from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
PythonRequirementSolutionProvider,
)

repository = SolutionProviderRepository()
repository.register_solution_providers([PythonRequirementSolutionProvider])

return repository


def main() -> int:
exit_code: int = Application().run()
Expand Down
38 changes: 37 additions & 1 deletion src/poetry/mixology/failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,22 @@ def __init__(self, root: Incompatibility) -> None:

def write(self) -> str:
buffer = []

version_solutions = []
required_python_version_notification = False
for incompatibility in self._root.external_incompatibilities:
if isinstance(incompatibility.cause, PythonCause):
root_constraint = parse_constraint(
incompatibility.cause.root_python_version
)
constraint = parse_constraint(incompatibility.cause.python_version)

version_solutions.append(
"For <fg=default;options=bold>"
f"{incompatibility.terms[0].dependency.name}</>,"
" a possible solution would be to set the"
" `<fg=default;options=bold>python</>` property to"
f' <fg=yellow>"{root_constraint.intersect(constraint)}"</>'
)
if not required_python_version_notification:
buffer.append(
"The current project's supported Python range"
Expand Down Expand Up @@ -91,7 +103,31 @@ def write(self) -> str:
message = " " * padding + message

buffer.append(message)
if required_python_version_notification:
# Add suggested solution
links = ",".join(
f"\n <fg=blue>https://python-poetry.org/docs/dependency-specification/#{section}</>"
for section in [
"python-restricted-dependencies",
"using-environment-markers",
]
)

description = (
"The Python requirement can be specified via the"
" `<fg=default;options=bold>python</>` or"
" `<fg=default;options=bold>markers</>` properties"
)
if version_solutions:
description += "\n\n " + "\n".join(version_solutions)

description = description.strip(" ")

buffer.append(
f"\n <fg=blue;options=bold>* </>"
f"<fg=default;options=bold>Check your dependencies Python requirement</>:"
f" {description}\n{links}\n",
)
return "\n".join(buffer)

def _write(
Expand Down
Empty file.
8 changes: 0 additions & 8 deletions src/poetry/mixology/solutions/providers/__init__.py

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions src/poetry/mixology/solutions/solutions/__init__.py

This file was deleted.

This file was deleted.

Empty file.
Empty file.

This file was deleted.

Empty file.

This file was deleted.

10 changes: 9 additions & 1 deletion tests/mixology/version_solver/test_python_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def test_dependency_does_not_match_root_python_constraint(
Because no versions of foo match !=1.0.0
and foo (1.0.0) requires Python <3.5, foo is forbidden.
So, because myapp depends on foo (*), version solving failed."""
So, because myapp depends on foo (*), version solving failed.
<fg=blue;options=bold>* </><fg=default;options=bold>Check your dependencies Python requirement</>: The Python requirement can be specified via the `<fg=default;options=bold>python</>` or `<fg=default;options=bold>markers</>` properties
For <fg=default;options=bold>foo</>, a possible solution would be to set the `<fg=default;options=bold>python</>` property to <fg=yellow>"<empty>"</>
<fg=blue>https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies</>,
<fg=blue>https://python-poetry.org/docs/dependency-specification/#using-environment-markers</>
"""

check_solver_result(root, provider, error=error)

0 comments on commit 748883e

Please sign in to comment.