pyproject. toml和hatch
最初,Django-wiki核心开发者选择使用新的 pyproject.toml
放弃旧的 setup.py
(见 #1199 ). Python打包生态系统已对构建后台的界面进行了标准化 (PEP 517 / PEP 660) 以及元数据声明的格式 (PEP 621 / PEP 631) .因此,执行 setup.py
文件现在 deprecated .
The discussion for this feature and the steps to mark this as completed are happening in this discussion, and as well the development process is here.
由于这项工作,维护者选择使用 hatch
要管理django-wiki的开发过程,您可以在他们的 official docs .
假设您已经安装 hatch
在您的环境中,您必须在新的 django-wiki
是初始化环境,因此您必须执行 hatch env create
根中 django-wiki
代码库。
这将添加一组可用的命令以及开发过程中使用的不同环境,以下是使用 hatch env show
Standalone
+-----------+---------+---------------------------+-------------+
| Name | Type | Dependencies | Scripts |
+===========+=========+===========================+=============+
| default | virtual | black<22.11,>=22.3.0 | assets |
| | | codecov | clean-build |
| | | coverage[toml] | clean-pyc |
| | | ddt | cov |
| | | django-functest<1.6,>=1.2 | lint |
| | | flake8<5.1,>=3.7 | no-cov |
| | | pre-commit | test |
| | | pytest-cov | |
| | | pytest-django | |
| | | pytest-pythonpath | |
| | | pytest<7.3,>=6.2.5 | |
+-----------+---------+---------------------------+-------------+
| transifex | virtual | transifex-client | assets |
| | | | clean-build |
| | | | clean-pyc |
| | | | cov |
| | | | lint |
| | | | no-cov |
| | | | pull |
| | | | push |
| | | | test |
+-----------+---------+---------------------------+-------------+
| docs | virtual | bleach<5.1,>=3.3.0 | assets |
| | | django>=3.1.13 | build |
| | | sphinx-rtd-theme==1.1.1 | changes |
| | | sphinx>=3 | clean |
| | | | clean-build |
| | | | clean-pyc |
| | | | cov |
| | | | devhelp |
| | | | dirhtml |
| | | | doctest |
| | | | epub |
| | | | gettext |
| | | | html |
| | | | htmlhelp |
| | | | info |
| | | | json |
| | | | latex |
| | | | latexpdf |
| | | | link-check |
| | | | link-check2 |
| | | | lint |
| | | | man |
| | | | no-cov |
| | | | pickle |
| | | | qthelp |
| | | | singlehtml |
| | | | test |
| | | | texinfo |
| | | | text |
+-----------+---------+---------------------------+-------------+
Matrices
+------+---------+-------------------+---------------------------+-------------+
| Name | Type | Envs | Dependencies | Scripts |
+======+=========+===================+===========================+=============+
| test | virtual | test.py3.7-dj2.2 | black<22.11,>=22.3.0 | all |
| | | test.py3.7-dj3.0 | codecov | assets |
| | | test.py3.7-dj3.1 | coverage[toml] | clean |
| | | test.py3.7-dj3.2 | ddt | clean-build |
| | | test.py3.8-dj2.2 | django-functest<1.6,>=1.2 | clean-pyc |
| | | test.py3.8-dj3.0 | flake8<5.1,>=3.7 | cov |
| | | test.py3.8-dj3.1 | pre-commit | lint |
| | | test.py3.8-dj3.2 | pytest-cov | no-cov |
| | | test.py3.9-dj2.2 | pytest-django | test |
| | | test.py3.9-dj3.0 | pytest-pythonpath | |
| | | test.py3.9-dj3.1 | pytest<7.3,>=6.2.5 | |
| | | test.py3.9-dj3.2 | | |
| | | test.py3.10-dj3.2 | | |
| | | test.py3.8-dj4.0 | | |
| | | test.py3.9-dj4.0 | | |
| | | test.py3.10-dj4.0 | | |
+------+---------+-------------------+---------------------------+-------------+
我们在配置文件中声明了4个不同的环境,每个环境都有自己的目的:
default
:django-wiki的开发环境。test
:我们确保代码适用于不同的Django和Python版本。docs
:用于生成您此时正在阅读的页面。transifex
: Used only for the translation side of the project.
We center around the entrypoints provided by hatch
(read more)
that's why we have documented commands that make development easier.
Some commands are only available in certain environments,
so for example at the transifex
environment you see pull
and push
commands that are not present in any other environment declared above. For
executing the command you have to follow this simple formula:
$ hatch run <environment name>:<command name>
然后施加到 push
司令部 transifex
环境将是:
$ hatch run transifex:pull
您可以使用相同的逻辑来执行应用程序中的可用命令,但这里有一个按环境排序的命令的详细列表,因此您可以了解每个命令的用途:
cov
:检查覆盖状态。no-cov
:检查等待添加覆盖范围的地方。lint
:确保代码更改遵循我们的指导方针和惯例。clean-build
:删除项目构建后生成的文件。clean-pyc
:删除pyc生成的文件。assets
:生成django-wiki前端使用的静态文件。test
:测试当前环境中的更改。test:all
:测试我们支持的Python和Django版本的更改。test:lint
:确保代码更改遵循我们的指导方针和惯例。test:clean
:删除通过测试过程生成的文件。transifex:push
:将翻译文件推送到Transifex。transifex:pull
:从Transifex提取翻译文件。docs:clean
:删除生成的文档文件。List of docs commands used to generate the documentation in different formats:
请参阅 Builder documentation of SPHINX 更多地了解每个构建者的目的和预期产出。
docs:html
docs:dirhtml
docs:singlehtml
docs:pickle
docs:json
docs:htmlhelp
docs:qthelp
docs:devhelp
docs:epub
docs:latex
docs:latexpdf
docs:text
docs:man
docs:texinfo
docs:info
docs:gettext
docs:changes
docs:link-check2
docs:doctest
docs:build
:生成HTML格式的文档。docs:link-check
:检查文档中的外部链接。
我们希望本文档可以帮助您更多地了解开发过程,如果有什么不清楚,请打开问题。
FAQ
Whats the difference between test and test:all?
当你执行
hatch run test
这将检查您在活动环境中的更改,这意味着它将在特定的Python版本和特定的Django版本上运行;另一方面test:all
将在Python和Django支持版本的整个矩阵中运行测试套件。hatch is unable to create a test environment with an specific Python Version?
如果你执行之后
hatch env create
您在终端中收到这样的消息py3.8-4.0 -> cannot locate Python: 3.8
这意味着hatch
无法找到该Python版本,最终这取决于您使用什么程序来管理您的Python版本,最重要的是版本必须在您的PATH
.How to manage different Python Versions?
外部有很多选项,最重要的是如上所述,版本需要能够位于您的系统中
PATH
.例如,如果您是 pyenv 您可以使用设置多个Python版本pyenv local <version> <version>
.pyenv local 3.7.12 3.8.12 3.9.13 3.10.2
There's an error when init an environment?
如果您看到错误消息,例如
Environment default defines a matrix, choose one of the following instead:
然后是所有可用环境的列表,您需要在shell命令上设置环境名称,如下所示hatch -e <env_name> shell
hatch -e test.py3.10-dj3.2 shell
这样,您就可以通过特定的Python和Django版本切换环境。
How do I switch default shell versions?
默认情况下,django-wiki运行在最新支持的Python和Django版本上,如果你想切换到另一个环境,比如Python 3.9.13和Django 3.0,然后执行以下命令:
hatch -e py3.9-dj3.0 shell