tox -av
能显示出定义在tox.ini
中所有的任务:
$ tox -av
default environments:
default -> Invoke pytest to run automated tests
additional environments:
build -> Build the package in isolation according to PEP517, see https://github.com/pypa/build
clean -> Remove old distribution files and temporary build artifacts (./build and ./dist)
docs -> Invoke sphinx-build to build the docs
doctests -> Invoke sphinx-build to run doctests
linkcheck -> Check for broken links in the documentation
publish -> Publish the package you have been developing to a package index server. By default, it uses testpypi. If you really want to publish your package to be publicly accessible in PyPI, use the `-- --repository pypi` option.
要执行哪个命令便用tox -e build
,tox -e docs
等, 下面是如何使用 PyScaffold 的动图:https://yanbin.blog/wp-content/uploads/2021/09/pyscaffold-demo.gif
在我体验 tox 命令过程中,每一步好像都比较慢,应该是创建虚拟机要花些时间 。tox 使用教程
PyBuilder最好再看另一个构建工具 PyBuilder,它所创建出的目录结构很接近于 Maven, 下面来瞧瞧
$pip install pybuilder
$mkdir sample && cd sample # 项目目录需手工创建
$pyb --start-project # 回答一些问题后创建所需的目录和文件
完后看下它的目录结构:
【虚拟机管理系统有哪些?vm虚拟机管理系统】$ tree sample
.
├── build.py
├── docs
├── pyproject.toml
├── setup.py
└── src
├── main
│ ├── python
│ └── scripts
└── unittest
└── python
构建过程仍然是用pyb
命令,可用pyb -h
查看帮助,pyb -t
列出所有的任务, PyBuilder 的任务是以插件的方式加入的,插件配置在build.py
文件中 。
$ pyb -t sample
Tasks found for project "sample":
*** yze - Execute*** ysis plugins.
depends on tasks: prepare run_unit_tests
clean - Cleans the generated output.
compile_sources - Compiles source files that need compilation.
depends on tasks: prepare
coverage - <no description available>
depends on tasks: verify
install - Installs the published project.
depends on tasks: package publish(optional)
package - Packages the application. Package a python application.
depends on tasks: compile_sources run_unit_tests(optional)
prepare - Prepares the project for building. Creates target VEnvs
print_module_path - Print the module path.
print_scripts_path - Print the script path.
publish - Publishes the project.
depends on tasks: package verify(optional) coverage(optional)
run_integration_tests - Runs integration tests on the packaged application.
depends on tasks: package
run_unit_tests - Runs all unit tests. Runs unit tests based on Python's unittest module
depends on tasks: compile_sources
upload - Upload a project to PyPi.
verify - Verifies the project and possibly integration tests.
depends on tasks: run_integration_tests(optional)
$ pyb run_unit_tests sample
PyBuilder 也是在构建或测试之前创建虚拟环境, 从 0.12.9 版开始可通过参数--no-venvs
跳过创建虚拟环境这一步 。使用了--no-venvs
的话 Python 代码将会在运行pyb
的当前 Python 环境中执行,所需的依赖将要手工安装 。
项目的依赖也要定义在build.py
文件中
@init
def set_properties(project):
project.depends_on('boto3', '>=1.18.52')
project.build_depends_on('mock')
随后在执行pyb
创建虚拟环境时就会安装上面的依赖,并在其中运行测试与构建 。
Poetry最后一个 Poetry, 感觉这是一个更为成熟,项目活跃度也更高的 Python 构建,它有着更强大的信赖管理功能,用
推荐阅读
- 30万左右7座SUV那个好 30万左右7座suv汽车大全
- 246天天免费资料大全+正版246期期准12期3362 246天天好免费资料大全首页一
- 大家最喜欢的网络文学作品都是什么?
- 中韩翻译器在线翻译中韩翻译器拍照扫一扫
- 温江卡奇乐儿童亲子乐园 南宁卡奇乐亲子乐园
- 北京全路通信信号研究设计院_全路通信信号研究设计院如何
- 有没有一觉醒来竟穿成虐文女主的小说推荐?
- 遥控器组合机械舞,遥控器组合键怎么解锁
- 断舍断舍离经典语录 断舍离经典语录100条