现代 Python 模板 - 良好的包基本结构

1作者: lambda-science9 个月前原帖
简而言之:一个用于快速构建Python包的模板库,包含所有最佳实践。 大家好, 我想分享一个我创建的小型库,名为“现代Python模板”。我之所以创建它,是因为在多个项目中,包括专业环境中,我发现缺乏良好的结构和实践,导致代码丑陋甚至不功能正常,环境混乱。 这个库的目标是提供一个Python仓库的设置,包含所有最佳实践工具,并预先配置好。这使得构建和发布Python包变得简单! 链接在这里:https://github.com/lambda-science/modern-python-boilerplate 它包含(在一个Makefile中!)现代的Python管理(结构、打包、版本和依赖管理),现代持续集成(代码清单、格式化、类型检查、测试、覆盖率、预提交钩子),文档(自动API参考构建和在Github/Gitlab上发布,使用Mkdocs)以及运行(基本Dockerfile、Makefile、在Pycharm上测试的DevContainer,作为终端命令运行的模块等)。 欢迎分享反馈或评论,告诉我哪些地方可以改进。 我听说有些人讨厌预提交钩子,所以我只是保留了最基本的代码检查和重新格式化功能。
查看原文
TL;DR: Python Boilerplate repo for fast package building with all best practices<p>Hello,<p>I wanted to share a small repository I made named “Modern Python Boilerplate”. I created it because I saw in multiple projects including in professional environnement, the lack of good structure and practice, leading to ugly code or even non-functional, environnement mess…<p>The goal is to provide a python repository setup that provides all the best good-practices tool available and pre-configure them. It makes it easy to build and publish python package !<p>The link is here https:&#x2F;&#x2F;github.com&#x2F;lambda-science&#x2F;modern-python-boilerplate<p>It include (in a single Makefile !) modern python management (structure, packaging, version and deps w&#x2F; UV), modern CI (listing, formatting, type checking, testing, coverage, pre-commit hooks w&#x2F; Ruff&#x2F;Ty), documentation (automatic API Reference building and publishing on Github&#x2F;Gitlab w&#x2F; Mkdocs) and running (basic Dockerfile, Makefile, DevContainer tested on Pycharm, module running as a terminal command…)<p>Don’t hesitate to share feedback or comments on this, what could be improved.<p>I heard for example that some people hate pre-commit hooks, so I just kept it to the straight minimum of checking&#x2F;re-formatting code.