This is a opinionated template repository designed to bootstrap a modern Python development environment using:
- VS Code Dev Containers
- ASDF for tool version management
- Poetry for Python dependency and environment management
- Git bash prompt for visibality at cli
- Optional Pre-commit hooks for enforcing code quality
- Optional Git configuration via environment variables
| Feature | Description |
|---|---|
devcontainer.json |
Spins up a preconfigured Docker-based Python environment with VS Code |
.tool-versions |
Ensures consistent versions of tools across dev machines |
poetry |
Manages dependencies and virtualenvs in-project |
pre-commit-config.yaml |
an example pre-commit hooks with config and updates hooks |
| pre-commit helper | enable auto update of pre-commit hooks and installation ( if pre-commit is installed) |
| Git auto-configuration | Sets up Git identity inside container using env vars |
| Git bash prompt | Adds repo-aware prompt for easy context |
-
Use this repo as a template (click "Use this template" on GitHub)
-
Clone your new repository:
git clone https://github.com/dmascot/template-python-dev.git cd template-python-dev -
Open the repo in VS Code
-
VS Code will prompt: Reopen in Container → ✅ click it!
-
Automatically installs ASDF plugins and their versions defined in
.tool-versions
When the container is created, the .devcontainer/on-create.sh script automatically runs to prepare your development environment. It performs the following:
-
Copies .tool-versions to $HOME/.tool-versions
-
Installs any missing ASDF plugins (e.g. Python, Poetry)
-
Installs the exact tool versions defined in .tool-versions
-
Installs poetry and creates an in-project virtual environment (if applicable)
-
Installs and configures pre-commit hooks (if a .pre-commit-config.yaml is present)
-
Optionally sets up Git user info from environment variables
-
sources command from
.devcontainer/scripts/libsto be able to execute them at later stage. In particular, following commands can be usefulconfigure_gitto configuregithub user and emailafter setting variables ( if you did not set it before building container )update_and_install_packagesto update package versions and install themupdate_and_install_pre_commit_hooksto install and update pre-commit hooks aftercreating pre-commit-config.yaml
You can customize this behaviour in devcontainer/on-create.sh
Tools are installed using ASDF via .tool-versions:
python 3.12.8
poetry 2.1.2You can add more tools like nodejs with in .tool-versions:
nodejs 20.11.0Note that , you may need to required dependencies too if you choose this path
| Variable | Purpose | Where to set |
|---|---|---|
| GIT_USER_NAME | Git user name | .bashrc, .devcontainer/.env, etc |
| GIT_EMAIL | Git email | .bashrc, .devcontainer/.env, etc |
e.g.
export GIT_USER_NAME="Kewl Developer"
export GIT_EMAIL="kewl@devmail.com"🏷 Change the Dev Container Name
You can change the container name in .devcontainer/devcontainer.json:
{
"name": "python"
}change python to anything
{
"name": "kewl-python-project"
}This repo is designed to be forked and adapted. Feel free to tweak the setup for your use case!
MIT