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 cache clear` should be able to clear all information for a single package

See original GitHub issue
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

Thanks for making an awesome product.

In my project, I split my code to several packages, which are published to pypi. The problem is after I upload a new version of a package on pypi, poetry doesn’t know that the package has been updated and throw SolverProblemError (depends on package X which doesn’t match any versions) if I use the updated package somewhere else.

I think this may be due caching. Clearing poetry cache: poetry cache clear pypi --all does help me solve the problem. However, it’s so slow as poetry has to repopulate the cache for all other packages.

I think it would be great to have:

  • the ability to invalidate/clear cache of specific packages, or
  • automatically fetch new version of a package if the requested version is newer than the current one in the cache or when it fails to resolve dependencies.

Thanks!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:8
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dusktreadercommented, Mar 29, 2022

After digging into the source, it turns out you can delete an entry for a specific version of a package:

$ poetry cache clear pypi:snick:1.2.0

However, this will not help you in this case because Poetry is using the cached package info: https://github.com/python-poetry/poetry/blob/master/src/poetry/repositories/pypi_repository.py#L204

So, I think the cache clear command needs a way to tell it to purge the package info from the cache instead.

May tinker with this a bit and see if I can throw together a PR for this functionality.

1reaction
jediecommented, Jul 24, 2022

The problem is after I upload a new version of a package on pypi, poetry doesn’t know that the package has been updated

I confirm this (Poetry v1.1.14), because i have the same trouble again and again. e.g.:

~/repos/pyinventory_ynh$ poetry update 
Updating dependencies
Resolving dependencies... (4.9s)

  SolverProblemError

  Because pyinventory-ynh depends on pyinventory (>=0.14.0rc1) which doesn't match any versions, version solving failed.

  at ~/.local/lib/python3.9/site-packages/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

Poetry didn’t find it

~/repos/pyinventory_ynh$ poetry update -vvv
...
PyPI: 0 packages found for pyinventory >=0.14.0rc1
   1: fact: no versions of pyinventory match >=0.14.0rc1
   1: conflict: no versions of pyinventory match >=0.14.0rc1
   1: !  pyinventory (>=0.14.0rc1) is satisfied by  pyinventory (>=0.14.0rc1)
   1: ! which is caused by "pyinventory-ynh depends on pyinventory (>=0.14.0rc1)"
   1: ! thus: version solving failed
   1: Version solving took 0.182 seconds.
   1: Tried 1 solutions.
...

pip found it:

~/repos/pyinventory_ynh$ poetry run pip install "pyinventory>=0.14.0rc1"
Collecting pyinventory>=0.14.0rc1
  Downloading PyInventory-0.14.0rc1-py3-none-any.whl (120 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 120.5/120.5 kB 4.9 MB/s eta 0:00:00
...
Installing collected packages: pyinventory
  Attempting uninstall: pyinventory
    Found existing installation: pyinventory 0.13.0
    Uninstalling pyinventory-0.13.0:
      Successfully uninstalled pyinventory-0.13.0
Successfully installed pyinventory-0.14.0rc1

It exists: https://pypi.org/project/pyinventory/0.14.0rc1/ Note: it’s not related to the version scheme: I tested 0.14.0rc1 and 0.14.0.rc1 and 0.14.0rc2 (This is just a example. I see the same behavior in other constellation, after a new release published to PyPi)

rm -Rf ~/.cache/pypoetry/cache/ helps here, sometimes, but often not.

poetry run pip install -U <PackageName> will often install the version i need, but poerty didn’t find it. So i assume it’s there and public on PyPi.

Also boring: The error message like Because <foo> depends on <bar> (>=0.14.0rc1) which doesn't match any versions, version solving failed. if not very helpfull 😦

pipenv has a little bit better error message, because it lists all found versions.

EDIT: Adding allow-prereleases = true (see also: https://github.com/python-poetry/poetry/issues/4405 ) doesn’t help here, too.

EDIT2: Maybe duplicated by https://github.com/python-poetry/poetry/issues/3543 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Commands | master | Documentation | Poetry - Python ...
The cache clear command removes packages from a cached repository. For example, to clear the whole cache of packages from the pypi repository,...
Read more >
'poetry install' command fails; *.whl files are not found
It seems to be related to poetry cache. For me, it works as intended if i go to User\user\AppData\Local\pypoetry and I delete the...
Read more >
Pipeline caching - Azure - Microsoft Learn
Pipeline caching can help reduce build time by allowing the outputs or downloaded dependencies from one run to be reused in later runs, ......
Read more >
Configure a Poetry environment | PyCharm Documentation
Poetry is a tool that facilitates creating a Python virtual environment based on the project dependencies. You can declare the libraries your project ......
Read more >
Dependency management - Synapse - GitHub Pages
Clear caches : poetry cache clear --all pypi . Poetry caches a bunch of information about packages that isn't readily available from PyPI....
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