1

I have a package which has a complex web of dependencies. I need to publish this on PyPI; it's not designed as an end-user application. However, when I install the package, I get messages such as INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.. Often this goes on for longer than an hour, and I have to kill the installation process.

However, none of this happens if I pip install my_package --use-deprecated=legacy-resolver. This is fine for development, but once I publish on PyPI, my users will have to use --use-deprecated=legacy-resolver if they want it to ever install.

I could introduce arbitrary version constraints to help the resolver as suggested by Pip, but I don't actually want to constrain versions unnecessarily, because this will limit the compatibility of my package. And in any case I have tried doing this and limiting the dependency ranges of a few packages doesn't help, because most of the problematic dependencies are transitive dependencies - dependencies of dependencies. I don't want to declare these in my pyproject.toml because I don't actually use them myself.

Is there an official way to declare that I want to use a different dependency resolver for my package, such as the legacy one? Does PEP 517 make this possible? Or is this a core limitation of the Python ecosystem? Can I use a lockfile or constraint file for a published package to hint to the resolver which versions to use without restricting it?

Migwell
  • 18,631
  • 21
  • 91
  • 160
  • 1
    Dependency resolvers are chosen by the user, not by the package. Imagine if *your dependencies* wanted to override your choice to use the legacy resolver to work around the issue you're experiencing! Anyway, what version of Pip are you using? Does https://stackoverflow.com/questions/65122957 answer your question? – Karl Knechtel Jul 28 '23 at 03:13
  • Also keep in mind that your clients could install the package with other tools, such as Poetry or Flit, which include their own dependency resolution. This is especially the case if they have your package as a dependency listed in their own `pyproject.toml` or legacy `setup.py`, rather than just installing your package directly for use in one-offs. – Karl Knechtel Jul 28 '23 at 03:18

0 Answers0