Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Including a Build System

In this lesson, you’ll learn how to add a build system to pyproject.toml. You’ll also get to know other build systems and explore how Poetry works with pyproject.toml.

00:00 And I think we can now start to actually create our file. So, if you start by copying the section called build-system. Okay, just copy this? Copy this and put it into our pyproject.toml file.

00:13 Perfect. Okay, so I don’t need to really understand anything that’s going on here. I kind of just need to copy-paste it. Yeah. And the reason we need to do this is that setuptools is no longer the only way to install packages.

00:25 There are other ways to do it—with systems like Flit is one, Poetry is another, and so on. Right, Poetry. Poetry was—they used pyproject.toml for a while before Python started using it in this way, right? Well yeah, so, they started using pyproject.toml once Python kind of decided in an earlier PEP than the one we were looking at here, that pyproject.toml should be used for project specification. Okay, so this was sort of at the beginning, before things have started to move in this direction in a major way. Yeah, it’s kind of at the very start when they really started to define we need a specification for packaging.

01:03 So an idea of using pyproject.toml for a project specification is quite an old idea, and slowly, different build systems like Poetry have started to use it and, and now Python itself, with pip, is saying, “Okay, now we’re in the stage where we can get on board with all of this as well.” Yeah.

01:21 So, at the moment, I believe that Poetry still uses pyproject.toml, but with slightly different names on things. Okay, so it has a slightly different specification that doesn’t follow the PEP. Right, exactly. But they’re moving towards implementing the PEP as well. Okay.

01:38 So in the future, Poetry will essentially use, we can use exactly the same file— Except we just change "setuptools" to "poetry" basically. Yeah, exactly.

01:47 So we change the build system. And similarly, if we want to use Flit, we should be able to use the same project, so that we’ll soon set up. Right. But just change the build system. Okay.

01:57 And why would you want change your build system? Yeah, so, different build systems have different capabilities, in general. So setuptools is kind of a fairly basic one. That’s the most common— Common one.

02:08 That’s because of its history really. And it’s quite powerful, while Flit comes from a place where we just want to do things—simple things should be simple. So if you have a very simple system, then Flit

02:21 tries to make the setup much easier, and especially, it kind of integrates nicely with what you already have in Git or version control and things like that. Okay, so once you get much more experience with creating packages and stuff, then you might want to look at what different build systems can offer you for your, basically for your own workflow as a developer. Right.

02:40 And it might be slightly different from project to project. For instance, if you have things that depend on C extensions, then you might want to look at a different build system than if you have one with just pure Python, and so on. Okay, so by C extensions, you mean extensions or files or parts of the program that run in a different language than Python that you have to sort of wrap and bring into Python? Right, exactly.

Become a Member to join the conversation.