Virtual environments are a fundamental part of Python development, but to most developers, they’re largely a ‘black box’. In this talk, we’re gonna dissect the code, file structure and utilities that make them up to deeply learn, and not just have superficial knowledge of, how venvs actually work.
No previous skills or specific knowledge is required to enjoy the talk.
We all use virtual environments, but do we know how they work? What’s inside a virtual environment? Why do we even have to ‘activate’ them anyways, and what does that mean in the first place? In this talk, we’re gonna discover that.
First, we’ll need to go over how Python installs work in modern operating systems (hopefully, the days of xkcd 1987 https://xkcd.com/1987/ are long gone), and how we can’t isolate projects without the aid of a tool such as these virtual environments.
Then, we’ll go over the files and folders inside venvs, examine their purpose, and browse through the venv module source code to understand the CLI tool we use every day. We’ll install some deps and see how those fit inside this virtual environment structure.
Lastly, we’ll check which problems are not solved by virtual environments, its limitations depending on the scope we’re looking for (i.e, a venv is not a container! And shouldn’t be used as such!), and how, lately, many libraries which purpose overlap with those of venvs are actually wrapping over this functionality so that you don’t have to manage it yourself (beware the law of leaky abstractions!).
Daniel is a software engineer with a background in first, local, and then international and VC-backed startups. He's now the lead engineer at Reckon Digital, where he directs and coordinates several projects with clients such as the UN's World Food Programme.