Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Deployment Tools and Techniques at Spotify: Virtualenv in debian by Chris Angove
1. 1
Spotify Tech
Web/iOS/Android/Native clients
Service oriented architecture > 50 services in Java and Python
Primarily using Cassandra for persistent storage
7,000 Servers in production
~500 in Engineers worldwide
2. 2
What have we been
doing?
Lost in the forest of dependency building
3. 3
Deploy via Debian Packages
Use Debian Stable repositories
Package/Backport needed libraries as needed
All Dependencies defined in Debian package
Deployed via Puppet/Aptitude
19. 19
Dh == Debian Helper
•
•
•
•
•
Registers itself as a Debian Helper
Bundles the requirements in requirements.txt into virtual environment
Deploys virtualenv into /usr/share/python/<package-name>
Still requires native dependencies to be installed via packaging
Just include the following in the debian/rules:
%:
dh
$@
-‐-‐with
python-‐virtualenv
22. 22
Example: Using Sentry
Define Dependencies in requirements.txt
sentry[postgres]==6.2.0
eventlet==0.13.0
hiredis==0.1.1
django-‐auth-‐ldap==1.1.4
23. 23
Example: Using Sentry
Define Debian dependencies in control file
Build-Depends:
python (>= 2.6.6-3~),
debhelper (>= 8),
dh-virtualenv,
python-dev,
libpq-dev,
libldap2-dev,
libsasl2-dev,
Standards-Version: 3.9.3
X-Python-Version: >= 2.6
24. 24
Example: Using Sentry
Use dh_virtualenv in Debian rules file
%:
dh $@ --with python-virtualenv
override_dh_virtualenv:
dh_virtualenv --index-url='http://localhost/simple'
25. 25
Have done this with RPMs as well (@ Amplify)
Within RPM build virtaulenv and mark it as
relocatable:
/usr/local/bin/virtualenv --no-site-packages build_venv
source build_venv/bin/activate
env CFLAGS="$RPM_OPT_FLAGS" easy_install -Z .
deactivate
/usr/local/bin/virtualenv --relocatable build_venv
37. 37
Thanks to Jyrki
Pulliainen and Jim
Whitehead @ Spotify
Stockholm!
Whitepaper:
http://labs.spotify.com/2013/10/10/packagingin-your-packaging-dh-virtualenv/
Code: https://github.com/spotify/dh-virtualenv
38. 38
Questions?
Chris Angove, Chapter Lead - Backend
Email: cangove@spotify.com
Blog: http://labs.spotify.com/
Listen: https://play.spotify.com/
39. Want to join the band?
Check out spotify.com/jobs or
@Spotifyjobs for more information.
January 24, 2014