Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The Python Deployment Albatross - PyTennessee 2017
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Cindy Sridharan
February 05, 2017
Technology
1
530
The Python Deployment Albatross - PyTennessee 2017
Second stab at this talk.
Cindy Sridharan
February 05, 2017
Tweet
Share
More Decks by Cindy Sridharan
See All by Cindy Sridharan
Unmasking netpoll.go
copyconstructor
4
2.5k
Monitoring in the time of Cloud Native
copyconstructor
4
410
Prometheus - A Whirlwind Tour
copyconstructor
11
3.8k
Prometheus at Google NYC Tech Talks Nov 2016
copyconstructor
10
2.5k
Other Decks in Technology
See All in Technology
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
150
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
620
配列に見る bash と zsh の違い
kazzpapa3
1
130
生成AIを活用した音声文字起こしシステムの2つの構築パターンについて
miu_crescent
PRO
2
180
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.3k
変化するコーディングエージェントとの現実的な付き合い方 〜Cursor安定択説と、ツールに依存しない「資産」〜
empitsu
4
1.3k
SREチームをどう作り、どう育てるか ― Findy横断SREのマネジメント
rvirus0817
0
130
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
920
予期せぬコストの急増を障害のように扱う――「コスト版ポストモーテム」の導入とその後の改善
muziyoshiz
1
1.8k
[CV勉強会@関東 World Model 読み会] Orbis: Overcoming Challenges of Long-Horizon Prediction in Driving World Models (Mousakhan+, NeurIPS 2025)
abemii
0
110
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
700
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
Claude Code のすすめ
schroneko
67
210k
Crafting Experiences
bethany
1
48
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
[SF Ruby Conf 2025] Rails X
palkan
1
740
Transcript
The Python Deployment Albatross CINDY SRIDHARAN @COPYCONSTRUCT PYTENNESSEE FEBRUARY 5,
2017 NASHVILLE, TN
setup.py
What’s our goal?
Hermetically sealed, uniform, reproducible Python artifacts
Hermetically sealed
✓ Isolate pure Python dependencies ✓ Isolate compile time native/non-Python
dependencies ✓ Isolate runtime native/non-Python dependencies
uniform
Output of the build process is platform and architecture agnostic
Reproducible
A set of software development practices that create a verifiable
path from human readable source code to the binary code used by computers.
What is Python? python hello_world.py Python – or /usr/bin/python –
as your system understands it, is a program called the interpreter
How does Python know what to import from where? site.py
sys.prefix sys.exec_prefix
None
None
WHEELS VIRTUALENV PEX DOCKER CONDA NIX
wheels
but before wheels there were …
eggs-ecutable
purely a distribution format wheels
no build system needed on target host no C compiler
required wheels
wheels no arbitrary code execution like sdists Ergo faster installation
pip builds and caches wheels by default
ergo less tied to a specific version of Python Creates
.pyc files as a part of the installation wheels
manylinux wheels
None
virtualenv
helps “isolate Python environments”
✓ Isolates per-project pure Python dependencies from one another virtualenv
virtualenv ✓ Isolates per-project pure Python dependencies from system Python
✓ Isolates header files and shared libraries *if these are
packaged* virtualenv
greenlet.h is installed local to the virtualenv
… as is greenlet.so
Where virtualenv falls short Uses system provided headers and .so
files if not packaged
- - relocatable doesn’t always work
dh-virtualenv
PEX
Any directory with an __init__.py is considered a package Python
import quirks
__init__.py
Any directory with a __main__.py is treated as an executable
Python import quirks
__main__.py package is now executable
python –m package will execute package/__main__.py if it exists Python
import quirks
Adding #!/usr/bin/env python to the beginning of any module makes
it an executable Python executables
change permissions of file
Zipfiles A zipfile with an __init__.py is considered a package
Zipfiles A zipfile with a __main__.py is treated as an
executable
zip file is now executable
✓zip files don’t start until a magic zip number ✓
can add arbitrary strings at the start of the file ✓ #!/usr/bin/env python PEX
zip files are also used at Facebook
None
pex file
None
None
None
None
Uses system provided headers and .so files if not packaged
PEX
not cross-platform by default PEX
docker treats packaging as a namespacing problem
What does it mean to containerize a Python process?
Docker image for Python processes
BASE IMAGE DEVELOPMENT HEADERS AND LIBRARIES VIRTUALENV PEX
Best practices for building Docker images for Python ✓ small
images ✓ always use a virtualenv or pex ✓ single process per container
Dockerflow
Challenges of containerization
None
The Docker engine is a container runtime Overlay Networking With
1.12 in Swarm mode, it’s also a cluster scheduler Process manager … and much, much more (service discovery, load balancing, TLS ...) All compiled into one gigantic binary running as root
Logging Metrics Collection Observability Debugging
conda
CONDA or PIP?
PIP lacks a SAT solver
CONDA or WHEELS?
CONDA or VIRTUALENV?
CONDA or DOCKER?
VM ==> DOCKER :: DOCKER ==> CONDA
✓ Python or other modules ✓ System-level libraries ✓ Executable
programs conda package Can be downloaded from remote channels
all build dependencies need to be preinstalled in the build
prefix tarball files generated by the build script to produce a package
None
NIX
referential transparency
An expression is said to be referentially transparent if evaluating
it gives the same value for same arguments. Such functions are called pure functions.
nix expressions Nix expressions specify how to build nix packages,
including, if necessary, their dependencies.
different users have different “views” of the system profiles
profiles
garbage collection any package not in use (no symlinks) by
any generation of any profile
List of all dependencies, recursively, down to the bare minimum
necessary to use that derivation closure
channels a URL that points to a place that contains
a set of Nix expressions and a manifest
A use case for nix
✓ Statically linked Objective-C, C and Lua code ✓ Every
time there’s a MacOS upgrade, hosts need to be reimaged ✓ Application then needs to be recompiled ✓ A nix closure gets around this Why nix closures?
Conclusion ✓ Build wheels ✓ Use a virtualenv (or pex),
even with Docker ✓ Build small Docker images ✓ Explore conda/nix only if needed ✓ Good Luck!
@copyconstruct