Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Packaging Python applications

Packaging Python applications

The past, present and future solutions to this horrible problem.

Piotr Banaszkiewicz

October 18, 2013
Tweet

More Decks by Piotr Banaszkiewicz

Other Decks in Programming

Transcript

  1. Packaging solutions Packaging solutions “Old” “Current” “New” eggs Buildout Fabric

    (*) virtualenv Global (site-packages) Vagrant System packages (DEBs, RPMs, etc) wheels LXC (Docker)
  2. Python eggs ✔ Python importables ✔ Handle Python binary package

    ✗ Don't solve project dependencies ✗ Tied to Python version – need to be built for target systems (include .pyc files) ✗ Not a standard + old age, bad naming convention
  3. Buildout ✔ Dependency and configuration management ✗ Requires lots of

    configuration itself ✗ Sort of steep learning curve
  4. Fabric • Used as a package solution :O ✗ …but

    it's not intended to. Conclusion: please don't.
  5. Python global site-packages • Making your project a Python package

    is good. • Installing your project system wide may be wrong.
  6. Vagrant • Automatization + virtualization = Vagrant • Big companies

    use it to speed setting up development, to save resources • Take a look at my last year's PyCon PL presentation “A Thing About Vagrant” https://speakerdeck.com/pbanaszkiewicz/
  7. Vagrant ✔ Portable development environments ✔ You have everything under

    control ✗ VMs are heavy ✗ ...and sometimes wonky Conclusion: it's awesome.
  8. System packages • .debs, .rpms • Think: virtualenv with your

    whole project installed from Linux package
  9. System packages • It's hard to package virtualenvs into RPM.

    • Too much effort for too little gain. • Alex Hudson, Packaging a virtualenv: really not relocatable http://www.alexhudson.com/2013/05/24/packaging-a -virtualenv-really-not-relocatable/
  10. System packages • Impossible to create generic DEB or RPM

    with virtualenv in it • But if you control target host... Then it's feasible
  11. System packages: fpm • fpm – to create DEBs and

    RPMs quickly • Does not follow Debian policy nor RPM packaging guidelines • But supposedly works • Listen to Hynek Schlawack's talks or read his blog posts: hynek.me, “Python Application Deployment with Native Packages”
  12. System packages: dh-virtualenv • Fresh: about one and half week

    old • By Spotify • Builds “correct” DEBs with necessary dependencies from requirements file and with virtualenv inside • Has some limitations (like installation path) • https://github.com/spotify/dh-virtualenv
  13. Wheels • Package format for Python (for binary packages too!)

    • Package names: package-version-pythonversion-abi-platform.whl • Supports signed packages! • It's quick
  14. LXC and Docker • Containers: think about smaller, lighter virtual

    machines with no CPU or memory overhead • Buzz around Docker
  15. Docker ✔ Great idea ✔ Containers are smoother than virtual

    machines ✗ Concerns about AUFS file system ✗ Apparently software is full of bugs ✗ So are linux containers
  16. Docker as a packaging solution • Build LXC with everything

    included • (Simply put shell commands in Dockerfile) • Would be round 100MB (?), compared to smallest Vagrant boxes weighting 300-400MB
  17. Thank you for listening • Snake with eggs: “Ball Python

    with eggs”, http://www.lihs.org/files/photos4.htm • Thankful kitten: google for “Cute Cat” • Sad pug: reise.bt.no • Python on wheels: “Snakes Need Wheels - Snake Push Toy” on Flickr • Any questions? Piotr Banaszkiewicz @pbanaszkiewicz
  18. Bonus: PEP 453 • Pip will be included within Python

    3.4 • And will be a default package manager for Python