SlideShare a Scribd company logo
1 of 30
Download to read offline
dh-virtualenv 
Packaging in packaging
@nailor 
Jyrki Pulliainen 
jyrki@spotify.com 
Photo credit: Pontus Persson
What’s in this talk? 
• Look at different, existing deployment strategies 
• What is dh-virtualenv? 
• Packaging sentry with dh-virtualenv
virtualenv
+ Stable 
+ Non-Python Dependencies 
+ Existing infrastructure 
+ Scripting
- Out of date 
- Complex 
- Global state
+ Has the new stuff 
+ De facto 
+ Battle tested 
+ Contained 
virtualenv
- Native dependency 
handling 
- Source installs 
- Random scripts 
sh: mysql_config: command not found
What is dh-virtualenv?
Virtualenv inside a Debian package
It’s Open Source! 
• GPL’d 
• Documented 
• Comes with a simple tutorial!
It’s a DebHelper Extension 
• Idea stolen adapted from @hynek 
* https://hynek.me/articles/python-app-deployment-with-native-packages/
In practice?
Package builder that… 
1. Creates a virtualenv 
2. Installs requirements.txt into that virtualenv 
3. Installs your project 
4. Fixes the virtualenv to match production
Packaging with dh-virtualenv 
Case in point: sentry
1. Install dh-virtualenv 
apt-get install dh-virtualenv 
2. Create ‘debian’ directory 
3. Insert the minimal boilerplate files in there
debian/control: 
Source: sentry 
Section: python 
Priority: extra 
Maintainer: Jyrki Pulliainen <jyrki@spotify.com> 
Build-Depends: debhelper (>= 9), python, dh-virtualenv, 
python-dev 
Standards-Version: 3.9.5 
Package: sentry 
Architecture: any 
Depends: ${python:Depends}, ${misc:Depends} 
Description: dh-virtualenv-packaged sentry 
Amazing tool, now packaged with dh-virtualenv!
debian/changelog: 
sentry (6.4.4-1) unstable; urgency=low 
* Initial packaging with dh-virtualenv 
-- Jyrki Pulliainen <jyrki@spotify.com> Wed, 23 Jul 2014 12:02:20 +0200
echo 9 > debian/compat
debian/rules: 
#!/usr/bin/make -f 
%: 
dh $@ --with python-virtualenv
5. Build your package! 
dpkg-buildpackage
dpkg-buildpackage: source package dh-virtualenv 
dpkg-buildpackage: source version 0.7-2 
dpkg-buildpackage: source distribution unstable 
dpkg-buildpackage: source changed by Jyrki Pulliainen <jyrki@spotify.com> 
dpkg-buildpackage: host architecture i386 
dpkg-source --before-build dh-virtualenv 
fakeroot debian/rules clean 
dh clean --with python2 --with sphinxdoc 
dh_testdir 
debian/rules override_dh_auto_clean 
make[1]: Entering directory `/vagrant_src/dh-virtualenv' 
rm -rf doc/_build 
rm -f doc/dh_virtualenv.1 
rm -rf dh_virtualenv.egg-info 
dh_auto_clean 
running clean 
'build/lib.linux-i686-2.7' does not exist -- can't clean it 
'build/bdist.linux-i686' does not exist -- can't clean it 
removing 'build/scripts-2.7' (and everything under it) 
make[1]: Leaving directory `/vagrant_src/dh-virtualenv' 
dh_clean 
dpkg-source -b dh-virtualenv 
dpkg-source: error: can't build with source format '3.0 (quilt)': no upstream tarball found at ../ 
dh-virtualenv_0.7.orig.tar.{bz2,gz,lzma,xz}
dh_virtualenv 
Running virtualenv with interpreter /usr/bin/python2 
New python executable in debian/sentry/usr/share/python/sentry/bin/python2 
Also creating executable in debian/sentry/usr/share/python/sentry/bin/python 
Installing setuptools, pip...done. 
Unpacking /vagrant_src/sentry-with-dh-virtualenv 
Running setup.py (path:/tmp/pip-ttX1Ip-build/setup.py) egg_info for package from file:/// 
vagrant_src/sentry-with-dh-virtualenv 
warning: no previously-included files matching '*~' found anywhere in distribution 
Downloading/unpacking BeautifulSoup>=3.2.1,<3.3.0 (from sentry==6.4.4) 
Downloading BeautifulSoup-3.2.1.tar.gz 
Running setup.py (path:/vagrant_src/sentry-with-dh-virtualenv/debian/sentry/usr/share/python/ 
sentry/build/BeautifulSoup/setup.py) egg_info for package BeautifulSoup 
Downloading/unpacking celery>=3.0.15,<3.1.0 (from sentry==6.4.4) 
Downloading celery-3.0.25.tar.gz (1.1MB): 1.1MB downloaded 
Running setup.py (path:/vagrant_src/sentry-with-dh-virtualenv/debian/sentry/usr/share/python/ 
sentry/build/celery/setup.py) egg_info for package celery 
Upgrade: no old version found. 
no previously-included directories found matching '*.pyc' 
no previously-included directories found matching '*.sw*’
5. Install the shiny Debian package in production!
+ Non-Python dependencies 
+ Existing Infrastructure 
+ The new hotness 
+ Contained 
dh-virtualenv
- Can be slow to build 
- Requires still digging for requirements 
- Build system needs to have the exactly 
same Python 
dh-virtualenv
Thanks! 
github.com/spotify/dh-virtualenv 
dh-virtualenv.readthedocs.org 
labs.spotify.com/2013/10/10/packaging-in-your- 
packaging-dh-virtualenv/

More Related Content

What's hot

Puppet Camp Charlotte 2015: Exporting Resources: There and Back Again
Puppet Camp Charlotte 2015: Exporting Resources: There and Back AgainPuppet Camp Charlotte 2015: Exporting Resources: There and Back Again
Puppet Camp Charlotte 2015: Exporting Resources: There and Back Again
Puppet
 

What's hot (20)

Dockerを利用したローカル環境から本番環境までの構築設計
Dockerを利用したローカル環境から本番環境までの構築設計Dockerを利用したローカル環境から本番環境までの構築設計
Dockerを利用したローカル環境から本番環境までの構築設計
 
The Zen of High Performance Messaging with NATS (Strange Loop 2016)
The Zen of High Performance Messaging with NATS (Strange Loop 2016)The Zen of High Performance Messaging with NATS (Strange Loop 2016)
The Zen of High Performance Messaging with NATS (Strange Loop 2016)
 
Networking in Kubernetes
Networking in KubernetesNetworking in Kubernetes
Networking in Kubernetes
 
Reproducibility of computational workflows is automated using continuous anal...
Reproducibility of computational workflows is automated using continuous anal...Reproducibility of computational workflows is automated using continuous anal...
Reproducibility of computational workflows is automated using continuous anal...
 
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on DockerRunning High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
 
TAPIR PyWrapper3, at GBIF GB14 nodes meeting (2007)
TAPIR PyWrapper3, at GBIF GB14 nodes meeting (2007)TAPIR PyWrapper3, at GBIF GB14 nodes meeting (2007)
TAPIR PyWrapper3, at GBIF GB14 nodes meeting (2007)
 
Puppet Camp Charlotte 2015: Exporting Resources: There and Back Again
Puppet Camp Charlotte 2015: Exporting Resources: There and Back AgainPuppet Camp Charlotte 2015: Exporting Resources: There and Back Again
Puppet Camp Charlotte 2015: Exporting Resources: There and Back Again
 
Docker Runtime Security
Docker Runtime SecurityDocker Runtime Security
Docker Runtime Security
 
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, DockerUnder the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
 
Openstack meetup lyon_2017-09-28
Openstack meetup lyon_2017-09-28Openstack meetup lyon_2017-09-28
Openstack meetup lyon_2017-09-28
 
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and BeyondTectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
 
Debugging Network Issues
Debugging Network IssuesDebugging Network Issues
Debugging Network Issues
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
 
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみる
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみるK8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみる
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみる
 
Cluster Lifecycle Landscape
Cluster Lifecycle LandscapeCluster Lifecycle Landscape
Cluster Lifecycle Landscape
 
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
 
Software development practices in python
Software development practices in pythonSoftware development practices in python
Software development practices in python
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
 
Kubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby StepsKubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby Steps
 

Similar to Packaging in packaging: dh-virtualenv

5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenv
amenasse
 
Empacotamento e backport de aplicações em debian
Empacotamento e backport de aplicações em debianEmpacotamento e backport de aplicações em debian
Empacotamento e backport de aplicações em debian
Andre Ferraz
 
Binary Packaging for HPC with Spack
Binary Packaging for HPC with SpackBinary Packaging for HPC with Spack
Binary Packaging for HPC with Spack
inside-BigData.com
 

Similar to Packaging in packaging: dh-virtualenv (20)

Debian Packaging
Debian PackagingDebian Packaging
Debian Packaging
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenv
 
Software Packaging for Cross OS Distribution
Software Packaging for Cross OS DistributionSoftware Packaging for Cross OS Distribution
Software Packaging for Cross OS Distribution
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Docker and DevOps --- new IT culture
Docker and DevOps --- new IT cultureDocker and DevOps --- new IT culture
Docker and DevOps --- new IT culture
 
Python+gradle
Python+gradlePython+gradle
Python+gradle
 
Debian packaging
Debian packagingDebian packaging
Debian packaging
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
AWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
AWS EC2 Ubuntu Instance - Step-by-Step Deployment GuideAWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
AWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
 
Empacotamento e backport de aplicações em debian
Empacotamento e backport de aplicações em debianEmpacotamento e backport de aplicações em debian
Empacotamento e backport de aplicações em debian
 
Binary Packaging for HPC with Spack
Binary Packaging for HPC with SpackBinary Packaging for HPC with Spack
Binary Packaging for HPC with Spack
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)
 
Vagrant crash course
Vagrant crash courseVagrant crash course
Vagrant crash course
 
Introduction to Docker
Introduction  to DockerIntroduction  to Docker
Introduction to Docker
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Packaging in packaging: dh-virtualenv

  • 2. @nailor Jyrki Pulliainen jyrki@spotify.com Photo credit: Pontus Persson
  • 3. What’s in this talk? • Look at different, existing deployment strategies • What is dh-virtualenv? • Packaging sentry with dh-virtualenv
  • 5. + Stable + Non-Python Dependencies + Existing infrastructure + Scripting
  • 6.
  • 7. - Out of date - Complex - Global state
  • 8. + Has the new stuff + De facto + Battle tested + Contained virtualenv
  • 9.
  • 10. - Native dependency handling - Source installs - Random scripts sh: mysql_config: command not found
  • 12. Virtualenv inside a Debian package
  • 13. It’s Open Source! • GPL’d • Documented • Comes with a simple tutorial!
  • 14. It’s a DebHelper Extension • Idea stolen adapted from @hynek * https://hynek.me/articles/python-app-deployment-with-native-packages/
  • 16. Package builder that… 1. Creates a virtualenv 2. Installs requirements.txt into that virtualenv 3. Installs your project 4. Fixes the virtualenv to match production
  • 17. Packaging with dh-virtualenv Case in point: sentry
  • 18. 1. Install dh-virtualenv apt-get install dh-virtualenv 2. Create ‘debian’ directory 3. Insert the minimal boilerplate files in there
  • 19. debian/control: Source: sentry Section: python Priority: extra Maintainer: Jyrki Pulliainen <jyrki@spotify.com> Build-Depends: debhelper (>= 9), python, dh-virtualenv, python-dev Standards-Version: 3.9.5 Package: sentry Architecture: any Depends: ${python:Depends}, ${misc:Depends} Description: dh-virtualenv-packaged sentry Amazing tool, now packaged with dh-virtualenv!
  • 20. debian/changelog: sentry (6.4.4-1) unstable; urgency=low * Initial packaging with dh-virtualenv -- Jyrki Pulliainen <jyrki@spotify.com> Wed, 23 Jul 2014 12:02:20 +0200
  • 21. echo 9 > debian/compat
  • 22. debian/rules: #!/usr/bin/make -f %: dh $@ --with python-virtualenv
  • 23. 5. Build your package! dpkg-buildpackage
  • 24. dpkg-buildpackage: source package dh-virtualenv dpkg-buildpackage: source version 0.7-2 dpkg-buildpackage: source distribution unstable dpkg-buildpackage: source changed by Jyrki Pulliainen <jyrki@spotify.com> dpkg-buildpackage: host architecture i386 dpkg-source --before-build dh-virtualenv fakeroot debian/rules clean dh clean --with python2 --with sphinxdoc dh_testdir debian/rules override_dh_auto_clean make[1]: Entering directory `/vagrant_src/dh-virtualenv' rm -rf doc/_build rm -f doc/dh_virtualenv.1 rm -rf dh_virtualenv.egg-info dh_auto_clean running clean 'build/lib.linux-i686-2.7' does not exist -- can't clean it 'build/bdist.linux-i686' does not exist -- can't clean it removing 'build/scripts-2.7' (and everything under it) make[1]: Leaving directory `/vagrant_src/dh-virtualenv' dh_clean dpkg-source -b dh-virtualenv dpkg-source: error: can't build with source format '3.0 (quilt)': no upstream tarball found at ../ dh-virtualenv_0.7.orig.tar.{bz2,gz,lzma,xz}
  • 25. dh_virtualenv Running virtualenv with interpreter /usr/bin/python2 New python executable in debian/sentry/usr/share/python/sentry/bin/python2 Also creating executable in debian/sentry/usr/share/python/sentry/bin/python Installing setuptools, pip...done. Unpacking /vagrant_src/sentry-with-dh-virtualenv Running setup.py (path:/tmp/pip-ttX1Ip-build/setup.py) egg_info for package from file:/// vagrant_src/sentry-with-dh-virtualenv warning: no previously-included files matching '*~' found anywhere in distribution Downloading/unpacking BeautifulSoup>=3.2.1,<3.3.0 (from sentry==6.4.4) Downloading BeautifulSoup-3.2.1.tar.gz Running setup.py (path:/vagrant_src/sentry-with-dh-virtualenv/debian/sentry/usr/share/python/ sentry/build/BeautifulSoup/setup.py) egg_info for package BeautifulSoup Downloading/unpacking celery>=3.0.15,<3.1.0 (from sentry==6.4.4) Downloading celery-3.0.25.tar.gz (1.1MB): 1.1MB downloaded Running setup.py (path:/vagrant_src/sentry-with-dh-virtualenv/debian/sentry/usr/share/python/ sentry/build/celery/setup.py) egg_info for package celery Upgrade: no old version found. no previously-included directories found matching '*.pyc' no previously-included directories found matching '*.sw*’
  • 26. 5. Install the shiny Debian package in production!
  • 27.
  • 28. + Non-Python dependencies + Existing Infrastructure + The new hotness + Contained dh-virtualenv
  • 29. - Can be slow to build - Requires still digging for requirements - Build system needs to have the exactly same Python dh-virtualenv
  • 30. Thanks! github.com/spotify/dh-virtualenv dh-virtualenv.readthedocs.org labs.spotify.com/2013/10/10/packaging-in-your- packaging-dh-virtualenv/