Python project development guide

After creating DAPT and some other Python packages, here are my steps to creating a Python package.

1. Create repository and project structure

The goal is to make a repository that has this structure:

├── [project-name]                  # A folder with the name of the Python package being created
├── docs                            # Folder that will hold the documentation
├── examples                        # Folder with the examples
├── tests                           # Unit test folder
├── .gitignore                      # Files and folders to ignore
├── LICENSE                         # Project license
├──                       # README for the project
└──                        # Setup file for PyPI
  1. Make a GitHub repository for the project.
  2. To make the folders run mkdir docs examples tests [project-name].
  3. The files can be created by running touch .gitignore LICENSE

2. Setup package


3. Setup documentation


4. Setup unit tests

It is a good idea to implement unit tests early into development. pytest is a great unit testing frame work to use. It can be installed by running pip install pytest. To use pytest, create a file that begins with “” or ends with “”. In your Python file, add import pytest to the top of the module. To create a simple test, you need to create a method with the name def test_*: or def *_test:. The last line of your function should have an assert with your expected result and actual result. For example, this is a basic test of some built in Python math function. This module would be placed in a file named “”.

import pytest

def test_min:
    assert min(1,3) == 1

def test_max:
    assert max(1,3) == 3

This test can then be ran by running pytest or pytest in the terminal. The former command will run python file matching the naming scheme above. The latter method will only run the specified module.

TODO: Config options

TODO: Classes

5. Setup .gitignore

For my .gitignore file I use this basic template:

# Python stuff

# pip stuff

# Dev env stuff

# Unwanted files

6. Pick a license

A great place to pick a license is For most projects I use the MIT license which allows people to do pretty much anything wth your code and they must give you credit. The BSD-3 licence is also good as it doesn’t allow your name to be used as an endorsement for derived projects.