Apologies if this has been answered elsewhere… was unable to find this specific use case.
We have a package that uses
qtpy to support either
PyQt5 backends, but one of the two must be installed. If possible, we’d like to make our package installable simply with
pip install my-package and have
PySide2 installed if and only if
PyQt5 does not already exist in the environment. I am aware that we could use extras and ask our users to
pip install my-package[pyside2] … but if at all possible, we’d like to have the bare install work without requiring the extras syntax, while also preventing both qt backends from being installed (if a user already has one of them in their environment).
(we’d also prefer to avoid having a seperate
my-package-core package with no dependencies, with
my-package depending on both
We initially attempted to achieve this by putting
try: import PyQt5 logic in
setup.py, but that strategy seems to fail (unless the end-user uses the
--no-cache-dir) when pip builds a wheel for caching during the install step. PEP 508 markers also do not appear to allow this sort of environmental inquiry.
Any input greatly appreciated (even if it’s just “yeah you can’t do that” )