pipenv 方便的python 开发工作流工具
Posted rongfengliang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pipenv 方便的python 开发工作流工具相关的知识,希望对你有一定的参考价值。
pipenv 将 composer、bundler、npm、yarn、cargo 等比较方便的包管理工具添加到了python 语言中,可以
帮助我们自动的管理virtualenv ,同时可以方便的从pipefile 中添加或者移除包
pipenv 解决的问题
- 我们不用在独立的使用pip 以及virualenv ,他们已经可以一起工作了
- 使用requirements.txt 方式管理包是有问题的,因此pipenv 使用pipefile 以及pipefile.lock
- 提供便捷的依赖图(通过 pipenv graph)
- 可以高效的加载.env 文件,方便快发
一个基本使用
- 安装
brew install pipenv
- 初始化一个项目
python3 环境
pipenv --python 3.7
效果
Creating a virtualenv for this project…
Pipfile: /Users/dalong/mylearning/pipenv-project/Pipfile
Using /usr/local/bin/python3 (3.7.2) to create virtualenv…
? Creating virtual environment...Using base prefix ‘/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7‘
New python executable in /Users/dalong/.local/share/virtualenvs/pipenv-project-iZJiWFj1/bin/python3.7
Also creating executable in /Users/dalong/.local/share/virtualenvs/pipenv-project-iZJiWFj1/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /usr/local/bin/python3
? Successfully created virtual environment!
Virtualenv location: /Users/dalong/.local/share/virtualenvs/pipenv-project-iZJiWFj1
Creating a Pipfile for this project…
- 添加依赖
tap-mysql
pipenv install tap-mysql
效果
Installing tap-mysql…
Adding tap-mysql to Pipfile‘s [packages]…
? Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
? Success!
Updated Pipfile.lock (430178)!
Installing dependencies from Pipfile.lock (430178)…
?? ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 13/14 — 00:00:00
?? ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 14/14 — 00:00:03
To activate this project‘s virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
- 运行安装的tap
pipenv run tap-mysql
- 依赖图
pipenv graph
tap-mysql==1.10.0
- attrs [required: ==16.3.0, installed: 16.3.0]
- backoff [required: ==1.3.2, installed: 1.3.2]
- mysql-replication [required: ==0.18, installed: 0.18]
- pymysql [required: Any, installed: 0.7.11]
- pendulum [required: ==1.2.0, installed: 1.2.0]
- python-dateutil [required: Any, installed: 2.7.5]
- six [required: >=1.5, installed: 1.12.0]
- pytzdata [required: Any, installed: 2018.7]
- tzlocal [required: Any, installed: 1.5.1]
- pytz [required: Any, installed: 2018.4]
- PyMySQL [required: ==0.7.11, installed: 0.7.11]
- singer-python [required: ==5.3.1, installed: 5.3.1]
- backoff [required: ==1.3.2, installed: 1.3.2]
- jsonschema [required: ==2.6.0, installed: 2.6.0]
- python-dateutil [required: >=2.6.0, installed: 2.7.5]
- six [required: >=1.5, installed: 1.12.0]
- pytz [required: ==2018.4, installed: 2018.4]
- simplejson [required: ==3.11.1, installed: 3.11.1]
说明
pipenv 工具还是很方便的,帮助我们简化了好多实际开发中的问题,在项目中很值得使用
参考资料
https://www.kennethreitz.org/essays/a-better-pip-workflow
https://github.com/pypa/pipenv
以上是关于pipenv 方便的python 开发工作流工具的主要内容,如果未能解决你的问题,请参考以下文章