# hatch * 官网: [https://hatch.pypa.io/latest/](https://hatch.pypa.io/latest/) ## 简介 * Hatch是Python生态系统中的一个现代化的项目、包和虚拟环境管理工具,旨在简化Python项目的创建、打包和发布流程。 * 通过在pyproject.toml中定义Hatch的相关配置,开发者可以指定如何构建他们的项目以及设置其他相关选项。 ## 安装 ```shell brew install hatch pipx install hatch conda install -c conda-forge hatch ``` ## 示例 ```toml [build-system] requires = ["hatchling"] build-backend = "hatchling.build" [tool.hatch.version] path = "my_package/__init__.py" [tool.hatch.envs.default] dependencies = [ "pytest", "coverage[toml]", ] ``` * `requires`:构建项目所需的依赖列表,这里声明了 `hatchling`,它会在打包时被安装进隔离环境 * `build-backend`:指定构建后端,`hatchling.build` 是 hatchling 提供的标准后端接口