帮助您管理python发行版
disthelper的Python项目详细描述
Introduction
disthelper是一个命令行工具,可以帮助您管理python发行版。您可能希望创建python脚本来自动执行项目的常见维护任务。但是你把它们放在哪里?标准的setup.py framework怎么样?您可以将setup.py看作是python的“make”工具,尽管它更像是如何Ian Bicking describes it,而不是有目标和依赖的actual make tool。例如,如果您编写了一个脚本来构建项目文档,而另一个脚本则用于上载项目文档,则可以从setup.py文件中运行这些命令:
python setup.py build_docs upload_docs
What it does
disthelper只是自动使用distutils,所以您不必考虑如何create a custom setup.py command。它设置模块/子模块结构,编辑setup.cfg,并根据您的请求添加新的命令模块。disthelper不会做任何手工做不到的事情。
Create a command
disthelper是作为Paste扩展实现的。假设要创建我提到的build_docs命令。将CD放入您的项目目录并键入:
$ paster distcmd build_docs | Selected and implied templates: | disthelper#distcmd A disthelper-based package for setup.py commands | | ** creating ./setup.py (you'll probably need to edit this) | Variables: | command: build_docs | distcmds_mod: distcmds | package: foo | Creating template distcmd | Recursing into +package+ | Creating ./foo/ | Recursing into +distcmds_mod+ | Creating ./foo/distcmds/ | Copying +command+.py_tmpl to ./foo/distcmds/build_docs.py | Copying __init__.py to ./foo/distcmds/__init__.py | Copying __init__.py to ./foo/__init__.py | patching ./setup.cfg ... | | ./foo/distcmds/build_docs.py | ...is ready to edit | run as: | python setup.py build_docs |
如果您还没有python包,它会提示您输入它的名称。假设您将包命名为foo,则应看到以下布局:
$ tree | . | |-- foo | | |-- __init__.py | | `-- distcmds | | |-- __init__.py | | `-- build_docs.py | |-- setup.cfg | `-- setup.py | | 2 directories, 5 files
您的命令已准备好运行:
$ python setup.py build_docs --help | Global options: | --verbose (-v) run verbosely (default) | --quiet (-q) run quietly (turns verbosity off) | --dry-run (-n) don't actually do anything | --help (-h) show detailed help message | | Options for 'build_docs' command: | --long-option (-l) <help> | --other-long-option (-o) <help> | | usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] | or: setup.py --help [cmd1 cmd2 ...] | or: setup.py --help-commands | or: setup.py cmd --help |
但是,它还没有做任何有用的事情,所以去做吧!
My command disappeared, what do I do?
不幸的是,distutils将完全忽略您命令中的任何重要的错误,因此有一天您的命令可能会消失。要检查命令设置是否正确,请运行:
$ paster distcmd build_docs --check | Selected and implied templates: | disthelper#distcmd A disthelper-based package for setup.py commands | | Variables: | command: build_docs | distcmds_mod: distcmds | package: foo | attempting to import foo.distcmds.build_docs | OK | checking vars in ./setup.cfg | | build_docs OK
Other make like tools
disthelper不是为复杂的构建、依赖关系管理等而设计的,它只是帮助您创建维护脚本。您可能想退房…
- Vellum
Vellum是一个简单的构建工具,如PoT,但使用Python编写了一个简单但灵活的基于YAML的格式。
- 软件构造工具
- 开发建设管理系统
Changelog
- 0.9.2
- 修复了生成setup.py文件时的另一个错误
- 添加了ShellDoc对功能测试的支持(自述示例)
- 0.9.1
- 当一个尚未存在的 时,对SETUP.PY文件的固定处理
- 0.9
- 第一个版本,基本粘贴命令工作