[x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
OS version and name: macOS 1015.3 Catalina
Running poetry add Naked results in an AssertionError
$ poetry add -vvv Naked
Using virtualenv: /Users/someuser/Library/Caches/pypoetry/virtualenvs/poetry-test-oO20IG-_-py3.6
PyPI: No release information found for Naked-0.1.9, skipping
PyPI: 19 packages found for Naked *
Using version ^0.1.31 for Naked
Updating dependencies
Resolving dependencies...
1: fact: poetry-test is 0.1.0
1: derived: poetry-test
1: fact: poetry-test depends on Naked (^0.1.31)
1: fact: poetry-test depends on pytest (^5.2)
1: fact: poetry-test depends on pytest (^5.2)
1: selecting poetry-test (0.1.0)
1: derived: pytest (^5.2)
1: derived: Naked (^0.1.31)
PyPI: 11 packages found for pytest >=5.2,<6.0
PyPI: No release information found for naked-0.1.9, skipping
PyPI: 1 packages found for naked >=0.1.31,<0.2.0
1: Version solving took 0.030 seconds.
1: Tried 1 solutions.
[AssertionError]
Traceback (most recent call last):
File "/Users/someuser/.poetry/lib/poetry/_vendor/py3.6/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/Users/someuser/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/Users/someuser/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/Users/someuser/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "/Users/someuser/.poetry/lib/poetry/console/commands/add.py", line 149, in handle
status = installer.run()
File "/Users/someuser/.poetry/lib/poetry/installation/installer.py", line 74, in run
self._do_install(local_repo)
File "/Users/someuser/.poetry/lib/poetry/installation/installer.py", line 161, in _do_install
ops = solver.solve(use_latest=self._whitelist)
File "/Users/someuser/.poetry/lib/poetry/puzzle/solver.py", line 36, in solve
packages, depths = self._solve(use_latest=use_latest)
File "/Users/someuser/.poetry/lib/poetry/puzzle/solver.py", line 181, in _solve
self._package, self._provider, locked=locked, use_latest=use_latest
File "/Users/someuser/.poetry/lib/poetry/mixology/__init__.py", line 7, in resolve_version
return solver.solve()
File "/Users/someuser/.poetry/lib/poetry/mixology/version_solver.py", line 80, in solve
next = self._choose_package_version()
File "/Users/someuser/.poetry/lib/poetry/mixology/version_solver.py", line 381, in _choose_package_version
for incompatibility in self._provider.incompatibilities_for(version):
File "/Users/someuser/.poetry/lib/poetry/puzzle/provider.py", line 529, in incompatibilities_for
for dep in dependencies
File "/Users/someuser/.poetry/lib/poetry/puzzle/provider.py", line 529, in <listcomp>
for dep in dependencies
File "/Users/someuser/.poetry/lib/poetry/mixology/incompatibility.py", line 60, in __init__
assert by_ref[ref] is not None
Update:
I discovered why this is occurring: There's a reported issue where Naked was listed as a dependency in its own package requirements: https://github.com/chrissimpkins/naked/issues/19
The fix is in master but not released (as of 0.1.31)
I have the same problem with adding my package with poetry add. This assertion error is not informative in the slightest. If it would at least say which package has cyclic dependency it would be more useful.
I have a dependency on datatable which has a dependency on typesentry which states inself in install_requires.
I was able to find this installing my package into a clear venv and using pipdeptree which gave me
Warning!! Cyclic dependencies found:
* typesentry => typesentry => typesentry
But is there another solution rather than making PRs to each individual package to fix this? This dependency loop is trivial and can be ignored on poetry level. Wouldn't it be better solution?
poetry add -vvv pystray meets the same problem.
Using virtualenv: /Users/abaaba/Library/Caches/pypoetry/virtualenvs/pystray-jVTnuic3-py3.7
PyPI: No release information found for pystray-0.1, skipping
PyPI: 24 packages found for pystray *
Using version ^0.16.0 for pystray
Updating dependencies
Resolving dependencies...
1: fact: pystray is 0.1.0
1: derived: pystray
1: Version solving took 0.005 seconds.
1: Tried 1 solutions.
[AssertionError]
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/usr/local/lib/python3.7/site-packages/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/usr/local/lib/python3.7/site-packages/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/usr/local/lib/python3.7/site-packages/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "/usr/local/lib/python3.7/site-packages/poetry/console/commands/add.py", line 156, in handle
status = installer.run()
File "/usr/local/lib/python3.7/site-packages/poetry/installation/installer.py", line 74, in run
self._do_install(local_repo)
File "/usr/local/lib/python3.7/site-packages/poetry/installation/installer.py", line 161, in _do_install
ops = solver.solve(use_latest=self._whitelist)
File "/usr/local/lib/python3.7/site-packages/poetry/puzzle/solver.py", line 36, in solve
packages, depths = self._solve(use_latest=use_latest)
File "/usr/local/lib/python3.7/site-packages/poetry/puzzle/solver.py", line 181, in _solve
self._package, self._provider, locked=locked, use_latest=use_latest
File "/usr/local/lib/python3.7/site-packages/poetry/mixology/__init__.py", line 7, in resolve_version
return solver.solve()
File "/usr/local/lib/python3.7/site-packages/poetry/mixology/version_solver.py", line 80, in solve
next = self._choose_package_version()
File "/usr/local/lib/python3.7/site-packages/poetry/mixology/version_solver.py", line 392, in _choose_package_version
self._add_incompatibility(incompatibility)
File "/usr/local/lib/python3.7/site-packages/poetry/mixology/version_solver.py", line 431, in _add_incompatibility
self._log('fact: {}'.format(incompatibility))
File "/usr/local/lib/python3.7/site-packages/poetry/mixology/incompatibility.py", line 111, in __str__
assert len(self._terms) == 2
I think that I get the same problem with networkx.
$ poetry add networkx -vvv
Using virtualenv: /home/matheusr42/.cache/pypoetry/virtualenvs/networkx-E6832TF_-py3.8
PyPI: No release information found for networkx-0.23, skipping
PyPI: No release information found for networkx-0.24, skipping
PyPI: No release information found for networkx-0.25, skipping
PyPI: No release information found for networkx-0.26, skipping
PyPI: No release information found for networkx-0.27, skipping
PyPI: No release information found for networkx-0.28, skipping
PyPI: No release information found for networkx-0.29, skipping
PyPI: No release information found for networkx-0.30, skipping
PyPI: No release information found for networkx-0.31, skipping
PyPI: No release information found for networkx-0.32, skipping
PyPI: No release information found for networkx-0.33, skipping
PyPI: 27 packages found for networkx *
Using version ^2.5 for networkx
Updating dependencies
Resolving dependencies...
1: fact: networkx is 0.1.0
1: derived: networkx
1: Version solving took 0.002 seconds.
1: Tried 1 solutions.
Stack trace:
13 ~/.poetry/lib/poetry/_vendor/py3.8/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
12 ~/.poetry/lib/poetry/_vendor/py3.8/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():
11 ~/.poetry/lib/poetry/_vendor/py3.8/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
10 ~/.poetry/lib/poetry/_vendor/py3.8/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]
9 ~/.poetry/lib/poetry/console/commands/add.py:174 in handle
172โ
173โ try:
โ 174โ status = self._installer.run()
175โ except Exception:
176โ self.poetry.file.write(original_content)
8 ~/.poetry/lib/poetry/installation/installer.py:99 in run
97โ local_repo = Repository()
98โ
โ 99โ return self._do_install(local_repo)
100โ
101โ def dry_run(self, dry_run=True): # type: (bool) -> Installer
7 ~/.poetry/lib/poetry/installation/installer.py:205 in _do_install
203โ )
204โ
โ 205โ ops = solver.solve(use_latest=self._whitelist)
206โ else:
207โ self._io.write_line("Installing dependencies from lock file")
6 ~/.poetry/lib/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โ
5 ~/.poetry/lib/poetry/puzzle/solver.py:233 in _solve
231โ
232โ try:
โ 233โ result = resolve_version(
234โ self._package, self._provider, locked=locked, use_latest=use_latest
235โ )
4 ~/.poetry/lib/poetry/mixology/__init__.py:7 in resolve_version
5โ solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
6โ
โ 7โ return solver.solve()
8โ
3 ~/.poetry/lib/poetry/mixology/version_solver.py:84 in solve
82โ while next is not None:
83โ self._propagate(next)
โ 84โ next = self._choose_package_version()
85โ
86โ return self._result()
2 ~/.poetry/lib/poetry/mixology/version_solver.py:401 in _choose_package_version
399โ conflict = False
400โ for incompatibility in self._provider.incompatibilities_for(version):
โ 401โ self._add_incompatibility(incompatibility)
402โ
403โ # If an incompatibility is already satisfied, then selecting version
1 ~/.poetry/lib/poetry/mixology/version_solver.py:442 in _add_incompatibility
440โ
441โ def _add_incompatibility(self, incompatibility): # type: (Incompatibility) -> None
โ 442โ self._log("fact: {}".format(incompatibility))
443โ
444โ for term in incompatibility.terms:
AssertionError
at ~/.poetry/lib/poetry/mixology/incompatibility.py:111 in __str__
107โ )
108โ
109โ def __str__(self):
110โ if isinstance(self._cause, DependencyCause):
โ 111โ assert len(self._terms) == 2
112โ
113โ depender = self._terms[0]
114โ dependee = self._terms[1]
115โ assert depender.is_positive()
@MadHatt3rs this succeeds for me in 1.1.0
$ [email protected] add networkx
Using version ^2.5 for networkx
Updating dependencies
Resolving dependencies... (0.1s)
Writing lock file
Package operations: 2 installs, 0 updates, 0 removals
โข Installing decorator (4.4.2)
โข Installing networkx (2.5)
@gaozhidf so does pystray
$ [email protected] add pystray
Using version ^0.17.1 for pystray
Updating dependencies
Resolving dependencies... (1.2s)
Writing lock file
Package operations: 4 installs, 0 updates, 0 removals
โข Installing six (1.15.0)
โข Installing pillow (7.2.0)
โข Installing python-xlib (0.28)
โข Installing pystray (0.17.1)
Regardig the assertion error, I agree this needs to be improved.
@abn , I was using version 1.1.0, but I realized that the problem is that I created a new project with same name of the package. I did this :sweat_smile: :
$ poetry new networkx
Created package networkx in networkx
$ cd networkx/
$ poetry add networkx
Creating virtualenv networkx-ij1fzQR9-py3.8 in /home/matheusr42/.cache/pypoetry/virtualenvs
Using version ^2.5 for networkx
Updating dependencies
Resolving dependencies... (0.0s)
AssertionError
at ~/.poetry/lib/poetry/mixology/incompatibility.py:111 in __str__
107โ )
108โ
109โ def __str__(self):
110โ if isinstance(self._cause, DependencyCause):
โ 111โ assert len(self._terms) == 2
112โ
113โ depender = self._terms[0]
114โ dependee = self._terms[1]
115โ assert depender.is_positive()
I tried with another project name and it works, thanks! :grin: I think that it is not a big problem, but will be nice if there is a warn message.
@sdispater can we get these, original issue and cyclic dependencies, propagated as a SolverError?
@MatheusR42 I did the same mistake as you did! Silly for sure, but would be nice if there was an alternative error handling when installing a package that has the same name as the project ๐
I made the same mistake as @MatheusR42. I wanted to play around with py2app so I made a project callec py2app. I didn't know that would break things. Certainly would appreciate a better message than the line 111 AssertionError. Love Poetry otherwise though :)
Most helpful comment
@abn , I was using version 1.1.0, but I realized that the problem is that I created a new project with same name of the package. I did this :sweat_smile: :
I tried with another project name and it works, thanks! :grin: I think that it is not a big problem, but will be nice if there is a warn message.