首页/ AI 技能 / @skilllib/skill-2117939930272414234
Skill站外收录 @skilllib/skill-2117939930272414234

setup-env

自动化配置 Python 项目运行环境,根据 pyproject.toml 或 requirements.txt 文件智能选择 uv 同步依赖或 pip 兼容流程,完成虚拟环境创建、依赖安装及脚本执行,全程无需手动激活环境。

0.0 (0) 38 次安装 原作者 编程导航
收录于 2026-01-22

Skills.MD

# Skill: Use uv to manage Python environments ## Scope 1. Create a virtual environment 2. Install dependencies 3. Run Python scripts/commands Assume `uv` is already available on PATH. --- ## Workflow selection - If `pyproject.toml` exists: use **project workflow** (`uv sync`, `uv run`) - Else if `requirements.txt` exists: use **pip workflow** (`uv venv`, `uv pip install -r ...`, `.venv/bin/python ...`) - Else: stop with an error ("No pyproject.toml or requirements.txt found.") --- ## Project workflow (pyproject.toml) ### Create venv + install dependencies From the repo root (where `pyproject.toml` is): - `uv sync` Notes: - uv maintains a persistent project environment at `.venv` and installs deps there. ### Run scripts / commands (preferred) Always run within the project environment: - `uv run -- python <script.py> [args...]` - `uv run -- python -m <module> [args...]` Notes: - `uv run` executes inside the project environment and ensures it is up-to-date. --- ## Pip workflow (requirements.txt) ### Create venv From the repo root: - `uv venv` # creates `.venv` by default ### Install dependencies - `uv pip install -r requirements.txt` ### Run scripts / commands Run using the venv interpreter directly (no activation required): - `.venv/bin/python <script.py> [args...]` - `.venv/bin/python -m <module> [args...]` (uv will also automatically find and use the default `.venv` in subsequent invocations when you use `uv pip ...` commands.) --- ## Minimal sanity checks (optional) - `test -x .venv/bin/python` - `uv pip list` (verify packages installed)

评论 0

还没有评论,来抢沙发。