Open aguschin opened 1 year ago
@aguschin have you tried to see if importlib.metadata
? They cover packages and distributions. I believe this should work as of python 3.10 (before that we may need to patch or copy packages_distributions()
helper but that's it:
>>> packages = importlib.metadata.packages_distributions()
>>> packages
{'pip': ['pip'], 'cv2': ['opencv-python-headless'], '_distutils_hack': ['setuptools'], 'pkg_resources': ['setuptools'], 'setuptools': ['setuptools'], 'regex': ['regex'], 'wheel': ['wheel'], 'numpy': ['numpy']}
>>> importlib.metadata.distribution(packages['cv2'][0]).version
'4.8.0.74'
works for regex
as well:
>>> importlib.metadata.distribution(packages['regex'][0]).version
'2023.6.3'
@aguschin issued a patch in https://github.com/iterative/mlem/pull/694
I kept running with issues with the automatic 3rd party dependencies (inferring the wrong version, or missing packages). The version issue is due to some python packages having a mismatch between
MODULE.__version__
and the version required for pip:regex==2023.6.3
,import regex ; regex.__version__
gives2.5.129
. But there is no2.5.129
version ofregex
so the install failopencv-python-headless=4.8.0.74
,import cv2 ; cv2.__version__
gives4.8.0
but there is no4.8.0
version ofopencv-python-headless
(you need to give the 4th-level version).Reported in discord.