Search code examples
pythonpipdependenciesdependency-managementpython-wheel

Python wheel anti-dependency


I'm managing a python project which can be released in two different variants, "full" and "lightweight", called e.g. my-project and my-project-lw. Both use the same top-level name, e.g. myproject. I have a script that cuts off the "heavy" parts of the project and builds both wheel installable archives with dependencies (the lightweight has considerably fewer). Everything works, and I can install them using the wheels.

Now I would like to make sure that a user wouldn't have both packages installed at the same time. Ideally I'd like pip to uninstall one when installing the other, or at least fail when the other is present (such that the user would have to uninstall the current manually).

Otherwise, when you install the my-project package it installs into /lib/python3.6/site-packages/myproject, and then when you install the my-project-lw package it overwrites the files in the same folder so you get a weird hybrid when some file are from "full" and some from "lightweigth", which is not good.

Is there a way to specify an anti-dependency? To mark them somehow as mutually exclusive? Thanks!


Solution

  • Pip doesn't support it. See also the related 'obsoletes' metadata. https://github.com/pypa/packaging-problems/issues/154