

While a variety of ways to structure your distribution package exist, I like the approach of placing Python code in a src directory.

Now cd into that directory in your favorite terminal so that it is your current working directory. In this first article, we will set up a simple directory structure, write a Python module, configure the distribution package using setup.py, and install our new package in a virtual environment.Ĭreate a new directory for the project. Add a robust and well-documented Python test framework like pytest, as introduced in Part 2, and you are golden.

The tools venv and pip, and pip's cousin dependency setuptools, are usually included in your Python distribution. python setup.py sdist For Windows, open a command prompt window ( Start Accessories) and change the command to: setup.py sdist sdist will create an archive file (e.g., tarball on Unix, ZIP file on Windows) containing your setup script setup. While Poetry and similar tools are being utilized more and more, I sometimes find that my Python development needs are satisfied by built-in Python features.
