Slide 1

Slide 1 text

BOOTSTRAPPING YOUR LOCAL PYTHON ENVIRONMENT CALVIN HENDRYX-PARKER, CTO SIX FEET UP Photo by on David Clode Unsplash

Slide 2

Slide 2 text

LET’S SET OUR INTENTION Photo by on $ python -m this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain it may be a good idea Sean Stratton Unsplash

Slide 3

Slide 3 text

https://xkcd.com/1987/

Slide 4

Slide 4 text

PYTHON LIVES IN MANY PLACES » Python provided by OS (macOS, RedHat, Ubuntu) » Python installed from an App Store (Microsoft Store) » Python installed from installer » Python installed from a Package Manager (apt, , ) » Python installed by a Python Distribution ( , ) python.org brew chocolatey ActiveState Anaconda

Slide 5

Slide 5 text

SO WHY SHOULD YOU CARE ABOUT ALL OF THIS? Photo by on Fermin Rodriguez Penelas Unsplash

Slide 6

Slide 6 text

STAY ZEN Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex.

Slide 7

Slide 7 text

SOME RULES

Slide 8

Slide 8 text

🚯 NO sudo

Slide 9

Slide 9 text

🚯 NO sudo I DON’T CARE, NO WHINING

Slide 10

Slide 10 text

📵 DO NOT USE THE SYSTEM PYTHON

Slide 11

Slide 11 text

📵 DO NOT USE THE SYSTEM PYTHON FOR ANYTHING

Slide 12

Slide 12 text

🤔 OK SMART GUY

Slide 13

Slide 13 text

PYENV » Change the global Python version on a per-user basis » Per-project Python versions » Override the Python version with an environment variable » Search commands from multiple versions of Python at a time https://github.com/pyenv/pyenv#installation https://pyenv-win.github.io/pyenv-win/

Slide 14

Slide 14 text

LET’S SEE pyenv IN ACTION 🚀 Explicit is better than implicit.

Slide 15

Slide 15 text

pyenv PLUGINS » virtualenv » virtualenvwrapper $ brew search pyenv

Slide 16

Slide 16 text

virtualenv & virtualenvwrapper

Slide 17

Slide 17 text

VIRTUAL ENVIRONMENTS ARE INCLUDED 🔋 IF YOU HAVE SIMPLE NEEDS, THIS IS FOR YOU! $ python -m venv venv

Slide 18

Slide 18 text

PIPX pipx is ready to go! ✨ 🌟 ✨ https://pypa.github.io/pipx/ $ brew install pipx $ pipx ensurepath

Slide 19

Slide 19 text

PIPX pipx is ready to go! ✨ 🌟 ✨ https://pypa.github.io/pipx/ $ brew install pipx $ pipx ensurepath LET’S DO SOME DAMAGE

Slide 20

Slide 20 text

PIPX pipx is ready to go! ✨ 🌟 ✨ https://pypa.github.io/pipx/ $ brew install pipx $ pipx ensurepath LET’S DO SOME DAMAGE $ pipx install httpie installed package httpie 2.4.0, Python 3.9.6 These apps are now globally available - http - https done! ✨ 🌟 ✨

Slide 21

Slide 21 text

WHAT ABOUT THE “USER SCHEME”? $ python -m pip install --user SomePackage

Slide 22

Slide 22 text

BUT WHAT ABOUT … » » » » » » Anaconda Python and Conda ActiveState Python pipenv poetry PDM pyproject.toml

Slide 23

Slide 23 text

BUT I WANT REPEATABILITY AND SIMPLICITY… » Simple is better than complex. piptools

Slide 24

Slide 24 text

I MEAN REALLY REPEATABLE… ENTER DOCKER + pip-tools

Slide 25

Slide 25 text

QUESTIONS? [email protected] @calvinhp