Learn Python with Talk Python's 270 hours of courses

An Unbiased Evaluation of Environment and Packaging Tools

Episode #436, published Wed, Nov 1, 2023, recorded Thu, Sep 21, 2023

How well do you know your Python packaging tools? These are things like pip which install your project's dependencies and their dependencies and so on. In this mix, we have more modern tools such as Poetry, Flit, Hatch and others. And even tools outside of Python itself which may attempt to manage Python itself in addition to the libraries. To make sense of all of this, we welcome back Anna-Lena Popkes for an unbiased evaluation of environment and packaging tools.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guests Introduction and Background

Anna-Lena Popkes is a seasoned machine learning engineer at a German company (InnoVex) and currently working on speech recognition projects at Babbel. She’s been a frequent guest on Talk Python To Me, discussing topics like testing and Harry Potter-themed learning projects. She recently returned to share her deep dive into Python packaging, having created both a popular talk at PyCon (DE and EuroPython) and a comprehensive blog post that offers an unbiased overview of Python environment and packaging tools.

What to Know If You're New to Python

Here are a few essential ideas to help newer Python developers get more out of this episode:

  • Be aware that Python has built-in tools like pip and venv for managing packages and environments.
  • Familiarize yourself with the concept of virtual environments—these keep projects isolated so that dependencies don’t clash.
  • Understand that pyproject.toml can hold metadata and dependencies for modern Python packages.
  • Python packaging has multiple tools that aim to solve overlapping or similar problems (e.g., environment creation, dependency resolution, version control, publishing).

Key Points and Takeaways

  1. Consolidating an Unbiased View of Packaging Tools Anna-Lena embarked on creating a single reference to compare the many Python tools for environment, dependency, and packaging. By examining them in detail, she shows how certain tools excel at complete workflows (like Poetry), while others handle just one piece (like pipx for isolated CLI apps). This unbiased perspective highlights usage scenarios rather than just personal preference.
  2. Dependency Resolution and Lock Files One of the key reasons to adopt packaging tools beyond pip alone is to handle lock files. Lock files ensure identical installations across machines, preventing future conflicts caused by shifting library versions. This came up in the show in the context of tools like Poetry, Hatch, PDM, and pip-tools.
  3. Creating and Managing Virtual Environments The need for isolated environments is universal among Python developers. You can manually handle them via venv or virtualenv, or have your packaging tool (like Poetry or Hatch) create and activate them. Anna-Lena points out that a well-managed environment eliminates dependency conflicts and messy configurations.
  4. Python Version Management Often overlooked, choosing which Python version to install and run is critical. Some tools like Conda or pyenv (github.com/pyenv/pyenv) let you switch among versions seamlessly. Anna-Lena highlighted scenarios where multiple versions are needed (e.g., to test 3.10 vs. 3.11).
  5. Building vs. Publishing Building a Python package involves bundling code into distributable artifacts (e.g., wheels), while publishing means uploading these artifacts to PyPI or other indexes. Some tools (like Flit) excel at building minimal packages, while Poetry includes both build and publishing steps in one tool.
  6. Rye: A New All-in-One Approach Inspired by Rust tooling, Rye is a newer addition that can manage Python versions, create environments, and handle dependencies all in one place—without relying on an existing Python install. Its rapid development is partially driven by big-name maintainers, and it aims to streamline everything from environment creation to publishing.
  7. Working as a Team and Avoiding Conflicts Anna-Lena mentioned how team preferences (and biases) affect tool choice. With many packaging tools, choosing one that everyone is comfortable using—and that meets the team's workflow—can avert frustration. Lock files, consistent environment creation, and project-level config are especially helpful.
  8. Managing Large Repos and Monorepos Large Python codebases often have conflicting dependencies if everything is lumped into a single environment. Tools like Hatch support multiple environment definitions for testing, docs, and more. This separation ensures you only install what you need for each part of your codebase.

Interesting Quotes and Stories

  • “One of my colleagues very strongly dislikes Poetry because of a breaking change they introduced without warning—so sometimes personal experience can influence tool choice.”
  • “I realized how complicated packaging is when someone asked me which tool to use, and I didn’t even have a short answer. I just knew there were way too many options.”

Key Definitions and Terms

  • pyproject.toml: A central config file for Python projects, specifying metadata, dependencies, and build backends.
  • Editable Installs: Installing a project in a way that code changes are immediately reflected without reinstalling (pip install -e).
  • Lock File: A file listing the exact versions (plus hashes) of all installed dependencies, guaranteeing reproducible environments.
  • Build Backend: The underlying tool that handles creating distributable package files (e.g., Poetry, Hatchling, Flit, or setuptools).

Learning Resources

Here are some deeper-dive resources to build on the topics from this episode:

Overall Takeaway

Python packaging and environment management can feel overwhelming given the huge array of available tools. Anna-Lena’s unbiased exploration shows that each utility—from pip and Poetry to Rye—provides its own distinctive path to the same broad goals: isolation, reproducibility, and efficient distribution. With the right combination of knowledge (like the difference between building and publishing) and modern tools that streamline the process, developers can overcome packaging headaches and enjoy a more seamless Python experience.

Links from the show

Anna-Lena's website: alpopkes.com
Anna-Lena on GitHub: github.com
Accompanying Blog Post: alpopkes.com
Talk from PyCon DE: youtube.com
Talk from EuroPython: youtube.com

Talk Python's Data Science Jumpstart with 10 Projects course: talkpython.fm

Rye: github.com
Poetry: python-poetry.org
Material for MkDocs: squidfunk.github.io
100 Days of Python in a Magical Universe Episode: talkpython.fm
pip-tools: pip-tools.readthedocs.io
Hatch: hatch.pypa.io
PDM: pdm.fming.dev
Flit: flit.pypa.io
Conda: docs.conda.io
Pipenv: pipenv.pypa.io
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon