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 从公开仓库中收录这些内容。

举报或申请下架