Minimum Structure of a Python Project

Here is the structure of a project named tasks_proj



In this project, the setup.py is defined as followed:

"""Minimal setup file for tasks project."""

from setuptools import setup, find_packages

setup(
    name='tasks',
    version='0.1.0',
    license='proprietary',
    description='Minimal Project Task Management',

    author='Brian Okken',
    author_email='Please use pythontesting.net contact form.',
    url='https://pragprog.com/book/bopytest',

    packages=find_packages(where='src'),
    package_dir={'': 'src'},

    install_requires=['click', 'tinydb', 'six'],
    extras_require={'mongo': 'pymongo'},

    entry_points={
        'console_scripts': [
            'tasks = tasks.cli:tasks_cli',
        ]
    },
)

Using such as structure of setup.py, the project can be installed locally using pip

$ cd tasks_proj
$ pip install .         # pip install -e .  (see below for comments on this)
Processing /Users/j35/git/python_testing_with_pytest/tasks_proj
Collecting click
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 2.1 MB/s
Collecting tinydb
  Downloading tinydb-3.15.2-py2.py3-none-any.whl (17 kB)
Requirement already satisfied: six in /miniconda3/envs/py38/lib/python3.8/site-packages (from tasks==0.1.0) (1.14.0)
Building wheels for collected packages: tasks
  Building wheel for tasks (setup.py) ... done
  Created wheel for tasks: filename=tasks-0.1.0-py3-none-any.whl size=6914 sha256=4b3a0bd23d0176eafeb65768ba8e453061309819143dc57109d73c4cc9a0b827
  Stored in directory: /private/var/folders/t8/307ghqxx5djb28nl56mkmx7j90c0xy/T/pip-ephem-wheel-cache-0t77c52a/wheels/a0/2a/3a/dcdfde2fc10624b7fc1548b9433a29bea956ee3d46d36263c9
Successfully built tasks
Installing collected packages: click, tinydb, tasks
Successfully installed click-7.1.2 tasks-0.1.0 tinydb-3.15.2

or

$ cd ..
$ pip install --no-chache-dir -e tasks_proj

the -e commands allows you to modify the source code while tasks is installed. Otherwise you will only be able to run the tests against tasks but won’t be able to modify the code.