Each time I start new pyton project my first step is to create a git repository, virtual environment and requirements.txt file. All project dependencies listed in the requirements.txt file are installed in the local venv. As I am a big fan of make utility, I usually create a Makefile with few targets that help to manage the project.
I need to be able to:
- activate virtualenv
- install requirements listed in the requirments.txt file
- install the project
- run tests
- clean files and directories
- build the wheel and tar distributions
- python virtualenv is installed
Below is the small code snippet that ilustrates how to combine virtualenv and make.
How does it work? The venv target builds virtualenvironment and installs Python packages listed in the requirements.txt file. If all packages are installed and up to date nothing happens. The venv make target can be used as a dependency for other targets or called directly to build venv from scratch: