自动化测试和部署工具包的python项目-100%可重用。
auxilium的Python项目详细描述
代码、文档和测试
现代软件开发是
- The code is the actual software program or library which can executed or invoked.
- The documentation should give an introducing the idea and mission, guide how to use it, describe functionality and features.
- Finally, intensive tests increases the confidence that the documented functionality is correctly implemented.
为支持此^ {STR 1 } $ AuxiLIs被设计为构建、自动DOC、测试和部署。 在3个简单步骤中进行中小型python项目。
- copy your source code into a boilerplate project structure
- write useful documentation in your python source code doc strings
- add as many as possible test cases in a designated test directory structure
一旦建立起来,^ {STR 1 } $ AuxiLIs<强>提供-BOX工具 使用
- conventions on how the project is structured, i.e. where to find source, test and doc files
- provides useful template structure of files which can be easy modified and extended
- keeps always a single source of truth for project information (like version number)
- sets up a clear and straight structure of the project as well as the corresponding documentation
- minimises the places to edit, e.g. for the documentation there are by default only thre files to edit
- comes with a shell script to trigger plenty test and analysis routines incl. drafting releases on github.com and distribute on pypi.org
- uses standard community tools like unittest, pylint, coverage, sphinx and more
- no detailed configurations of any tools are needed, so you can focus completely on coding your project
- demo of how to use the framework and various services to build true ci/cd; a full automated test and deploy pineline.
此外,我们还建议使用pyenv和virtualenv来测试不同的python安装。
快速启动项目
安装后,只需调用auxilium create
并输入一些项目详细信息。
将创建整个项目结构。全功能,包括文件证明、测试等。
$ auxilium create
*** create new project ***
Please enter project details.
Enter project name : unicorn
Enter project slogan: Always be a unicorn.
Enter author name : dreamer
Enter author email : dreamer@ho
Created project unicorn with these files:
unicorn/CHANGES.rst
unicorn/dev.py
unicorn/HOWTO.rst
unicorn/LICENSE
unicorn/MANIFEST.in
unicorn/README.rst
unicorn/requirements.txt
unicorn/setup.py
unicorn/upgrade_requirements.txt
unicorn/doc/.DS_Store
unicorn/doc/sphinx/.DS_Store
unicorn/doc/sphinx/conf.py
unicorn/doc/sphinx/doc.rst
unicorn/doc/sphinx/index.rst
unicorn/doc/sphinx/intro.rst
unicorn/doc/sphinx/logo.png
unicorn/doc/sphinx/releases.rst
unicorn/doc/sphinx/tutorial.rst
unicorn/test/__init__.py
unicorn/test/unittests.py
unicorn/unicorn/__init__.py
Consider a first full run via: 'cd unicorn; auxilium full;'
项目的默认结构
目录结构的顶层由源文件、文档文件和测试文件的三个子目录组成 以及一些或多或少的标准项目文件。假设项目被称为{EM1}$AuxiLII:EEM>。
/unicorn (project root dir) /unicorn (python source files) /doc/sphinx (sphinx files) /test/unittests (unittest files) LICENSE (license to use) CHANGES.rst (change history) HOWTO.rst (user guide) README.rst (introduction) requirements.txt (pip dependencies) upgrade_requirements.txt (pip dependencies which always have to be upgraded) setup.py (configuration file to build a distribution)
您的python源文件可以按照您的喜好进行结构化。 只需要很少的项目信息 必须在
/unicorn/unicorn/__init__.py
大多数都需要设置pip安装(使用setuptools)
以及生成文档的sphinx配置。
看看这里unicorn/unicorn/__init__.py
的样子。
# -*- coding: utf-8 -*-# unicorn# -------# Always be a unicorn.## Author: dreamer# Version: 0.1, copyright Thursday, 29 August 2019# Website: https://github.com/dreamer/unicorn# License: Apache License 2.0 (see LICENSE file)importlogginglogging.getLogger(__name__).addHandler(logging.NullHandler())__doc__='Always be a unicorn.'__license__='Apache License 2.0'__author__='dreamer'__email__='unicorn@home'__url__='https://github.com/'+__author__+'/'+__name____date__='Thursday, 29 August 2019'__version__='0.1'__dev_status__='3 - Alpha'__dependencies__=()__dependency_links__=()__data__=()__scripts__=()
在顶层,我们有以下文件
/auxilium (project root dir) LICENSE CHANGES.rst HOWTO.rst README.rst requirements.txt upgrade_requirements.txt setup.py
用于
- LICENSE is the license how to use, change or distribute the project.
- CHANGES.rst will contain the whole change and release history
- HOWTO.rst gives a intro how to use your project. This will show up in your documentation as tutorial.
- README.rst is this page which show up on repository homepage at first. Moreover, this will show up in your documentation as introduction.
- requirements.txt are additional python packages, which are required for development and/or testing
- upgrade_requirements.txt are additional python packages (same as requirements.txt), which have to be upgraded, i.e. installed by
pip
with the –upgrade option. Usually used for dev repos.- setup.py configs the installation procedure with pip and the meta keywords of your project on pypi.org. Most of the entries are found in the project __init__.py file.
结构
/auxilium (project root dir) /auxilium (python source files) /doc/sphinx (sphinx files)
自动生成文档
文档位于
/auxilium (project root dir) /doc/sphinx (sphinx files)< P> ^ {STR 1 } $ AuxiLIs从源代码文件中提取所有文档,并链接到一些顶级^ {EM1}$RST
/doc/sphinx
下的文件不需要编辑。文档的站点地图如下所示
/index.rst /intro.rst -> README.rst /tutorial.rst -> HOWTO.rst /doc.rst -> api/* (generated by *sphinx-apidoc* via :code:`auxilium api`) /releases.rst -> CHANGES.rst
sphinx有一个配置(conf.py)来构建html和latexresp。pdf文档。 后者需要乳胶安装才能工作。
它可以运行文档代码示例的doctests。
因为只有doc.rst不会引用从源代码生成的项目的顶级文档文件。 因此,这里的工作开始编写良好的python文档字符串。
但如果一个更sphinx特定的文件rep。文件优先。 可能是为了提供对项目的详细了解: 简单地删除^ {< CD4> }(如果存在),并替换^ {STR 1 } $doc.rST 的内容。
自动化测试和测试覆盖框架
测试通过使用unittest discovery脚本调用,该脚本默认情况下搜索文件
包含unittest.TestCase
类并对其进行处理。
使用coverage.py
/auxilium (project root dir) /test/unittests (unittest files)
安装
最新的稳定版本始终可以通过pip安装或更新:
$ pip install auxilium
开发版本
最新的开发版本可以直接从github安装:
$ pip install --upgrade git+https://github.com/sonntagsgesicht/auxilium.git
贡献
Issues和Pull Requests总是受欢迎的。
许可证
根据apache软件许可证(请参见LICENSE)提供了代码和文档。