Skip to content

Opinionated set of tools for developing in Python and best practices around building python applications.

License

Notifications You must be signed in to change notification settings

solita/production-ready-python-template

Repository files navigation

Python project-template with VSCode Devcontainer

Opinionated set of tools for developing in Python Reproducible, robust and yet simple development setup for python. By a data person that loves developing using VSCode devcontainer.

Prerequisites

Getting started

# Clone the repository
git clone <this-repo>
cd <this-repo>

# create .env for configs and secrets, see .env.sample
cp .env.sample .env
# Update .env with your settings as needed
# DEVELOPMENT=True enables debug logging

# Open the project in VSCode
code .

# Use the VSCode command palette (Ctrl+Shift+P) and select:
# > Dev Containers: Reopen in Container
# This will build and open the development container

# --- Inside the container ---

# Dependencies are managed with uv (part of the `builder` stage)
# To add new dependencies
uv add <package-name>

# Pre-commit hooks are installed with postCreateCommand in .devcontainer/devcontainer.json
pre-commit

# You're ready to develop!

Background

This template uses VSCode's Development Containers (devcontainers) to provide a consistent, isolated development environment. The setup leverages Docker Compose with an extension pattern:

  • docker-compose.yml defines the base service configuration
  • .devcontainer/docker-compose.extend.yml extends the base configuration specifically for development
  • The extension mounts your local project directory to /app in the container, enabling real-time file synchronization
  • This allows you to work on code locally in VSCode while running it in a container environment

This approach ensures that all developers work with identical dependencies and configurations, regardless of their local setup, while maintaining the ability to edit files directly on the host system.

Tooling

  • uv for dependency management
  • VS Code devcontainers with docker compose-file
  • Multi-stage build with builder, also used for development, and production
  • debugging: debugpy
  • testing: pytest
    • (optional) pytest-cov, pytest-mock, hypothesis, nox
  • linting & formatting: ruff
  • type-checking: mypy
  • environment variables: python-dotenv
  • pre-commit hooks

Development practices & style

About

Opinionated set of tools for developing in Python and best practices around building python applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published