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

Drop direct dependency on crashtest #9108

Merged
merged 2 commits into from
Mar 3, 2024
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
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)
Loading