Installing the right way
pipsi & pipenv
Craig Loftus
pipsi
For installing scripts
Isolates each script
Provides nice porcelain
pipenv
For project dependencies
Isolates each project
Provides nice porcelain
pipsi
For installing scripts
$ sudo pip install pew
$ pip install --user pew
$ pip install pew
[gibberish]
OSError: [Errno 13] Permission denied ...
$ sudo -H pip install pew
$ curl [somewhere on github]/get-pipsi.py | python
$
$ pipsi install pew
$ pew --help
$ pipsi list
Packages and scripts installed through pipsi:
Package "pipsi":
pipsi
Package "pew":
pew
$ pipsi upgrade pew
pipenv
For project dependencies
$ mkvirtualenv --python=python3 fancy
(fancy) $ pip install requests "django<1.11"
or pew and venv
(fancy) $ pip freeze > requirements.txt
(fancy) $ cat requirements.txt
certifi==2017.11.5
chardet==3.0.4
Django==1.10.8
idna==2.6
requests==2.18.4
urllib3==1.22
Some time later...
(fancy) $ cat requirements.txt
certifi==2017.11.5
chardet==3.0.4
Django==1.10.8
idna==2.6
requests==2.18.4
urllib3==1.22
(fancy) $ pip install --upgrade django
$ cat requirements.txt
requests
django<1.11
(fancy) $ pip install -r requirements.txt
(fancy) $ pip freeze > requirements-frozen.txt
$ rmvirtualenv fancy_env
$ mkvirtualenv --python=python3 fancy_env
$ pip install -r requirements.txt --upgrade
$ pip freeze > requirements-frozen.txt
(fancy) $ pip install -r requirements.txt --upgrade
(fancy) $ pip freeze > requirements-frozen.txt
$ pipsi install pew
$ pipsi install pipenv
$ cd fancy_project/
$ pipenv --three
$ pipenv install requests "django<1.11"
$ cat Pipfile
[packages]
requests = "*"
django = "<1.11"
[requires]
python_version = "3.5"
$ cat Pipfile.lock
"django": {
"hashes": [
"sha256:ffdc7e938391ae3c2ee8ff82e0b4444e4e6bb15c99d00770285233d42aaf33d6",
"sha256:d4ef83bd326573c00972cb9429beb396d210341a636e4b816fc9b3f505c498bb"
],
"version": "==1.10.8"
},
$ pipenv install --dev pytest
[dev-packages]
pytest = "*"
$ cd fancy_project/
$ pipenv install
Uses Pipfile.lock or requirements.txt
- pipenv update - ...
- pipenv graph - show dependency tree
- pipenv shell - drop into the venv
- pipenv run - execute a script in the venv
- pipenv check - run safety and flake8
- reinforce best practice
- reduce what I have to remember
- focus ...
- get out of the way
Comments?
$ pipenv install request
Did you mean requests? [Y/n]:
Installing things the right way with Pipsi and Pipenv
By Craig Loftus
Installing things the right way with Pipsi and Pipenv
- 1,475