当前位置:首页>python>01-01 UV-Python项目创建

01-01 UV-Python项目创建

  • 2026-10-16 12:42:33
01-01 UV-Python项目创建
一、创建项目
# 项目类型1: Minimal Projectuv init demo-bare --bare# 项目类型2: Projects with extension modulesuv init demo-ext --build-backend maturin# 项目类型3:创建 Applications Projectuv init demoappuv init demoapp --app# 项目类型4:创建 Packaged Applications Project:Libraries uv init demo-lib --lib# 项目类型5:创建 Packaged Applications Projectuv init demo-pkg --package
1)适应场景
> Minimal Project
    • 仅创建pyproject.toml文件。
   --bare :可以和其它项目类型混合使用。
> Projects with extension modules(拓展)
    • 扩展其它编程语言模块(例如:C, C++, FORTRAN, or Rust)。
需要配置Build System:
  1) maturin
    支持的编程语言:Rust。
uv init xxxproject --build-backend maturin
  2)scikit-build-core
    支持的编程语言:C, C++, FORTRAN, Cython。
uv init xxxproject --build-backend scikit-build-core
    --build-backend xxxxxx : 可与其它项目类型混合使用。
> Applications Project
    • Application projects are suitable for web servers, scripts, and command-line interfaces.
> Libraries Project
    • 提供Function和Object供导入本项目的项目调用。
> Packaged Applications Project
    • The --package flag can be used to create a packaged application。
2)目录结构
  • 文件:pyproject.toml
    Python Project元数据文件。
  • 文件:README.md
  • 文件:.python-version
    Python版本引脚(Pin)文件。
  • 文件:.gitignore
  • 文件:py.typed
    A py.typed marker is included to indicate to consumers that types can be read from the library。

最新文章

随机文章