Exploring Other Build Systems
In the previous lesson, I did a deeper dive on the available configuration options in your
pyproject.toml file. In this lesson, I’ll briefly demonstrate two alternate build systems, Flit and Poetry.
Flit is an alternate build system you can use instead of
setuptools. It’s simpler than most of the alternatives and doesn’t support things like C extensions. Because of this limitation, it means you have far fewer things to worry about for your project and its configuration. It’s not compatible with
setuptools, so you need different entries in your
I’ll be showing you a new file that’s not the one in the
reader repo. Like most packages—a bit of foreshadowing there on most—Flit is installed through
pip. Let me show you what it looks like to use this tool.
Once you’ve got Flit installed, to get going, you use
flit init. It will ask you some questions. First off, the name of the module, which it detects from the directory if you’re already in the package folder.
Like the example I mentioned in the previous lesson, Flit uses the
dynamic field. Here it’s saying it’ll generate the version and description for you based on an expected
__version__ value and a docstring inside of
Another popular build system is Poetry. It’s a bit more complicated than Flit and includes a very powerful dependency management feature. If you’re dealing with a larger project with a lot of interrelated dependencies, Poetry just might be the tool for you. Like Flit, it isn’t compatible with
setuptools and needs its own stuff in the
pyproject file. And although you can install it using
pip, the docs suggest against it. It has its own custom installer.
If you’re starting from scratch and don’t even have a project structure yet, the
poetry new command will generate the directory and give you some skeleton files. If, like us, you’ve already got a project structure, you use the
poetry init command instead.
03:09 Like Flit, it asks you some questions. It takes a guess at the name. Note the default here. Flit looked in the source directory, and so it saw a reader. Poetry looks at the package directory, which I’ve renamed so that I can demonstrate the three different build systems.
You can have it interactively ask about dependencies, but you’ve seen those before, so I’m going to skip this. And likewise, for dev dependencies. The resulting
pyproject file gets printed to the screen.
This allows Poetry to use whatever attributes it wants rather than having to stick to the PEP definition. This is, again, sort of a history thing. Poetry’s been around for a bit and has been trying to solve some of the problems that are now solved in
setuptools but weren’t before.
04:41 Like with my Flit example, there’s a bunch of missing stuff here. I skipped the dependency steps and didn’t do anything about the script callouts. So this isn’t a feature-full example, but you get the idea.
Become a Member to join the conversation.