Register to get access to free programming courses with interactive exercises

Building a package distribution using Poetry Python: Setting up the environment

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:

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

<span class="translation_missing" title="translation missing:">Bookmate</span>
<span class="translation_missing" title="translation missing:">Healthsamurai</span>
<span class="translation_missing" title="translation missing:">Dualboot</span>
<span class="translation_missing" title="translation missing:">Abbyy</span>
Suggested learning programs
Developing web applications with Django
10 months
from scratch
under development
Start at any time

Use Hexlet to the fullest extent!

  • Ask questions about the lesson
  • Test your knowledge in quizzes
  • Practice in your browser
  • Track your progress

Sign up or sign in

By sending this form, you agree to our Personal Policy and Service Conditions
Toto Image

Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.