Unpack Python Packages 📦

Deep dive into the wheels of python packaging

Alexander Hultnér PyCon SE, 2021

@ahultner

Alexander Hultnér

Founder of Hultnér Technologies and Papero.io

 

 

@ahultner

Hultnér Technologies

  • Alexander Hultnér
  • Magnus Junghard
  • Office in Gothenburg
  • Consulting
  • In-house development
  • Looking to hire!

 

contact@hultner.se

 

@ahultner

About us

Outline

  • Why do we care?
  • What is a Python Package?
  • Distribution types
    • Source distribution
    • Eggs
    • Wheels
  • Hands on!
    • Deconstruct a package
    • Build a package from scratch
  • Modern tooling
  • More resources
  • Q&A

@ahultner

Why do we care?

  • Distribution
  • Code sharing, reusability
  • Separation of concerns
  • Understand the magic behind the curtains

@ahultner

  • Bundle
  • Distribution format
  • Python Libraries
  • Applications / dev tools
  • PyPI
  • Private Repositories

What's a Python Package?

Quick introduction


 

@ahultner

  • Source distributions
    • (sdist), .tar.gz
  • Eggs
    • .egg
  • Wheels
    • .whl

 

Formats

Python Packaging Formats


 

@ahultner

  • Source distributions
  • Usually pkg.tar.gz files
    • pkg.zip
    • pkg.tar.[bz2, xz, (Z*)]
  • Source code
  • Needs to be compiled
  • Distribute to unsupported platforms
  • Executes setup.py for dependencies

 

sdist

Python Packaging Formats


 

@ahultner

  • De-facto standard
  • .egg files
  • Compiled "binary distribution"
  • Legacy format replaced by standard

 

Egg

Python Packaging Formats


 

@ahultner

  • "New" standard format
    • PEP 427 accepted 2013
  • Replaces eggs, can convert to whl
  • Installation format
  • .whl-files
    • Compatibility targets in file name
  • Resolve dependencies statically
  • No need for setup.py
  • Signed, RECORD checked on install
  • Versioned format

 

Wheel

Python Packaging Formats


 

@ahultner

Hands on session

Explore python packages


 

@ahultner

Conclusion

  • sdist is for source code
  • Wheels replaces eggs
  • Wheels simple zipfiles
    • Static metadata format
    • Enables faster and better tooling
  • We can now distribute binary packages natively without conda
  • Packaging is easy with modern tools

@ahultner

Questions

Contact me if you have any further

questions.

 

 

Want to learn more?

Available for training, workshops and

freelance consulting.

 

Sign up for book updates!

Papero.io/beta

Links

@ahultner

Made with Slides.com