Voice et bot modif
This commit is contained in:
parent
189d56026b
commit
7333a22bcd
10774 changed files with 634644 additions and 933308 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# coding=utf-8
|
||||
# Copyright 2022-present, the HuggingFace Inc. team.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
@ -15,6 +14,7 @@
|
|||
"""Check presence of installed packages at runtime."""
|
||||
|
||||
import importlib.metadata
|
||||
import importlib.util
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
|
@ -316,32 +316,38 @@ def is_colab_enterprise() -> bool:
|
|||
# Check how huggingface_hub has been installed
|
||||
|
||||
|
||||
def installation_method() -> Literal["brew", "hf_installer", "unknown"]:
|
||||
def installation_method() -> Literal["brew", "hf_installer", "pip", "unknown"]:
|
||||
"""Return the installation method of the current environment.
|
||||
|
||||
- "hf_installer" if installed via the official installer script
|
||||
- "brew" if installed via Homebrew
|
||||
- "pip" if pip is available (default fallback for standard Python environments)
|
||||
- "unknown" otherwise
|
||||
"""
|
||||
# hf_installer check must come first: the installer creates a venv using the
|
||||
# system Python, which may be Homebrew's. Checking brew first would false-positive
|
||||
# when the resolved sys.executable points to /opt/homebrew/... inside a venv.
|
||||
if _is_hf_installer_installation():
|
||||
return "hf_installer"
|
||||
if _is_brew_installation():
|
||||
return "brew"
|
||||
elif _is_hf_installer_installation():
|
||||
return "hf_installer"
|
||||
else:
|
||||
return "unknown"
|
||||
if _is_pip_available():
|
||||
return "pip"
|
||||
return "unknown"
|
||||
|
||||
|
||||
def _is_brew_installation() -> bool:
|
||||
"""Check if running from a Homebrew installation.
|
||||
|
||||
Note: AI-generated by Claude.
|
||||
Homebrew installs the `hf` formula into a Cellar directory and creates a
|
||||
libexec virtualenv at e.g. /opt/homebrew/Cellar/hf/0.30.0/libexec/.
|
||||
We check `sys.prefix` (the venv/prefix root) for "/Cellar/hf/" rather
|
||||
than checking `sys.executable` — the latter resolves to Homebrew's Python
|
||||
(e.g. /opt/homebrew/Cellar/python@3.12/...) even for non-brew installs
|
||||
when the system Python happens to come from Homebrew.
|
||||
"""
|
||||
exe_path = Path(sys.executable).resolve()
|
||||
exe_str = str(exe_path)
|
||||
|
||||
# Check common Homebrew paths
|
||||
# /opt/homebrew (Apple Silicon), /usr/local (Intel)
|
||||
return "/Cellar/" in exe_str or "/opt/homebrew/" in exe_str or exe_str.startswith("/usr/local/Cellar/")
|
||||
prefix = str(Path(sys.prefix).resolve())
|
||||
return "/Cellar/hf/" in prefix
|
||||
|
||||
|
||||
def _is_hf_installer_installation() -> bool:
|
||||
|
|
@ -356,6 +362,11 @@ def _is_hf_installer_installation() -> bool:
|
|||
return marker.exists()
|
||||
|
||||
|
||||
def _is_pip_available() -> bool:
|
||||
"""Return `True` if pip is importable in the current environment."""
|
||||
return importlib.util.find_spec("pip") is not None
|
||||
|
||||
|
||||
def dump_environment_info() -> dict[str, Any]:
|
||||
"""Dump information about the machine to help debugging issues.
|
||||
|
||||
|
|
@ -365,7 +376,7 @@ def dump_environment_info() -> dict[str, Any]:
|
|||
- `transformers` (https://github.com/huggingface/transformers/blob/main/src/transformers/commands/env.py)
|
||||
"""
|
||||
from huggingface_hub import get_token, whoami
|
||||
from huggingface_hub.utils import list_credential_helpers
|
||||
from huggingface_hub.utils import is_agent, list_credential_helpers
|
||||
|
||||
token = get_token()
|
||||
|
||||
|
|
@ -400,6 +411,8 @@ def dump_environment_info() -> dict[str, Any]:
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
info["Run by AI agent ?"] = "Yes" if is_agent() else "No"
|
||||
|
||||
# How huggingface_hub has been installed?
|
||||
info["Installation method"] = installation_method()
|
||||
|
||||
|
|
@ -418,6 +431,7 @@ def dump_environment_info() -> dict[str, Any]:
|
|||
info["HF_HUB_OFFLINE"] = constants.HF_HUB_OFFLINE
|
||||
info["HF_HUB_DISABLE_TELEMETRY"] = constants.HF_HUB_DISABLE_TELEMETRY
|
||||
info["HF_HUB_DISABLE_PROGRESS_BARS"] = constants.HF_HUB_DISABLE_PROGRESS_BARS
|
||||
info["HF_HUB_DISABLE_SYMLINKS"] = constants.HF_HUB_DISABLE_SYMLINKS
|
||||
info["HF_HUB_DISABLE_SYMLINKS_WARNING"] = constants.HF_HUB_DISABLE_SYMLINKS_WARNING
|
||||
info["HF_HUB_DISABLE_EXPERIMENTAL_WARNING"] = constants.HF_HUB_DISABLE_EXPERIMENTAL_WARNING
|
||||
info["HF_HUB_DISABLE_IMPLICIT_TOKEN"] = constants.HF_HUB_DISABLE_IMPLICIT_TOKEN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue