---
title: "uv 0.12.0 发布：uv init 默认采用 src 布局并配置 uv_build 后端"
source: "Simon Willison 博客（Atom）"
source_tier: "t2"
url: "https://simonwillison.net/2026/Jul/28/uv/#atom-everything"
permalink: "https://feed.astralor.com/items/itm_f0600c9f85910a336b4b0d16"
published: "2026-07-28T21:51:38.000Z"
score: 78
channel: "tech"
tags: ["Python","src 布局","uv","包管理"]
---

# uv 0.12.0 发布：uv init 默认采用 src 布局并配置 uv_build 后端

## AI 点评

> 这个版本更新的 src 布局默认值反映了 Python 社区最佳实践的演进。对正在使用 uv 但尚未采用 src 布局的团队来说，这是重新评估项目结构的好时机。建议结合 uv build 和 uv run 脚本功能，进一步提升开发效率。

## 速览

uv 0.12.0 版本带来破坏性变更：uv init 命令创建的默认项目结构从根目录 main.py 改为 src/ 布局的包，并自动配置 uv_build 后端用于构建 wheel 和 tar.gz 分发文件。同时设置脚本别名 uv-run 执行 main() 函数。作者此前因惯性避免 src 布局，现认为应切换。此改动影响所有新项目初始化流程。

## 关键点

- uv init 默认创建 src/ 布局的 Python 包，而非根目录 main.py
- 自动配置 uv_build 后端以支持 wheel 和 sdist 构建
- 设置脚本别名 uv-run 指向 src/uv_init/__init__.py 中的 main() 函数
- 此改动是破坏性变更，现有项目不受影响，但新项目需适应

## 全文

uv 0.12.0 Some interesting breaking changes in this release of uv, in particular to the default project produced by the uv init command. uv init is the uv shortcut for creating a new project. The previous version of uv, version 0.11.x, produced this directory when you ran uv init uv-init. Here's what you get with uv 0.12. I have a GitHub repository that automatically snapshots the output of uv init, so you can also see the full diff: uv init now defaults to a src/ shaped package, instead of dropping main.py in the root of the project. It also configures the uv_build backend for building wheels and .tar.gz distribution files when you run uv build. Finally, it sets up uv-init as a script alias which, when run with uv run uv-init, executes a new main() function in src/uv_init/__init__.py. I've so far avoided using src layout in my own projects just out of inertia. I think it's time I switched. Tags: packaging, python, uv

---

引用前请核对原文;本文由星际流动整理:https://feed.astralor.com/items/itm_f0600c9f85910a336b4b0d16
