From b00b6b5fe08e3346d5848ee73583bc1103e269ed Mon Sep 17 00:00:00 2001 From: Bingsu Date: Sun, 16 Jul 2023 02:06:20 +0900 Subject: [PATCH] feat: add `py-cpuinfo`, remove `protobuf` --- install.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/install.py b/install.py index 25bfba2..fa71ae9 100644 --- a/install.py +++ b/install.py @@ -7,12 +7,15 @@ from importlib.metadata import version # python >= 3.8 from packaging.version import parse +import_name = {"py-cpuinfo": "cpuinfo"} + def is_installed( package: str, min_version: str | None = None, max_version: str | None = None ): + name = import_name.get(package, package) try: - spec = importlib.util.find_spec(package) + spec = importlib.util.find_spec(name) except ModuleNotFoundError: return False @@ -27,9 +30,6 @@ def is_installed( if not max_version: max_version = "99999999.99999999.99999999" - if package == "google.protobuf": - package = "protobuf" - try: pkg_version = version(package) return parse(min_version) <= parse(pkg_version) <= parse(max_version) @@ -49,15 +49,12 @@ def install(): ("huggingface_hub", None, None), ("pydantic", "1.10.8", None), ("rich", "13.4.2", None), - # mediapipe - ("protobuf", "3.20.0", "3.20.9999"), + # ultralytics + ("py-cpuinfo", None, None), ] for pkg, low, high in deps: - # https://github.com/protocolbuffers/protobuf/tree/main/python - name = "google.protobuf" if pkg == "protobuf" else pkg - - if not is_installed(name, low, high): + if not is_installed(pkg, low, high): if low and high: cmd = f"{pkg}>={low},<={high}" elif low: