Search code examples
versioningpython-packagingpython-poetrypyproject.toml

Poetry skipping dependencies with both lower and upper bounds as "Invalid Constraint"


I am working on a project (let's call it X) which depends on another public package. Let's call it A. Package A has the following dependencies in the requirements.txt file

package-a>=6.1.0<7.0.0
package-b>=10.2.0<11.0.0
package-c>=1.0.4<2.0.0
package-d>=1.1.0<2.0.0

The pyproject.toml of package X is given below

[tool.poetry]
name = "X"
version = "1.0.0"
description = "Project X"
packages = [{include = "X"}]

[tool.poetry.dependencies]
python = "^3.8"
A = "1.0.0"
B = "12.0.0"

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

When I do a poetry lock, I see that the pacakges with both upper and lower bounds are being skipped

Updating dependencies
Resolving dependencies... (0.4s)
Invalid constraint (package-a (>=6.1.0<7.0.0)) found in A-1.0.0 dependencies, skipping
Invalid constraint (package-b (>=10.2.0<11.0.0)) found in A-1.0.0 dependencies, skipping
Invalid constraint (package-c (>=1.0.4<2.0.0)) found in A-1.0.0 dependencies, skipping
Invalid constraint (package-d (>=1.1.0<2.0.0)) found in A-1.0.0 dependencies, skipping
Resolving dependencies... (0.8s)

The same packages are missing in the poetry.lock file and hence NOT being installed when I do poetry install. Any pointers on how to solve this issue ? I couldn't find any information in https://python-poetry.org/docs/dependency-specification/


Solution

  • Seems to me like a comma , is missing to delimit the parts of the version specifiers of A's dependencies. For example it should read something like >=6.1.0,<7.0.0 (instead of >=6.1.0<7.0.0).

    A version specifier consists of a series of version clauses, separated by commas.

    -- PEP 440 – Version Identification and Dependency Specification