How do Python virtual environments work under the hood? How does understanding these concepts help you with managing them for your projects? This week on the show, CPython core developer Brett Cannon returns to discuss his recent articles about virtual environments and the Python packaging landscape.
Brett talks about his recent article “How Virtual Environments Work.” He was researching the topic to solve an issue with a Linux Python distribution that doesn’t provide the tools to create virtual environments. We talk about how he solved the problem by creating a tiny library named microvenv.
We also take a look at the Python packaging ecosystem. Brett talks about the early days of Python, when these tools didn’t exist. He contrasts that with the current packaging solution explosion and how each one attempts to solve unique problems. We also discuss the Python Packaging User Survey and the plans for packaging summits at PyCon US. Note that we recorded this episode two weeks before PyCon US 2023.
Course Spotlight: Getting the Most Out of the Python Standard REPL
In this video course, you’ll learn how to use the Python standard REPL (Read-Eval-Print Loop) to run your code interactively. This tool will allow you to test new ideas, explore and experiment with new tools and libraries, refactor and debug your code, try out examples, and more.
Topics:
- 00:00:00 – Introduction
- 00:01:58 – Virtual environments
- 00:07:10 – PEP 704 & virtual environment workflows
- 00:26:57 – Experimenting with not including
pip
- 00:34:44 – Video Course Spotlight
- 00:36:35 – What are you using for packaging?
- 00:43:32 – Python Packaging User Survey & the history of packaging
- 00:48:40 – Packing only gets complex when it’s not pure Python code
- 01:01:22 – Outcomes after the survey and the packaging summit
- 01:03:56 – What are you excited about in the world of Python?
- 01:05:28 – What’s something you want to learn next?
- 01:07:12 – How can people follow the work that you do?
- 01:08:14 – Thanks and goodbye
Show Links:
- How virtual environments work
- PEP 704 – Require virtual environments by default for package installers - peps.python.org
- microvenv - PyPI
- python-launcher: Python launcher for Unix - GitHub
- bootstrap.pypa.io
- Classifying Python virtual environment workflows
- Python Packaging User Survey - Results PDF
- Thoughts on the Python packaging ecosystem - Pradyun Gedam
- pypa/packaging: Core utilities for Python packages - GitHub
- Flit 3.8.0 - Flit 3.8.0 documentation
- hatch - PyPI
- hatchling - PyPI
- Episode #93: Launching Python, Virtual Environments, and Locking Dependencies With Brett Cannon – The Real Python Podcast
- PEP 665 – A file format to list Python dependencies for reproducibility of an application - peps.python.org
- Programming Rust, 2nd Edition
- Tall, Snarky Canadian - Brett’s Blog
- Microsoft Python Blog
- Visual Studio Code Blog
- Brett Cannon (@brettcannon@fosstodon.org) - Mastodon
Level up your Python skills with our expert-led courses: