Member-only story

How to make a Python package

Manpreet Singh
5 min readApr 29, 2021

--

Welcome back! Python is a very popular language, so maybe you want to develop a package for this language, so let’s talk about exactly how to create a package for Python!

Starting Off

First things first, you will have to have Python installed on your machine, you will also need a Python IDE of some sort, below is an article explaining exactly how to do both:

On top of this, the package we’re creating in this tutorial is a very basic, high level overview of this process, you can input your own code later in this tutorial. We will be using Pythons full documentation for packaging, here is the link for that:

Creating The Project

Let’s actually get started now, the layout of a standard package folder is essentially this: project_folder > src > example_pkg. We should now have 3 different folders with our package, we now want to fill these folders with the following documentation:

project_folder/
- LICENSE
- pyproject.toml
- README.md
- setup.cfg
- setup.py
- src/
- example_pkg/
- __init__.py
- tests/

Within the pyproject.toml file, you want to fill it with the following script:

[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"

This essentially tells the system what you are going to be using to build the tool.

Next up let’s create the metadata file, Python.org mentions that the static metadata is more important than the dynamic metadata, so let’s develop the setup.cfg and the setup.py files, use the following sample given by Python.org to develop your ssetup.cfg file:

[metadata]
# replace with your username:
name =…

--

--

Manpreet Singh
Manpreet Singh

No responses yet

Write a response