Python PDM backend complains about conflict which is not a conflict

167 views Asked by At

In my team, we are using PIP with PDM backend for managing our Python packages and we've run into a problem with PDM backend.

We've managed to reproduce with the following "mickey mouse" example.

Directory structure:

- package-a
  - pyproject.toml
- package-b
  - pyproject.toml

Contents of .toml file for package-a:

[build-system]
build-backend = "pdm.backend"
requires = [
  "pdm-backend >= 2.1.6"
]

[project]
authors = [
  {name = "author"},
]
dependencies = []
description = "test"
name = "package-a"
version = "0.0.0"

Contents of .toml file for package-b is the same as for package-a except this dependency:

dependencies = [
  # Works
  #"package-a @ file:///C:/temp/pythontest/pdm/package-a",
  # Fails
  "package-a @ file:///${PROJECT_ROOT}/../package-a",
]

As you see, there is a dependency from package-b to package-a. If we try to write this dependency using $(PROJECT_ROOT}/../, it fails. With absolute path, it works.

Log:

C:\temp\pythontest\pdm>pip install ./package-a ./package-b
Processing c:\temp\pythontest\pdm\package-a
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Processing c:\temp\pythontest\pdm\package-b
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Processing c:\temp\pythontest\pdm\package-a (from package-b==0.0.0)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
INFO: pip is looking at multiple versions of package-b to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install package-a 0.0.0 (from C:\temp\pythontest\pdm\package-a) and package-b==0.0.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested package-a 0.0.0 (from C:\temp\pythontest\pdm\package-a)
    package-b 0.0.0 depends on package-a 0.0.0 (from C:\temp\pythontest\pdm\package-b\..\package-a)

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Any ideas? Is this a bug in PDM backend?

0

There are 0 answers