Creating an Installable Module

We’ll start by learning how to make a small project installable with pip. For a simple one-module project, the minimal configuration is small. I don’t recommend you make it quite this small, but I want to show a minimal structure in order to build up to something more maintainable, and also to show how simple setup.py can be. Here’s a simple directory structure:

 some_module_proj/
 ├── setup.py
 └── some_module.py

The code we want to share is in some_module.py:

 def​ some_func():
 return​ 42

To make it installable with pip, we need a setup.py file. This is about as bare bones as you can get:

 from​ setuptools ...

Get Python Testing with pytest now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.