This is a minimal template for a typical Python application developed in Visual Studio Code. It includes a folder structure and boilerplate for:
- A CLI app
- Python module code
- Tests (using the pytest framework)
- Makefile
As well as a VS Code settings file to integrate a virtual environment and testing framework.
- Create a new environment by running
python3 -m venv .venv
- Activate the virtual environment (Command Pallete > Python: Create Terminal in VS Code)
- Execute
pip3 install -r requirements.txt
├── .vscode
│ └── settings.json
├── app
│ └── main.py
├── .env
├── .git
├── .gitignore
├── Makefile
├── Readme.md
├── python_project
│ └── functions.py
├── requirements.txt
└── tests
└── test_it.py
VS Code settings that:
- Specifies .venv/bin/python as the
pythonPath
- Specifies pytest as the testing framework
- Launches pytest with verbose output and ignores the .venv folder
- Enables linting
A dedicated folder for a CLI app.
A boilerplate Click program.
Python module code.
Initial module code.
Unit tests.
Initial test code.
VS Code environment variables. Sets the PYTHONPATH
to the root folder.
Includes a PHONY rule for cleaning up Python artifacts.
This document.
Python package requirerments. Includes:
- pytest
- pylint
- click
The MIT License (MIT)
Copyright (c) 2019 Calvin De Lima
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.