question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poetry unable to resolve dependency using asterisk wildcard (*)

See original GitHub issue

Issue

I’m noticing an issue with using a wildcard (*) for a version specification for a dependency in pyproject.toml. In this new project, I’m adding a dev dependency of black for code formatting. Generally I prefer to allow any version for this, so I’m attempting to use the wildcard syntax (docs). The docs seem to indicate that my example gist above should work, but poetry is having trouble resolving the dependency.

In searching for other issues, this seems similar to #1281, though that’s an older issue. I tried the mitigation steps at the end of that issue (deleting poetry.lock, etc) but it does not seem to help this case. I also noticed #2626, and I’m wondering if this is somehow related to that issue, perhaps a side effect. Opened this one separately though in case its a different issue.

Sample commands and output

When I try to do this via manual modification of pyproject.toml and using poetry install -vvv, I see the following output:

Using virtualenv: /home/matt/.cache/pypoetry/virtualenvs/example-k3bGbc8x-py3.8
Updating dependencies
Resolving dependencies...
   1: fact: example is 0.1.0
   1: derived: example
   1: fact: example depends on django (~2.2)
   1: fact: example depends on black (*)
   1: fact: example depends on black (*)
   1: selecting example (0.1.0)
   1: derived: black (*)
   1: derived: django (~2.2)
   1: fact: no versions of black match *
   1: conflict: no versions of black match *
   1: ! black (*) is satisfied by black (*)
   1: ! which is caused by "example depends on black (*)"
   1: ! thus: version solving failed
   1: Version solving took 0.017 seconds.
   1: Tried 1 solutions.

[SolverProblemError]
Because example depends on black (*) which doesn't match any versions, version solving failed.

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/usr/lib/python3.8/site-packages/poetry/console/commands/install.py", line 69, in handle
    return_code = installer.run()
  File "/usr/lib/python3.8/site-packages/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/usr/lib/python3.8/site-packages/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/usr/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/usr/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 190, in _solve
    raise SolverProblemError(e)

Alternatively, I also attempted to let poetry add the dependency using poetry add --dev -vvv black="*". The PyPI lines below seem particularly suspect, so maybe this is related to poetry’s PyPI interaction in the wildcard case. In this case, I see the following output:

Using virtualenv: /home/matt/.cache/pypoetry/virtualenvs/example-k3bGbc8x-py3.8
PyPI: 20 packages found for black *

Updating dependencies
Resolving dependencies...
   1: fact: example is 0.1.0
   1: derived: example
   1: fact: example depends on django (~2.2)
   1: fact: example depends on black (*)
   1: fact: example depends on black (*)
   1: selecting example (0.1.0)
   1: derived: black (*)
   1: derived: django (~2.2)
PyPI: No release information found for django-1.0.1, skipping
PyPI: No release information found for django-1.0.2, skipping
PyPI: No release information found for django-1.0.3, skipping
PyPI: No release information found for django-1.0.4, skipping
PyPI: No release information found for django-1.1, skipping
PyPI: No release information found for django-1.1.1, skipping
PyPI: No release information found for django-1.1.2, skipping
PyPI: 15 packages found for django >=2.2,<2.3
PyPI: 0 packages found for black *
   1: fact: no versions of black match *
   1: conflict: no versions of black match *
   1: ! black (*) is satisfied by black (*)
   1: ! which is caused by "example depends on black (*)"
   1: ! thus: version solving failed
   1: Version solving took 0.018 seconds.
   1: Tried 1 solutions.

[SolverProblemError]
Because example depends on black (*) which doesn't match any versions, version solving failed.

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/usr/lib/python3.8/site-packages/poetry/console/commands/add.py", line 149, in handle
    status = installer.run()
  File "/usr/lib/python3.8/site-packages/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/usr/lib/python3.8/site-packages/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/usr/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/usr/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 190, in _solve
    raise SolverProblemError(e)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
matthewarmandcommented, Apr 21, 2021

Probably yeah. I’d just left it open until a maintainer popped in but that hasn’t happened, and since it seems to have been incidentally fixed as of 1.1.x, seems it can be closed.

0reactions
mdenglercommented, Apr 21, 2021

Looks like I was just on an old version (thought I had updated to the latest but clearly not). So this bug can be closed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't I install a Python package with the ... - Stack Overflow
It would make my Poetry project's Python version match the Python requirement of the dependency exactly. I found that if I changed my...
Read more >
Dependency specification | Documentation | Poetry - Python ...
Wildcard requirements allow for the latest (dependency dependent) version where ... When adding dependencies via poetry add , you can use the @...
Read more >
A Poetic Apology. Or Why Should You Use Poetry to Manage…
Feeling now betrayed by pip's apparent inability to resolve dependencies, you rollback your changes and stick with Pandas' (now) outdated version.
Read more >
Ask HN: Why Poetry did not become a mainstream package ...
Personally, I use pipenv (manages package dependencies and sub-dependencies), pyenv (python version management), and pyenv-virtualenv (creates ...
Read more >
Pandoc User's Guide
(Use --file-scope to parse files individually.) Specifying formats. The format of the input and output can be specified explicitly using command-line options.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found