Packages

Learn how to package a Python project.

Here, we discuss the basics of packaging a Python project that can be published in a repository. The default repository might be PyPi (the Python Package Index), but also could be internal; or custom setups will work with the same basics.

Creating a Python library

We are going to simulate that we have created a small library, and we will use that as an example to review the main points to take into consideration.

Press + to interact

Aside from all the open-source libraries available, sometimes we might need some extra functionality—perhaps our application uses a particular idiom repeatedly or relies on a function or mechanism quite heavily and the team has devised a better function for these particular needs. In order to work more effectively, we can place this abstraction into a library and encourage all team members to use the idioms as provided by it, because doing so will help avoid mistakes and reduce bugs.

That's typically the case when we own a service and a client library for that service. We don't want clients calling our API directly, so instead, we provide them with a client library. The code for this library will be wrapped into a Python package and distributed through the internal package management systems.

Potentially, there are infinite examples that ...