PHP前端开发

用于快速启动 Polylith 的 Cookiecutter

百变鹏仔 1个月前 (01-16) #Python
文章标签 快速启动

向您展示一个python cookiecutter,用于在python 中快速启动polylith。如果您不知道什么是 polylith,请阅读文档,对于不耐烦的读者:

polylith 是一种软件架构,旨在构建简单、可维护、可测试和可扩展的后端系统。它通过在系统规模上应用功能思维来实现这一点,将代码视为可以组合成功能的构建块。

python-polylith 是允许我们在 python 中实现此功能的工具。

我不会详细介绍这种方法的优点。在本文中,我向您介绍诗歌-poly-cc,这是一个非常有主见的 cookiecutter,用于使用 python-polylith 启动项目。

您可以首先安装 cookiecutter 并使用以下命令生成项目:

cookiecutter https://github.com/ybenitezf/poetry-poly-cc.git

回答问题,你就很好了。你最终应该得到类似的结果:

.├── license├── readme.md├── bases├── build-packages.sh├── components├── development│   └── __init__.py├── poetry.toml├── projects├── pyproject.toml├── update-locks.sh└── workspace.toml

第一步包含在 readme.md 中:

奔跑

git initpoetry install# install pre-commit hookpoetry run pre-commit install# install pre-commit dependenciespoetry run pre-commit run -a

包含什么

  1. poetry 配置为在项目文件夹中创建 virtualenv(请参阅诗歌.toml)
  2. pytest 作为测试依赖项添加,还包括 pytest 的一些好东西:pytest-mock、pytest-cov 和 pytest-asyncio
  3. 预提交和 ruff 作为开发依赖项。
  4. mypy 用于静态类型检查,与预提交集成
  5. 支持脚本 build-packages.sh 和 update-locks.sh
  6. 推荐的 vscode 扩展