比较开发环境
diffenv的Python项目详细描述
差异
概述
diffenv收集并比较运行时环境。它定义了一个简单的标准来存储开发环境的完整图片。
简化示例
$ diffenvpython:python-version:Python 3.7.3shell:envvars:EDITOR:sublwGIT_EDITOR:subl -wAPI_ENDPOINT:http://api.lvh.me:4000PRISMA_ENDPOINT:http://prisma:4466os:timezone:0200version:Darwin 18.7.0 x86_64
简化差异
git: git-user-name: - <<-: Stan James+ +>>: Gabriel Pickard version: - <<-: git version 2.22.0+ +>>: git version 2.11.0 os: version: - <<-: Darwin 18.7.0 x86_64+ +>>: Linux 4.19.34-04457-g5b63d4390e96 x86_64 python: python-version: - <<-: Python 3.7.3+ +>>: Python 2.7.13 python3-version: - <<-: Python 3.7.3+ +>>: Python 3.5.3 which-python: - <<-: /usr/local/opt/python/libexec/bin/python+ +>>: /usr/bin/python
用例
- 将环境数据添加到错误报告中,甚至自动添加。Example
- 诊断环境中的细微差别是什么使你同事的机器出故障。
- 将您当前的环境与过去工作时的提交进行比较。
选项
usage: diffenv [-h] [-o OUTPUT] [-c COMPARE] [--add-hooks] [--share] [--issue]
[--post POST] [--config CONFIG] [--ignore-config] [--no-color]
[--no-paging] [--version]
Diff your total environment. Run without any params to simply output current
environment state as YAML.
optional arguments:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
output to file instead of stdout
-c COMPARE, --compare COMPARE
file or URL to compare against the current env
--add-hooks install git hooks in current repo and exit
--share store current env and return URL that can be shared
--issue create github issue
--post POST POST env to specific URL when sharing; must be used
with --share
--config CONFIG load config from specific file
--ignore-config ignore configs and run all facets
--no-color don't color diff output
--no-paging don't use less for paging output
--version display version and exit
安装
python3 -m pip install diffenv
目前diffenv只支持python 3。
使用
要将当前的开发环境输出到stderr:
diffenv
将您的环境与@werg进行比较:
diffenv -c https://raw.githubusercontent.com/error-central/diffenv/master/examples/gabe_env.yaml
与同事分享您的环境以进行比较:
diffenv --share
有关命令行选项的完整列表,请运行:
diffenv --help
定制
diffenv可以为用户或repo定制。自定义设置放在用户主目录或git repos top目录中名为.diffenv
的目录中。
自定义面
Git回购的自定义方面应保存在.diffenv/facets/<yourfacet>
方面文件本身需要是可执行的(chmod +x <yourfacet>
)。
配置
您可以限制使用保存在.diffenv/config.yaml
有关详细信息,请参见example_config.yaml
。
导致差异
开发安装
如果您是在本地开发,请不要像上面那样安装not,而是在repo根目录中运行以下命令:
# depending on your setup you may have to prefix sudo to this command
pip3 install --editable .
现在diffenv
将始终指向本地回购,包括任何更改。
对于Docker容器的测试:
docker pull python
docker run -it python bash
# Now e.g. `pip install diffenv`
测试
python3 -m unittest tests/tests.py