When your project is ready to be shared with others, it's time to build the code. The compiled distribution doesn't need Poetry anymore. The program will run without it.
It is where Poetry comes in again. In this tutorial, we'll learn how to build and install the distribution.
Building and installing the distribution kit
Usually, Poetry projects are almost ready to build their distributions. Some cases require additional configuration steps. But we won't go into that because it's irrelevant.
You can build a simple project using the poetry build
command:
poetry build
Building hello (0.1.0)
- Building sdist
- Built hello-0.1.0.tar.gz
- Building wheel
- Built hello-0.1.0-py3-none-any.whl
Run this command in the root directory of the project. You will see a dist/
directory with two files with different extensions.
First, we look at a file with the .whl
extension, which is short for wheel. This file is already suitable for installation using pip. Let's install it in the user's environment: