Slide 1

Slide 1 text

Ṝᒬత։ᚙ؀ڥ ᔒ໰୊䆩ʁ

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

https://conda.io/docs/user-guide/

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Me • Call me TP • Follow @uranusjr • https://uranusjr.com

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

http://macdown.uranusjr.com

Slide 12

Slide 12 text

https://docs.pipenv.org

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

https://xkcd.com/1987/

Slide 15

Slide 15 text

*NOT FINE

Slide 16

Slide 16 text

Application Dependencies Tools Interpreters

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Application Dependencies

Slide 19

Slide 19 text

$ python3 -m venv --prompt="project" .venv $ . .venv/bin/activate (project) $ pip install -r requirements.txt

Slide 20

Slide 20 text

cffi==1.5.2 cryptography==1.2.2 enum34==1.1.2 Flask==0.10.1 gunicorn==19.4.5 idna==2.0 ipaddress==1.0.16 itsdangerous==0.24 Jinja2==2.8 MarkupSafe==0.23 ndg-httpsclient==0.4.0 pyasn1==0.1.9 pycparser==2.14 pyOpenSSL==0.15.1 requests==2.9.1 six==1.10.0 Werkzeug==0.11.4 requests[security] flask gunicorn==19.4.5

Slide 21

Slide 21 text

https://gist.github.com/datagrok/2199506

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Python? Meh.

Slide 24

Slide 24 text

https://docs.pipenv.org

Slide 25

Slide 25 text

Pipenv • No more bin/activate • Subshell • Direct binary call • Declared dependencies • Locking into actual requirements

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Application Dependencies Tools

Slide 28

Slide 28 text

SUDO PIP INSTALL PIPENV

Slide 29

Slide 29 text

I TOLD YOU TO USE VIRTUAL ENVIRONMENTS

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

$ mkdir -p ~/.local/bin ~/.local/venvs $ python3 -m venv ~/.local/venvs/pipenv $ ~/.local/venvs/pipenv/bin/pip install pipenv $ ln -s ~/.local/venvs/pipenv/bin/pipenv ~/.local/bin $ pipenv --version pipenv, version 11.10.3

Slide 32

Slide 32 text

https://github.com/mitsuhiko/pipsi

Slide 33

Slide 33 text

Rules of Thumb • Do not use sudo. Ever. • Always use virtual environments • Use --user when desperate

Slide 34

Slide 34 text

$ python3 -m ~/.local/venvs/pipenv

Slide 35

Slide 35 text

Application Dependencies Tools Interpreters

Slide 36

Slide 36 text

I MEAN IT COULD BE WORSE

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Linux • Ubuntu: use “deadsnakes” PPA • Compile your own otherwise • Discussed later • Be careful with the package manager

Slide 39

Slide 39 text

macOS • Do not use System Python • Do not use Homebrew Python • Must compile your own

Slide 40

Slide 40 text

Compile Your Python • Install some build dependencies • pyenv install • You can use shims, but I hate them

Slide 41

Slide 41 text

$ python-build 3.6.5 ~/.local/pythons/3.6 $ python-build 3.5.4 ~/.local/pythons/3.5 $ ln -s ~/.local/pythons/3.6/python3.6 ~/.local/bin $ ln -s ~/.local/pythons/3.5/python3.5 ~/.local/bin $ ln -s ~/.local/bin/python3.6 ~/.local/bin/python3

Slide 42

Slide 42 text

$ python3.5 -V Python 3.5.4 $ python3 -V Python 3.6.5 $ python -V nope

Slide 43

Slide 43 text

https://github.com/uranusjr/pythonup-macos

Slide 44

Slide 44 text

$ pythonup install 3.6 # Build 3.6. $ pythonup upgrade 3.6 # Re-install if newer. $ pythonup use 3.6 # Link 3.6 scripts.

Slide 45

Slide 45 text

python() { local PYTHON="$(which python)" if [[ "$PYTHON" == /usr/* ]]; then echo "nope" >&2 | echo >/dev/null else "$PYTHON" "$@" fi } Hide the Default Python

Slide 46

Slide 46 text

Windows • No global Python to worry about • No support from pyenv • Building is drastically more difficult

Slide 47

Slide 47 text

https://vstinner.readthedocs.io/cpython_windows.html

Slide 48

Slide 48 text

! Just use installers from python.org?

Slide 49

Slide 49 text

" At least download them automatically?

Slide 50

Slide 50 text

https://github.com/uranusjr/pythonup-windows

Slide 51

Slide 51 text

$ pythonup install 3.6 # Download and install 3.6. $ pythonup upgrade 3.6 # Re-install if newer. $ pythonup use 3.6 # Link 3.6 scripts.

Slide 52

Slide 52 text

THE CIRCLE IS NOW COMPLETE

Slide 53

Slide 53 text

Summary (1/3) • Don’t use Homebrew Python • Prefer self-compiling if possible • Don’t add things to PATH; link* them

Slide 54

Slide 54 text

Summary (2/3) • Always use virtual environments • You can call scripts in venv directly • Link* them in PATH!

Slide 55

Slide 55 text

Summary (3/3) • Always use virtual environments (reprise) • Avoid activate scripts • Pipfile and Pipenv abstracts away warts

Slide 56

Slide 56 text

Future Work • A lot of unfinished stuff already • Differences when developing a package • pyproject.toml and build system declaration

Slide 57

Slide 57 text

JOIN!