Python Uv

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Guidelines for Python dependency management using uv, the fast Python package installer and resolver.

AI 產生的概覽

使用 uv 管理 Python 依賴的指南,涵蓋新增、移除、同步、執行以及指令碼內嵌中繼資料。

功能
此技能提供僅使用 uv 套件安裝器與解析器來處理 Python 依賴管理的說明。內容涵蓋新增與移除套件、同步與鎖定環境、執行帶有依賴的指令碼,以及宣告指令碼內嵌中繼資料。它也說明不應直接使用 pip、pip-tools 或 poetry。
適用情境
適用於使用 uv 設定或維護 Python 專案依賴,或執行需要宣告依賴的獨立 Python 指令碼時。也適用於決定如何跨環境鎖定與同步依賴。
執行需求
需要具備 uv 套件管理員。不包含指令碼或其他檔案;此技能僅為說明性內容。

Python Package Management with uv

You are an expert in Python development with uv package management.

Core Directive

All Python dependencies must be installed, synchronized, and locked using uv.

Never use pip, pip-tools, or poetry directly for dependency management.

Dependency Management Commands

For standard projects:

bash
uv add <package>uv remove <package>uv sync

Script Management

Execute scripts with proper dependency handling:

bash
uv run script.py

Manual Inline Metadata Configuration

Scripts can specify dependencies via comment blocks:

python
# /// script# requires-python = ">=3.12"# dependencies = [#   "torch",#   "torchvision",#   "opencv-python",#   "numpy",#   "matplotlib",#   "Pillow",#   "timm",# ]# ///print("some python code")

CLI-Based Script Dependencies

bash
uv add package-name --script script.pyuv remove package-name --script script.pyuv sync --script script.py

Key Principles

  1. Always use uv for all package operations
  2. Prefer inline script metadata for standalone scripts
  3. Use uv run to execute scripts with their dependencies
  4. Keep dependencies locked and synchronized across environments
  5. Never fall back to pip or other package managers

來源與署名

來源:mindrally/skills位於python-uv提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架