pipenv
2018-12-13 本文已影响8人
诺之林
本文的示例代码参考flask-basic
目录
What
官方版
Pipenv: Python Development Workflow for Humans
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the Python world. Windows is a first--class citizen, in our world.
It automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile as you install/uninstall packages. It also generates the ever--important Pipfile.lock, which is used to produce deterministic builds.
精华版
pipenv = pip + virtualenv + Pipfile&Pipfile.lock
对照版
Node | Python | |
---|---|---|
包管理器 | npm | pip |
环境隔离 | 全局(-g) 本地(默认) | virtualenv |
依赖描述 | package.json | Pipfile |
版本锁定 | (官方)无 | Pipfile.lock |
关于pipenv更多介绍 可以参考 pipenv
How
Installation
python --version
# Python 3.5.2
pip install pipenv
pipenv --version
# pipenv, version 2018.10.13
Setup
mkdir flask-basic && cd flask-basic
pipenv --python 3.7
cat Pipfile
[[source]]
name = "pypi"
verify_ssl = true
url = "https://pypi.org/simple"
[packages]
[requires]
python_version = "3.7"
[dev-packages]
pipenv shell
python --version
# Python 3.7.0
关于pipenv更多参数 可以参考"pipenv -h"
pipenv install flask
pipenv graph
Flask==1.0.2
- click [required: >=5.1, installed: 7.0]
- itsdangerous [required: >=0.24, installed: 1.1.0]
- Jinja2 [required: >=2.10, installed: 2.10]
- MarkupSafe [required: >=0.23, installed: 1.1.0]
- Werkzeug [required: >=0.14, installed: 0.14.1]
Project
vim app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return '<h1>Hello Flask!</h1>'
pipenv run flask run
curl localhost:5000
# <h1>Hello Flask!</h1>