Poetry 看到一个间接依赖(numpy for python)已经过时了,但是没有更新它

Poetry sees an indirect dependency (numpy for python) is outdated, but doesn't update it

试用 poetry 1.1.11 并在 tool.poetry.dependencies 部分的 pyproject.toml 中添加 pandas。 Pandas 依赖于 numpy

pandas 1.3.3 Powerful data structures for data analysis, time series, and statistics
├── numpy >=1.17.3
├── python-dateutil >=2.7.3
│   └── six >=1.5 
└── pytz >=2017.3

当我调用 poetry add pandas 时,它正确安装了 numpy 1.21.1。 Numpy 已经升级到 1.22.2 并且 poetry 认识到这一点

poetry show --outdated
numpy 1.21.1 1.21.2 NumPy is the fundamental package for array computing with Python.

但是 numpy 不是由诗歌更新的。

poetry update
Updating dependencies
Resolving dependencies... (0.3s)

No dependencies to install or update

这是预期的吗? numpy 将如何/何时更新?

EDIT2:根据@finswimmer 的要求,这是 TOML,并且比第一个 EDIT TOML 更简单。这是 poetry new 的一个空项目。然后尝试 poetry add numpy 如下所示。

刚刚

[tool.poetry]
name = "delete_me4"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

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

[tool.poetry.dev-dependencies]
pytest = "^5.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
❯ poetry add numpy
Using version ^1.21.2 for numpy

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:
    - numpy requires Python >=3.7,<3.11, so it will not be satisfied for Python >=3.11,<4.0
  
  Because numpy (1.21.2) requires Python >=3.7,<3.11
   and no versions of numpy match >1.21.2,<2.0.0, numpy is forbidden.
  So, because delete-me4 depends on numpy (^1.21.2), version solving failed.

  at ~/.local/share/pypoetry/venv/lib/python3.9/site-packages/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 numpy, a possible solution would be to set the `python` property to ">=3.9,<3.11"

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

上面帮助文本中的建议解决了这个问题。 poetry add numpy 在具有此 TOML 更改的空项目中工作。

[tool.poetry.dependencies]
python = ">=3.9,<3.11"

我不确定是什么触发了它想要 Python >= 3.11 缩小范围,但是嘿。一旦我尝试了 repro,它就解决了我的问题。

请注意,进一步限制 Python 允许 scipy 从 1.6.1 移动到 1.7.1

[tool.poetry.dependencies]
python = ">=3.9,<3.10"