Suggestion to make RDkit dependency optional
RalfG opened this issue · 3 comments
Hi Wout,
I recently added spectrum_utils plotting to MS²PIP (works great, thanks!). When running tests in GitHub Actions, I ran into the issue that RDKit is not installed using pip. Since RDKit is only used for molecule drawing, would you agree to make RDKit an optional dependency?
I would propose to put the rdkit imports in a try/except statement, and output a warning if the import fails. E.g. replace
spectrum_utils/spectrum_utils/plot.py
Lines 9 to 10 in 842de8b
with
try:
from rdkit import Chem
from rdkit.Chem import Draw
except ImportError:
warnings.warn("RDKit could not be imported. Some spectrum_utils functionality related to molecule drawing might lead to a NameError.", category=ImportWarning)
If you agree, I can open a PR.
I agree, I've already been thinking about doing that. Usage of RDKit within spectrum_utils is minimal and it's a heavy dependency (not really possible to install it without conda). I'll try to find some time this week after the PSI sessions to push a new version.
RDKit has been removed as a dependency. You can get spectrum_utils v0.3.5 from PyPI now, and from bioconda hopefully asap.
Thanks!