开发环境糖果
项目描述
Devbox
这是一个快速设置开发仓库的工具。它专门为Python项目创建,但也有一些通用的功能。
创建一个Box
首先使用pip安装devbox。然后运行dcreate python path/to/repository。有不同的模板提供不同的仓库基本配置。有关更多信息,请运行dcreate -h。
运行创建命令后,您的仓库将有一系列新文件,提供一些默认行为。根据需要修改它们,然后添加并提交。
解包
如果已安装devbox,可以运行dunbox git@github.com:user/repo.git。如果没有安装devbox,请运行
wget https://raw.github.com/mathcamp/devbox/master/devbox/unbox.py && \ python unbox.py git@github.com:user/repo.git
如果您已克隆要解包的仓库,只需传入仓库路径,devbox将完成设置
wget https://raw.github.com/mathcamp/devbox/master/devbox/unbox.py && \ python unbox.py path/to/repo
功能
Devbox使管理预提交钩子变得容易。它在设置过程中创建一个名为git_hooks的目录,并将其链接到您的.git/hooks目录。此外,它还提供了在项目或项目中特定修改的文件上运行预提交命令的简便方法。请参阅modified和all字段以获取更多详细信息。
Devbox允许在设置开发仓库时运行任意的设置命令。这对于安装依赖项、创建符号链接等很有用。
Devbox允许您指定项目依赖项,这使得将多个项目捆绑在一起变得容易。如果您的项目依赖于您也经常编辑的几个库,您可以将这些库作为依赖项,并在与主要项目同时开发时轻松设置它们。
Python特定功能
Devbox提供了一个简单的界面,用于在设置过程中自动创建和安装到虚拟环境。
Devbox可选包含version_helper.py
,一个基于git标签自动生成包版本的实用工具。
对于链接到其他项目,请在conf文件中调查父级和依赖选项。这些选项将在虚拟环境中得到尊重。
Devbox conf的格式
.devbox.conf是一个包含多个字段的json编码字典
dependencies : list List of git urls to also clone and set up when unboxing this repo (run after pre_setup, before post_setup) pre_setup : list List of commands to run at the start of unboxing. Instead of a system command, you may also specify the url of a script (e.g. https://raw.github.com/user/repo/master/path/to/script.sh). That script will be downloaded and run. post_setup : list List of commands to run after any dependencies have been handled. Can specify a url, same as pre_setup. hooks_all : list List of commands to run during the pre-commit hook. hooks_modified : list A list of (pattern, command) pairs. The pattern is a glob that will match modified files. During the pre-commit hooks, each modified file that matches the pattern will be passed as an argument to the command. (ex. [["*.py", "pylint --rcfile=.pylintrc"], ["*.js", "jsl"]])
Python特定的字段
env : dict path : str The path to a virtualenv relative to repository root. args : list List of flags to pass to the virtualenv command (e.g. ["--system-site-packages"]) parent : str or None When unboxing this repo, look for a directory of this name at the same level in your directory structure. If it exists, devbox will make a symbolic link to that virtualenv instead of constructing one for this repo.
预提交深入解析
简单的预提交钩子存在问题。为了说明这一点,这里有一个简单的例子。
预期:
修改文件A和B,在B中放置语法错误
git add A
git commit
git add B
git commit被预提交钩子在B上的失败所阻塞
修复并git add B
git commit
到处都是笑容
实际:
修改文件A和B,在B中放置语法错误
git add A
git commit被预提交钩子在B上的失败所阻塞
悲伤
这是一个简单的例子,但很容易频繁地做错。还有一个更糟糕的变种,即使你在提交一个损坏的构建,钩子也能通过。设计hook.py
文件是为了解决这个问题和其他问题。它在一个临时文件夹中执行git checkout-index,复制任何git子模块,然后在那些临时文件上运行钩子。
0.2.0
首次发布
项目详情
devbox-0.2.0.tar.gz的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | a1e7b9014389346e5bf380608871bf4cf24665331060801415aca09cb36d869b |
|
MD5 | 39c8cb717e17e6f8db7394854ee50315 |
|
BLAKE2b-256 | e8e7c80538e776b106bde9c2a4d93f83a7f0016bcb917fbe6e61326c155bab91 |