CoolFace
Apppublic

declare-lab/tango2

sourceHugging Faceupdated 2y agoView on Hugging Face
92likes
dependency_versions_check.py48 linesDownload Raw Back to diffusers
1# Copyright 2023 The HuggingFace Team. All rights reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7#     http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14import sys15 16from .dependency_versions_table import deps17from .utils.versions import require_version, require_version_core18 19 20# define which module versions we always want to check at run time21# (usually the ones defined in `install_requires` in setup.py)22#23# order specific notes:24# - tqdm must be checked before tokenizers25 26pkgs_to_check_at_runtime = "python tqdm regex requests packaging filelock numpy tokenizers".split()27if sys.version_info < (3, 7):28    pkgs_to_check_at_runtime.append("dataclasses")29if sys.version_info < (3, 8):30    pkgs_to_check_at_runtime.append("importlib_metadata")31 32for pkg in pkgs_to_check_at_runtime:33    if pkg in deps:34        if pkg == "tokenizers":35            # must be loaded here, or else tqdm check may fail36            from .utils import is_tokenizers_available37 38            if not is_tokenizers_available():39                continue  # not required, check version only if installed40 41        require_version_core(deps[pkg])42    else:43        raise ValueError(f"can't find {pkg} in {deps.keys()}, check dependency_versions_table.py")44 45 46def dep_version_check(pkg, hint=None):47    require_version(deps[pkg], hint)48