Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions src/main/python/systemds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,46 @@
# under the License.
#
# -------------------------------------------------------------

from importlib.metadata import version, PackageNotFoundError
from systemds import context
from systemds import operator
from systemds import examples
from systemds import scuro

__all__ = ["context", "operator", "examples", "scuro"]
__all__ = ["context", "operator", "examples"]

required_packages = [
("torch", "2.5.1"),
("torchvision", "0.20.1"),
("librosa", "0.10.2"),
("opencv-python", "4.10.0.84"),
("opt-einsum", "3.3.0"),
("h5py", "3.11.0"),
("transformers", "4.46.3"),
("nltk", "3.9.1"),
("gensim", "4.3.3"),
]


def check_package_version(package_name, required_version):
try:
return version(package_name) >= required_version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see, missed it was greater than,

LGTM

except PackageNotFoundError:
return False


if all(check_package_version(pkg, version) for pkg, version in required_packages):
try:
from systemds import scuro

__all__.append("scuro")
except ImportError as e:
print(f"Scuro could not be imported: {e}")
else:
missing = [
f"{pkg} {version}"
for pkg, version in required_packages
if not check_package_version(pkg, version)
]
print(
f"Warning: Scuro dependencies missing or wrong version installed: {', '.join(missing)}"
)
Loading