poetry: poetry add "requests[security]" fails on Poetry 1.2.0b1

If I run poetry add "requests[security]" on Poetry 1.2.0b1, it fails with this message:

Package ‘requests’ is listed as a dependency of itself.

I downgraded to Poetry 1.1.13 where it works. Thanks for all your work!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

https://github.com/python-poetry/poetry/blob/89e3f7ba019e89c0901215d97e8af3694291cb28/src/poetry/puzzle/solver.py#L166-L173

I think that needs to become (seems to work for me)

                    if (
                        not _package.features
                        and package.provides(_package)
                        and _package.version == package.version
                    ):
                        for dep in package.requires:
                            # Prevent adding base package as a dependency to itself
                            if _package.provides(dep):
                                continue

is_same_package_as() compares sources. The x dependency that gets added to x[y] gets created out of thin air and has no source because of it. Causing it to not be considered the same package.

dep has no source, _package can have a source. When _package has a source they are not considered the same package. This explains why it works when you remove the source.

Since that if is inside another if that tests whether it has features or not provides() seems to be a better choice than is_same_package_as() since it only compares the names and features.