/template-python

Template repository for Python projects.

Primary LanguagePythonMIT LicenseMIT

This is a template Python repository to start a fresh project with a default setup.

Tests Quality Checked with mypy Code style: black pdm-managed pre-commit License: MIT

The project setup includes:

  • Python >= 3.10
  • Ubuntu, MacOS, Windows latest OS versions
  • PDM for dependency management
  • GitHub Actions and pre-commit for linting, formatting, CI/CD
    • Black for code formatting
    • Mypy for static type checking
    • Pytest for testing
  • MIT license
  • The above badges of this README.md

Getting Started

  1. Install Python 3.10 in your local machine. For MacOS use
brew install python@3.10
  1. Click on the Use this template button at this page to create a new repository from this template (you must be logged in to GitHub to see the button).
  2. Name your repository and click Create repository from template. If the repository name is more than one word, make sure to use -hyphens- instead of spaces or underscores.
  3. Git clone the repository to your local machine.
  4. Cd into the repository directory.
  5. Run template_setup.py with
python3 template_setup.py [--user-name YOUR_GIT_USER_NAME] [--user-email YOUR_GIT_USER_EMAIL]
  1. Follow the instructions in the terminal.
    • Select y to make project installable when prompted by PDM

Running the setup script will:

  • Rename file contents, names, and directories that contains template repository name with the new repository name
  • Rename user name and user email in and README_main.md
  • Configure GitHub user name and user email locally
  • Remove pdm.lock, pyproject.toml, and requirements.txt
  • Remove README.md and rename README_main.md to README.md
  • If not installed pip install PDM in your local machine
  • Update PDM to the latest version
  • PDM init with Python 3.10
  • Install dependencies with PDM
  • Install pre-commit hooks to local .git folder
  • Remove template_setup.py
  • Prompt user an option to git add commit and push
  • Remove .mypy_cache and .pytest_cache folders