Poetry: Adding a package with the same name as your local package results in an AssertionError

Created on 19 Jun 2018  路  9Comments  路  Source: python-poetry/poetry

Yes, this is my own stupid fault :)
Maybe a sanity check somewhere could be helpful?

The local pyproject.toml file specifies 'kek.tilde' and the one in the git repo does as well. Then the following trace happens.

$ poetry add kek.tilde --git https://gitlab.com/snuk/kek.tilde.git -v
Using virtualenv: /Users/roel/Library/Caches/pypoetry/virtualenvs/kek.tilde-py3.6

Updating dependencies
Resolving dependencies... (0.0s)

[AssertionError]

Exception trace:
 /usr/local/lib/python3.6/site-packages/poetry/_vendor/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /usr/local/lib/python3.6/site-packages/poetry/console/application.py in do_run() at line 87
   return super(Application, self).do_run(i, o)
 /usr/local/lib/python3.6/site-packages/poetry/_vendor/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /usr/local/lib/python3.6/site-packages/poetry/console/commands/command.py in run() at line 72
   return super(BaseCommand, self).run(i, o)
 /usr/local/lib/python3.6/site-packages/poetry/_vendor/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 /usr/local/lib/python3.6/site-packages/poetry/_vendor/cleo/commands/command.py in execute() at line 107
   return self.handle()
 /usr/local/lib/python3.6/site-packages/poetry/console/commands/add.py in handle() at line 134
   status = installer.run()
 /usr/local/lib/python3.6/site-packages/poetry/installation/installer.py in run() at line 75
   self._do_install(local_repo)
 /usr/local/lib/python3.6/site-packages/poetry/installation/installer.py in _do_install() at line 158
   ops = solver.solve(use_latest=self._whitelist)
 /usr/local/lib/python3.6/site-packages/poetry/puzzle/solver.py in solve() at line 35
   self._package, provider, locked=locked, use_latest=use_latest
 /usr/local/lib/python3.6/site-packages/poetry/mixology/__init__.py in resolve_version() at line 8
   return solver.solve()
 /usr/local/lib/python3.6/site-packages/poetry/mixology/version_solver.py in solve() at line 79
   next = self._choose_package_version()
 /usr/local/lib/python3.6/site-packages/poetry/mixology/version_solver.py in _choose_package_version() at line 381
   for incompatibility in self._provider.incompatibilities_for(version):
 /usr/local/lib/python3.6/site-packages/poetry/puzzle/provider.py in incompatibilities_for() at line 293
   for dep in dependencies
 /usr/local/lib/python3.6/site-packages/poetry/puzzle/provider.py in <listcomp>() at line 293
   for dep in dependencies
 /usr/local/lib/python3.6/site-packages/poetry/mixology/incompatibility.py in __init__() at line 59
   assert by_ref[ref] is not None
Bug Dependency resolution Error Handling Good First Issue

Most helpful comment

Error handling with an explanation of what this assertion error is would be perfect!

So instead of

% poetry lock
Updating dependencies
Resolving dependencies... (0.0s)

[AssertionError]

or

% poetry lock -v
Using virtualenv: /home/pawamoy/.cache/pypoetry/virtualenvs/failprint--fnxWxWY-py3.8
Updating dependencies
Resolving dependencies... (0.0s)

[AssertionError]


Traceback (most recent call last):
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/console/commands/lock.py", line 28, in handle
    return installer.run()
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 180, in _solve
    result = resolve_version(
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/mixology/__init__.py", line 7, in resolve_version
    return solver.solve()
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/mixology/version_solver.py", line 80, in solve
    next = self._choose_package_version()
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/mixology/version_solver.py", line 381, in _choose_package_version
    for incompatibility in self._provider.incompatibilities_for(version):
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/puzzle/provider.py", line 524, in incompatibilities_for
    return [
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/puzzle/provider.py", line 525, in <listcomp>
    Incompatibility(
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/mixology/incompatibility.py", line 60, in __init__
    assert by_ref[ref] is not None

We would have something like

% poetry lock
Updating dependencies
Resolving dependencies... (0.0s)

[AssertionError]
Package 'my-super-package' is listed as a dependency of itself.
This is not supported by Poetry.

All 9 comments

Hey there! I just got into this today and I'd like to fix it :)

I just want to what's the expected behaviour. Should we allow the installation of the library itself or should we fail if a "Cannot install the library you are managing" message of some sorts.

What do you think?

@jonatasbaldin I don't know if this is still an issue, as a lot of work has been done since filing this.
Could you check if this is still the case?

Either way, please note that I'm not sure if solving dependency issues is an easy way to get involved in this project?

Yes, it still an issue. Just did a poetry install <mylib> and got the same error.

And yes, I tried to take a look around and it was a bit scary hah but if there's a philosophy on how to deal with this edge case, I'd be keen to give it a try :D

@jonatasbaldin I'm not using Poetry at the moment, so I have not stake in this.
pinging @sdispater

Error handling with an explanation of what this assertion error is would be perfect!

So instead of

% poetry lock
Updating dependencies
Resolving dependencies... (0.0s)

[AssertionError]

or

% poetry lock -v
Using virtualenv: /home/pawamoy/.cache/pypoetry/virtualenvs/failprint--fnxWxWY-py3.8
Updating dependencies
Resolving dependencies... (0.0s)

[AssertionError]


Traceback (most recent call last):
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/console/commands/lock.py", line 28, in handle
    return installer.run()
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 180, in _solve
    result = resolve_version(
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/mixology/__init__.py", line 7, in resolve_version
    return solver.solve()
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/mixology/version_solver.py", line 80, in solve
    next = self._choose_package_version()
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/mixology/version_solver.py", line 381, in _choose_package_version
    for incompatibility in self._provider.incompatibilities_for(version):
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/puzzle/provider.py", line 524, in incompatibilities_for
    return [
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/puzzle/provider.py", line 525, in <listcomp>
    Incompatibility(
  File "/home/pawamoy/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/mixology/incompatibility.py", line 60, in __init__
    assert by_ref[ref] is not None

We would have something like

% poetry lock
Updating dependencies
Resolving dependencies... (0.0s)

[AssertionError]
Package 'my-super-package' is listed as a dependency of itself.
This is not supported by Poetry.

Hey,

Is this still open? If yes, I would like to work on this.

Hey @avirlrma,

happy to see you like to contribute :+1: Feel free to start working on it. I'v assigned you to this issue.

fin swimmer

Thanks @finswimmer. Will update my progress here.

Sorry for the delay folks, will raise the PR in the coming two days.

Was this page helpful?
0 / 5 - 0 ratings