Web3.Py
web3的Python项目详细描述
的python实现 web3.js
- python 3.6+支持
阅读documentation on ReadTheDocs中的更多内容。View the change log on Github。
开发人员设置
git clone git@github.com:ethereum/web3.py.git
cd web3.py
请参阅操作系统特定说明:
然后运行以下安装命令:
virtualenv venv . venv/bin/activate pip install -e .[dev]
对于不同的环境,可以设置多个virtualenv。为了 例如,如果要创建venvdocs,则执行 以下内容:
virtualenv venvdocs . venvdocs/bin/activate pip install -e .[docs] pip install -e .
使用Docker
如果你想在Docker环境中开发和测试,使用 docker compose.yml文件中提供的sandbox容器。
要启动测试环境,请运行:
docker-compose up -d
这将构建一个Docker容器,该容器设置有运行 python测试代码。
注意:此容器未安装“go ethereum”,因此 无法运行Go以太坊测试套件。
从本地计算机运行python测试:
docker-compose exec sandbox bash -c 'pytest -n 4 -f -k "not goethereum"'
您可以使用 bash -c前缀。
docker-compose exec sandbox bash -c ''
或者,如果您只想打开容器的会话,请运行:
docker-compose exec sandbox bash
测试设置
在开发过程中,您可能希望在每次保存文件时都运行测试。
更改文件时显示flake8错误:
# Test flake8 when-changed -v -s -r -1 web3/ tests/ ens/ -c "clear; flake8 web3 tests ens && echo 'flake8 success' || echo 'error'"
您可以使用pytest-watch,为每个python环境运行一个:
pip install pytest-watch cd venv ptw --onfail "notify-send -t 5000 'Test failure ⚠⚠⚠⚠⚠' 'python 3 test on web3.py failed'" ../tests ../web3
或者,您可以在一个命令中运行多进程测试,但不使用颜色:
# in the project root: pytest --numprocesses=4 --looponfail --maxfail=1# the same thing, succinctly: pytest -n 4 -f --maxfail=1
- Setup your development environment。
- 对测试执行tox。
有多个 components 所有的测试。您可以针对特定组件运行对的测试。为了 示例:
# Run Tests for the Core component (for Python 3.6): tox -e py36-core # Run Tests for the Core component (for Python 3.7): tox -e py37-core
如果由于某种原因它不工作,请添加--recreateparams。
tox对于测试完整的生成目标集很有用。但是 如果您想单独运行测试,py.test对于 开发工作流程。例如,只在一个文件中运行测试:
py.test tests/core/gas-strategies/test_time_based_gas_price_strategy.py
释放设置
对于类似Debian的系统:
apt install pandoc
发布新版本:
make release bump=$$VERSION_PART_TO_BUMP$$
如何颠簸
此repo的版本格式为 稳定,{major}.{minor}.{patch}-{stage}.{devnum}表示不稳定 (stage可以是alpha或beta)。
若要在行中发布下一个版本,请指定要凹凸的部分,如 make release bump=minor或make release bump=devnum。
如果您是beta版本,make release bump=stage将切换到 马厩。
若要在当前版本稳定时发布不稳定版本,请指定 新版本显式地 make release bump="--new-version4.0.0-alpha.1 devnum"