Files
wehub-resource-sync e93507a09c
Lockfile supply-chain audit / lockfile supply-chain audit (push) Has been cancelled
Windows Studio GGUF CI / GPU prebuilt resolves without Visual Studio (push) Has been cancelled
Windows Studio GGUF CI / setup.ps1 unit tests (VS 2026 / CMake guard) (push) Has been cancelled
Windows Studio GGUF CI / real-VS detection (VS 2022) (push) Has been cancelled
Windows Studio GGUF CI / real-VS detection (VS 2026) (push) Has been cancelled
Windows Studio GGUF CI / VC++ runtime detect + install round-trip (windows-2025-vs2026) (push) Has been cancelled
Windows Studio GGUF CI / VC++ runtime detect + install round-trip (windows-latest) (push) Has been cancelled
Windows Studio Update CI / Studio Updating Tests (push) Has been cancelled
Wheel CI / Wheel build + content sanity + import smoke (push) Has been cancelled
Lint CI / Source lint (Python + shell + YAML + JSON + safety nets) (push) Has been cancelled
MLX CI on Mac M1 / dispatch (push) Has been cancelled
Security audit / advisory audit (pip + npm + cargo) (push) Has been cancelled
Security audit / pip scan-packages :: extras (push) Has been cancelled
Security audit / pip scan-packages :: studio (push) Has been cancelled
Security audit / pip scan-packages :: hf-stack (push) Has been cancelled
Security audit / npm scan-packages (Studio frontend tarballs) (push) Has been cancelled
Security audit / workflow-trigger lint (pull_request_target / cache-poisoning) (push) Has been cancelled
Security audit / pytest tests/security (push) Has been cancelled
Security audit / npm provenance + new install-script diff (push) Has been cancelled
Studio API CI / Studio API & Auth Tests (push) Has been cancelled
Backend CI / (Python 3.10) (push) Has been cancelled
Backend CI / (Python 3.11) (push) Has been cancelled
Backend CI / (Python 3.12) (push) Has been cancelled
Backend CI / (Python 3.13) (push) Has been cancelled
Backend CI / Repo tests (CPU) (push) Has been cancelled
Frontend CI / Frontend build + bundle sanity (push) Has been cancelled
Studio GGUF CI / OpenAI, Anthropic API tests (push) Has been cancelled
Studio GGUF CI / Tool calling Tests (push) Has been cancelled
Studio GGUF CI / JSON, images (push) Has been cancelled
Mac Studio GGUF CI / OpenAI, Anthropic API tests (push) Has been cancelled
Mac Studio GGUF CI / Tool calling Tests (push) Has been cancelled
Mac Studio GGUF CI / JSON, images (push) Has been cancelled
Mac Studio Install Matrix CI / Install + load (macos-14) (push) Has been cancelled
Mac Studio Install Matrix CI / Install + load (macos-15) (push) Has been cancelled
Mac Studio Install Matrix CI / Install + load (macos-26) (push) Has been cancelled
Mac Studio Install Matrix CI / Install + load (macos-15-intel) (push) Has been cancelled
Mac Studio API CI / Studio API & Auth Tests (push) Has been cancelled
Mac Studio Install Matrix CI / Install + load (macos-26-intel) (push) Has been cancelled
Mac Studio UI CI / Chat UI Tests (push) Has been cancelled
Studio Tauri CI / Tauri Linux debug build (no codesign) (push) Has been cancelled
Mac Studio Update CI / Studio Updating Tests (push) Has been cancelled
Studio UI CI / Chat UI Tests (push) Has been cancelled
Windows Studio API CI / Studio API & Auth Tests (push) Has been cancelled
Windows Studio UI CI / Chat UI Tests (push) Has been cancelled
Studio Update CI / Studio Updating Tests (push) Has been cancelled
Core / Core (HF=default + TRL=default) (push) Has been cancelled
Core / Core (HF=4.57.6 + TRL<1) (push) Has been cancelled
Core / Core (HF=latest + TRL=latest) (push) Has been cancelled
Core / llama.cpp build + smoke (push) Has been cancelled
Windows Studio GGUF CI / OpenAI, Anthropic API tests (push) Has been cancelled
Windows Studio GGUF CI / Tool calling Tests (push) Has been cancelled
Windows Studio GGUF CI / JSON, images (push) Has been cancelled
Windows Studio GGUF CI / Studio install + inference without Visual Studio (push) Has been cancelled
Studio export capability / capability (macos-latest) (push) Has been cancelled
Studio export capability / capability (ubuntu-latest) (push) Has been cancelled
Studio export capability / capability (windows-latest) (push) Has been cancelled
Cross-platform parity / parity (macos-latest) (push) Has been cancelled
Cross-platform parity / parity (windows-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Studio load-orchestrator CI / test (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:59:56 +08:00

123 lines
3.8 KiB
Python

import subprocess
import sys
import os
import shutil
import importlib
def detect_package_manager():
"""Detect the available package manager"""
package_managers = {
"apt": "/usr/bin/apt",
"yum": "/usr/bin/yum",
"dnf": "/usr/bin/dnf",
"pacman": "/usr/bin/pacman",
"zypper": "/usr/bin/zypper",
}
for pm, path in package_managers.items():
if os.path.exists(path):
return pm
return None
def check_package_installed(package_name, package_manager = None):
"""Check if a package is installed using the system package manager"""
if package_manager is None:
package_manager = detect_package_manager()
if package_manager is None:
print("Warning: Could not detect package manager")
return None
try:
if package_manager == "apt":
result = subprocess.run(["dpkg", "-l", package_name], capture_output = True, text = True)
return result.returncode == 0
elif package_manager in ["yum", "dnf"]:
result = subprocess.run(["rpm", "-q", package_name], capture_output = True, text = True)
return result.returncode == 0
elif package_manager == "pacman":
result = subprocess.run(["pacman", "-Q", package_name], capture_output = True, text = True)
return result.returncode == 0
elif package_manager == "zypper":
result = subprocess.run(
["zypper", "se", "-i", package_name], capture_output = True, text = True
)
return package_name in result.stdout
except Exception as e:
print(f"Error checking package: {e}")
return None
def require_package(package_name, executable_name = None):
"""Require a package to be installed, exit if not found"""
# Executable in PATH is the most reliable signal
if executable_name:
if shutil.which(executable_name):
print(f"✓ {executable_name} is available")
return
pm = detect_package_manager()
is_installed = check_package_installed(package_name, pm)
if is_installed:
print(f"✓ Package {package_name} is installed")
return
print(f"❌ Error: {package_name} is not installed")
print(f"\nPlease install {package_name} using your system package manager:")
install_commands = {
"apt": f"sudo apt update && sudo apt install {package_name}",
"yum": f"sudo yum install {package_name}",
"dnf": f"sudo dnf install {package_name}",
"pacman": f"sudo pacman -S {package_name}",
"zypper": f"sudo zypper install {package_name}",
}
if pm and pm in install_commands:
print(f" {install_commands[pm]}")
else:
for pm_name, cmd in install_commands.items():
print(f" {pm_name}: {cmd}")
print(f"\nAlternatively, install with conda:")
print(f" conda install -c conda-forge {package_name}")
print(f"\nPlease install the required package and run the script again.")
sys.exit(1)
# Usage
# require_package("ffmpeg", "ffmpeg")
def require_python_package(
package_name,
import_name = None,
pip_name = None,
):
"""Require a Python package to be installed, exit if not found"""
if import_name is None:
import_name = package_name
if pip_name is None:
pip_name = package_name
if importlib.util.find_spec(import_name) is None:
print(f"❌ Error: Python package '{package_name}' is not installed")
print(f"\nPlease install {package_name} using pip:")
print(f" pip install {pip_name}")
print(f" # or with conda:")
print(f" conda install {pip_name}")
print(f"\nAfter installation, run this script again.")
sys.exit(1)
else:
print(f"✓ Python package '{package_name}' is installed")