Skip to content

Python-templates/template-python

 
 

Repository files navigation

Python template repository

ci Ruff

Brendon Smith (br3ndonland)

Description

Welcome! This is a template repository for Python projects, engineered for use as a GitHub template repository. To use the template, click on "Use this template" or browse to template-python/generate. GitHub will create a new repository without the commit history from this one.

The template-python repo name can be replaced with a one-line terminal command: git grep -l 'template-python' | xargs sed -i '' 's/template-python/repo-name/g' (replace repo-name with the name of the repository you generate). There may also be a few edits to the pyproject.toml needed. See the quickstart section for more.

Another common approach, especially for Python, is to use cookiecutter. In a cookiecutter repo, the developer adds template variables throughout, like {{cookiecutter.repo_name}}. When a user runs cookiecutter using the template repository, the template variables are replaced with the information the user provides. This repo is simple enough that I haven't needed to add cookiecutter yet.

Copier and PyScaffold are similar to cookiecutter, with some additional benefits. I may consider updating this repo for Copier or PyScaffold.

Quickstart

Install Hatch, rename the project, then install the project:

cd path/to/repo
# Replace instances of template-python with new repo name
# In the command below, use your repo name instead of 'repo-name'
❯ git grep -l 'template-python' | xargs sed -i '' 's|template-python|repo-name|g'
❯ git grep -l 'template_python' | xargs sed -i '' 's|template_python|repo-name|g'
# Try running the tests
❯ hatch run coverage run

Further information

See CONTRIBUTING.md.

About

Template repository for Python projects

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%