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

The Python Deployment Albatross - PyTennessee 2017

The Python Deployment Albatross - PyTennessee 2017

Second stab at this talk.

Cindy Sridharan

February 05, 2017
Tweet

More Decks by Cindy Sridharan

Other Decks in Technology

Transcript

  1. ✓ Isolate pure Python dependencies ✓ Isolate compile time native/non-Python

    dependencies ✓ Isolate runtime native/non-Python dependencies
  2. A set of software development practices that create a verifiable

    path from human readable source code to the binary code used by computers.
  3. What is Python? python hello_world.py Python – or /usr/bin/python –

    as your system understands it, is a program called the interpreter
  4. ergo less tied to a specific version of Python Creates

    .pyc files as a part of the installation wheels
  5. PEX

  6. ✓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
  7. Best practices for building Docker images for Python ✓ small

    images ✓ always use a virtualenv or pex ✓ single process per container
  8. 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
  9. ✓ Python or other modules ✓ System-level libraries ✓ Executable

    programs conda package Can be downloaded from remote channels
  10. all build dependencies need to be preinstalled in the build

    prefix tarball files generated by the build script to produce a package
  11. NIX

  12. An expression is said to be referentially transparent if evaluating

    it gives the same value for same arguments. Such functions are called pure functions.
  13. nix expressions Nix expressions specify how to build nix packages,

    including, if necessary, their dependencies.
  14. List of all dependencies, recursively, down to the bare minimum

    necessary to use that derivation closure
  15. channels a URL that points to a place that contains

    a set of Nix expressions and a manifest
  16. ✓ 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?
  17. Conclusion ✓ Build wheels ✓ Use a virtualenv (or pex),

    even with Docker ✓ Build small Docker images ✓ Explore conda/nix only if needed ✓ Good Luck!