avast / pytest-docker

Docker-based integration tests
MIT License
427 stars 71 forks source link

Version Conflict with PyYAML 6.0 #70

Closed PJ-Schulz closed 2 years ago

PJ-Schulz commented 2 years ago

Hello

I would like to use pytest-docker in my library. However, I also need PyYAML with version 6.0. poetry is used as package manager. When I now install pytest-docker and PyYAML, I get a poetry SolverProblemError:

p@ubuntu:~/repos/testsrepos/dockerpytest$ poetry add pyyaml pytest-docker
Using version ^6.0 for PyYAML
Using version ^0.10.3 for pytest-docker

Updating dependencies
Resolving dependencies... (0.5s)

  SolverProblemError

  Because no versions of docker-compose match >1.27.3,<1.27.4 || >1.27.4,<1.28.0 || >1.28.0,<1.28.2 || >1.28.2,<1.28.3 || >1.28.3,<1.28.4 || >1.28.4,<1.28.5 || >1.28.5,<1.28.6 || >1.28.6,<1.29.0 || >1.29.0,<1.29.1 || >1.29.1,<1.29.2 || >1.29.2,<2.0
   and docker-compose (1.27.3) depends on PyYAML (>=3.10,<6), docker-compose (>=1.27.3,<1.27.4 || >1.27.4,<1.28.0 || >1.28.0,<1.28.2 || >1.28.2,<1.28.3 || >1.28.3,<1.28.4 || >1.28.4,<1.28.5 || >1.28.5,<1.28.6 || >1.28.6,<1.29.0 || >1.29.0,<1.29.1 || >1.29.1,<1.29.2 || >1.29.2,<2.0) requires PyYAML (>=3.10,<6).
  And because docker-compose (1.27.4) depends on PyYAML (>=3.10,<6)
   and docker-compose (1.28.0) depends on PyYAML (>=3.10,<6), docker-compose (>=1.27.3,<1.28.2 || >1.28.2,<1.28.3 || >1.28.3,<1.28.4 || >1.28.4,<1.28.5 || >1.28.5,<1.28.6 || >1.28.6,<1.29.0 || >1.29.0,<1.29.1 || >1.29.1,<1.29.2 || >1.29.2,<2.0) requires PyYAML (>=3.10,<6).
  And because docker-compose (1.28.2) depends on PyYAML (>=3.10,<6)
   and docker-compose (1.28.3) depends on PyYAML (>=3.10,<6), docker-compose (>=1.27.3,<1.28.4 || >1.28.4,<1.28.5 || >1.28.5,<1.28.6 || >1.28.6,<1.29.0 || >1.29.0,<1.29.1 || >1.29.1,<1.29.2 || >1.29.2,<2.0) requires PyYAML (>=3.10,<6).
  And because docker-compose (1.28.4) depends on PyYAML (>=3.10,<6)
   and docker-compose (1.28.5) depends on PyYAML (>=3.10,<6), docker-compose (>=1.27.3,<1.28.6 || >1.28.6,<1.29.0 || >1.29.0,<1.29.1 || >1.29.1,<1.29.2 || >1.29.2,<2.0) requires PyYAML (>=3.10,<6).
  And because docker-compose (1.28.6) depends on PyYAML (>=3.10,<6)
   and docker-compose (1.29.0) depends on PyYAML (>=3.10,<6), docker-compose (>=1.27.3,<1.29.1 || >1.29.1,<1.29.2 || >1.29.2,<2.0) requires PyYAML (>=3.10,<6).
  And because docker-compose (1.29.1) depends on PyYAML (>=3.10,<6)
   and docker-compose (1.29.2) depends on PyYAML (>=3.10,<6), docker-compose (>=1.27.3,<2.0) requires PyYAML (>=3.10,<6).
  Because no versions of pytest-docker match >0.10.3,<0.11.0
   and pytest-docker (0.10.3) depends on docker-compose (>=1.27.3,<2.0), pytest-docker (>=0.10.3,<0.11.0) requires docker-compose (>=1.27.3,<2.0).
  Thus, pytest-docker (>=0.10.3,<0.11.0) requires PyYAML (>=3.10,<6).
  So, because dockerpytest depends on both PyYAML (^6.0) and pytest-docker (^0.10.3), version solving failed.

Does anyone know how to use pytest-docker with PyYAML 6.0, or how to fix this bug?

Luminaar commented 2 years ago

Hello, thank you for raising the issue.

There seems to be no easy solution ― the problem is in a transitive dependency that we have no control over (we depend on docker-compose which depends on pyyaml<6.0). One possible solution would be to submit an issue or PR to the docker-compose repository, though there is a new version of docker-compose which is not written in Python and I don't know how willing the devs will be to change the old version.

Another solution would be to use pyyaml<6.0 in your project, which of course might not be feasible if you depend on fixes from version 6 (from the changelog it seems that the main breaking change is removing support for Python2.7).

Finally, it might be possible to change pytest-docker in such a way to allow users to provide their own docker-compose installation instead of installing it directly. This will require a greater discussion as well as a major version bump.

PJ-Schulz commented 2 years ago

Thank for the detailed answer. The easiest way is to use a version of pyyaml<6.0 at the moment. But if there will be new features in pyyaml in the future, they cannot be used together with pytest-docker. So this is not the best solution.

Using a pre-installed docker-compose has the same dependency on pyyaml<6.0, unless someone uses their own version of docker-compose or a version >2.

I have opened an issue on docker/compose to update the dependency to 6.0 : https://github.com/docker/compose/issues/9114

otetard commented 2 years ago

An attempt to not strictly depend on Docker Compose (and not on PyYAML either) is provided in this PR: #72.

n1ngu commented 2 years ago

Fixed by #72, would you please close the issue @PJ-Schulz ?