Python Dev Workflow for Humans
python setup.py install
easy_install NameOfPackage
pip install NameOfPackage
virtualenv nameOfDirectory
python3 -m venv nameOfDirectory
mkvirtualenv nameOfEnvironment
pip install --user pipenv
Kenneth Reitz
Creator of
Requests: HTTP for Humans
pipenv install requests
You mentioned development dependencies...
pipenv install --dev pytest
Help a friend set up their environment
pipenv install
How do I install for deployment?
pipenv sync
But Alex! I already have a project using requirements.txt!
pipenv install -r requirements.txt
How do I run things in my virtual environment?
pipenv run python name_of_script.py
That seems like a lot to type just to run a command...
pipenv shell
Drops you into your virtual environment.
I heard that there was a security vulnerability in a library I use, and I want to know if I'm affected!
pipenv check
Uses the Pyup.io safety package to check all dependencies in your tree for vulnerabilities.
12-Factor Apps and Environment Variables
Pipenv will use a .env file to update your virtual environment.
So... you know... don't commit your .env file.
What does a Pipfile look like?
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
[dev-packages]
pytest = "*"
Let's talk about Node.js and npm for a few seconds...
// package.json
{
//...
"scripts": {
"dev": "node build/dev-server.js",
"start": "node build/dev-server.js",
"build": "node build/build.js"
},
//...
}
npm run dev
Well, Pipenv does that too.
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
[dev-packages]
pytest = "*"
[scripts]
printspam = "python -c \"print('I am a silly example, no one would need to do this')\""
pipenv run printspam