python-poetry / python-poetry/poetry

Improve dependency source_url equality check to use normalised urls instead of given/derrived values

Open
#3,113 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Issue

ptry-project has the following project dependency graph:

ptry-project -+-> ptry-lib --> ptry-helper
              \-> ptry-helper

ptry-project is a poetry project. ptry-lib and ptry-helper both use setup.py. All of the dependencies are specified using git URLs and point to a specific git commit hash.

Latest poetry (last working version was 1.0.10) fails when running poetry update in ptry-project. verbose log output:

ptry-project ─╼ poetry@local update -vvv                                                                             0
Using virtualenv: /Users/martynas/Library/Caches/pypoetry/virtualenvs/ptry-project-3Lsr60E6-py3.8
Updating dependencies
Resolving dependencies...
   1: fact: ptry-project is 0.1.0
   1: derived: ptry-project
   1: fact: ptry-project depends on ptry-helper (0.1.0 git rev 047f569)
   1: fact: ptry-project depends on ptry-lib (0.1.0 git rev 3665750)
   1: fact: ptry-project depends on pytest (^5.2)
   1: fact: ptry-project depends on pytest (^5.2)
   1: selecting ptry-project (0.1.0)
   1: derived: pytest (^5.2)
   1: derived: ptry-lib (0.1.0 git rev 3665750)
   1: derived: ptry-helper (0.1.0 git rev 047f569)
PyPI: 15 packages found for pytest >=5.2,<6.0
   1: fact: ptry-lib (0.1.0 git rev 3665750) depends on ptry-helper (0.1.0 git rev 047f569)
   1: conflict: ptry-lib (0.1.0 git rev 3665750) depends on ptry-helper (0.1.0 git rev 047f569)
   1: ! not ptry-helper (0.1.0 git rev 047f569) is satisfied by ptry-helper (0.1.0 git rev 047f569)
   1: ! which is caused by "ptry-project depends on ptry-helper (0.1.0 git rev 047f569)"
   1: ! thus: ptry-lib is forbidden
   1: ! ptry-lib (0.1.0 git rev 3665750) is satisfied by ptry-lib (0.1.0 git rev 3665750)
   1: ! which is caused by "ptry-project depends on ptry-lib (0.1.0 git rev 3665750)"
   1: ! thus: version solving failed
   1: Version solving took 23.160 seconds.
   1: Tried 1 solutions.

Stack trace:

8 ~/Library/Caches/pypoetry/virtualenvs/poetry-RboxO2pV-py3.8/lib/python3.8/site-packages/clikit/console_application.py:131 in run
129│ parsed_args = resolved_command.args
130│
→ 131│ status_code = command.handle(parsed_args, io)
132│ except KeyboardInterrupt:
133│ status_code = 1

7 ~/Library/Caches/pypoetry/virtualenvs/poetry-RboxO2pV-py3.8/lib/python3.8/site-packages/clikit/api/command/command.py:120 in handle
118│ def handle(self, args, io): # type: (Args, IO) -> int
119│ try:
→ 120│ status_code = self._do_handle(args, io)
121│ except KeyboardInterrupt:
122│ if io.is_debug():

6 ~/Library/Caches/pypoetry/virtualenvs/poetry-RboxO2pV-py3.8/lib/python3.8/site-packages/clikit/api/command/command.py:171 in _do_handle
169│ handler_method = self._config.handler_method
170│
→ 171│ return getattr(handler, handler_method)(args, io, self)
172│
173│ def repr(self): # type: () -> str

5 ~/Library/Caches/pypoetry/virtualenvs/poetry-RboxO2pV-py3.8/lib/python3.8/site-packages/cleo/commands/command.py:92 in wrap_handle
90│ self._command = command
91│
→ 92│ return self.handle()
93│
94│ def handle(self): # type: () -> Optional[int]

4 ~/projects/poetry/poetry/console/commands/update.py:47 in handle
45│ self._installer.update(True)
46│
→ 47│ return self._installer.run()
48│

3 ~/projects/poetry/poetry/installation/installer.py:103 in run
101│ local_repo = Repository()
102│
→ 103│ return self._do_install(local_repo)
104│
105│ def dry_run(self, dry_run=True): # type: (bool) -> Installer

2 ~/projects/poetry/poetry/installation/installer.py:235 in _do_install
233│ )
234│
→ 235│ ops = solver.solve(use_latest=self._whitelist)
236│ else:
237│ self._io.write_line("Installing dependencies from lock file")

1 ~/projects/poetry/poetry/puzzle/solver.py:65 in solve
63│ with self._provider.progress():
64│ start = time.time()
→ 65│ packages, depths = self._solve(use_latest=use_latest)
66│ end = time.time()
67│

SolverProblemError

Because ptry-lib (0.1.0 git rev 3665750) depends on ptry-helper (0.1.0 git rev 047f569)
and ptry-project depends on ptry-helper (0.1.0 git rev 047f569), ptry-lib is forbidden.
So, because ptry-project depends on ptry-lib (0.1.0 git rev 3665750), version solving failed.

at ~/projects/poetry/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

This was previously discussed a bit in: https://github.com/python-poetry/poetry/issues/3030#issuecomment-704288487

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the dependency resolution failure with the linked ptry-project using poetry update -vvv, then start from poetry/puzzle/solver.py and the installer entry point in poetry/installation/installer.py. Compare the dependency source URLs involved in the ptry-lib and ptry-helper graph; done means the shared git dependency is recognized as satisfied and resolution succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.