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

Python requirement of package completely ignored by poetry #5591

Closed
3 tasks done
onnoeberhard opened this issue May 11, 2022 · 5 comments · Fixed by python-poetry/poetry-core#407 or python-poetry/poetry-core#457
Closed
3 tasks done
Labels
area/solver Related to the dependency resolver kind/bug Something isn't working as expected

Comments

@onnoeberhard
Copy link

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: macOS 12.3.1
  • Poetry version: 1.1.13
  • Link of a Gist with the contents of your pyproject.toml file: (contents pasted below)

Issue

I created a completely empty folder with the following pyproject.toml file:

[tool.poetry]
name = "abcd"
version = "0.1.0"
description = ""
authors = ["Onno Eberhard <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.9"

[tool.poetry.dev-dependencies]
dm-control = {version = "^1.0.2", python = ">=3.9,<=3.10"}

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Running poetry update yields the following error message:

Updating dependencies
Resolving dependencies... (0.0s)

  SolverProblemError

  The current project's Python requirement (>=3.9,<4.0) is not compatible with some of the required packages Python requirement:
    - dm-control requires Python >=3.7, <=3.10, so it will not be satisfied for Python >3.10,<4.0

  Because no versions of dm-control match >1.0.2,<2.0.0
   and dm-control (1.0.2) requires Python >=3.7, <=3.10, dm-control is forbidden.
  So, because abcd depends on dm-control (^1.0.2), version solving failed.

  at ~/.poetry/lib/poetry/puzzle/solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For dm-control, a possible solution would be to set the `python` property to ">=3.9,<=3.10"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

The suggestion is to "set the python property to ">=3.9,<=3.10"", which I have done. I can only conclude that poetry completely ignores this property.

@onnoeberhard onnoeberhard added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 11, 2022
@abn
Copy link
Member

abn commented May 11, 2022

Workaround:

dm-control = {version = "^1.0.2", python = ~3.9,<=3.10"}

@dimbleby
Copy link
Contributor

the suggestion is trying to tell you that you could set the project-level python property, it is not intending to be about any property on this particular package.

@onnoeberhard
Copy link
Author

@abn Thanks! The workaround does indeed work for this example, but in my actual project I am using Python 3.8, so "~3.8" would mean something different than ">=3.8,<=3.10". I still tried it but then I got the same error message (again for dm-control, but with the python property set to "~3.8") when I tried to add another dependency (flake8)...

@dimbleby Thanks, but as I am only using this package as a development dependency I don't want to change the Python version of the whole project.

@Secrus Secrus added area/solver Related to the dependency resolver and removed status/triage This issue needs to be triaged labels May 15, 2022
@dimbleby
Copy link
Contributor

dimbleby commented Jun 25, 2022

@onnoeberhard I wasn't telling you to make that change, I was telling you what the error message was saying. ie

The suggestion is to "set the python property to ">=3.9,<=3.10"", which I have done.

is a misunderstanding of what the suggestion was.

Having said which, I'm not completely sure that I was right about that!

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/solver Related to the dependency resolver kind/bug Something isn't working as expected
Projects
None yet
4 participants