• Stars
    star
    257
  • Rank 157,829 (Top 4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated 25 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python project and library template for clean, reliable, open-source projects.

Python compat GHA Status

A template to quickly get you creating an open-source python library or project with linting, static analysis, CI, and CD to PyPI.

Usage

To use this template, click the green "Use this template" button in the github web interface. Then run:

git clone YOUR_REPO
# then cd into your local repo, and run:
./bootstrap

And follow the on-screen prompts. bootstrap uses some git data (like detecting your username and repository name), so cloning the repo generated from the template is necessary.

Compatibility

This template's bootstrap functionality only works on MacOS/Linux/WSL, it will not work natively on windows. The resulting project, however, may be windows-compatible.

Features

  • Features dependent if project is a library or a standalone project.
  • Poetry support.
    • If not installed, Poetry will automatically be installed when running bootstrap.
    • Poetry Dynamic Versioning - Dynamically handles your project version based on git tags.
  • Optional command line interface boilerplate using Typer.
  • Optional C binding support via Cython.
  • Sphinx + ReadTheDocs.
  • Pre-commit linting and static analysis. The following hooks are pre-configured:
    • Black - The uncompromising Python code formatter.
    • Ruff - An extremely fast Python linter.
    • Creosote - Identifies unused dependencies.
    • Codespell - Checks code and documentation for common misspellings.
    • Pyright - Static type checker.
  • Docker support for standalone projects.
  • GitHub Actions for:
    • Running pre-commit on pull requests and commits to main.
    • Running unit tests, coverage, and verify docs build on pull requests and commits to main.
    • Build and upload wheels to PyPI on semver tags vX.Y.Z.
      • Add your PyPI API token to your GitHub secrets for key PYPI_TOKEN.
      • If using Cython, pre-built binary packages will be created for all major operating systems, python versions, and computer architectures.
    • Build and upload docker images to Dockerhub.
      • Add your Dockerhub username and token to your GitHub secrets DOCKERHUB_USERNAME and DOCKERHUB_TOKEN.

Cython

This template has an option to add boilerplate for Cython. Cython is a programming language that simplifies the creation of C extensions for Python. The Cython documentation is quite good; the aim of this section is to explain what this template sets up, and what actions will still need to be performed by you. This explanation assumes you are familiar with C. Replace any reference here to pythontemplate with your project name.

  1. Place all C and header files in the pythontemplate/_c_src directory. If you don't plan on using any explicit C files, you may delete this directory.
  2. Update pythontemplate/cpythontemplate.pxd with header information from the files in (1). Example of common definitions (functions, structs, and enums) are provided. Think of *.pxd as a header file that allows Cython .pyx code to access pure C files. This file will be compiled into a package that can be imported in a .pyx file via cimport. If you don't plan on using any explicit C files, you may delete this file.
  3. Add Cython code to pythontemplate/_c_extension.pyx. Some class starter code is provided. This is where a good pythonic interface (functions and classes) should be written.
  4. Optionally tweak build.py (runs at setup/installation) with compiler options. The default build.py offers a good, working starting point for most projects and performs the following:
    1. Recursively searches for all C files in pythontemplate/_c_src/. To change this action, modify the variable c_files.
    2. Compiles the code defined in _c_extension.pyx into a shared object file.
    3. Adds pythontemplate and pythontemplate/_c_src to the Include Path (variable include_dirs).
    4. If your codebase contains a slower, python implementation of your Cython code, we can allow building to fail by uncommenting the allowed_to_fail logic at the top.
  5. The Github Action workflow defined in .github/workflows/build_wheels.yaml will create pre-built binaries for all major Python versions, operating systems, and computer architectures. It will also create a Source Distribution (sdist). Finally, on git semver tags (vX.X.X), it will upload all the resulting wheels to PyPI.

Reference

If you find this in the git history of a project and you like the structure, visit this template at https://github.com/BrianPugh/python-template .

More Repositories

1

cyclopts

Intuitive, easy CLIs based on python type hints.
Python
278
star
2

belay

Belay is a python library that enables the rapid development of projects that interact with hardware via a micropython-compatible board.
Python
236
star
3

game-and-watch-patch

CFW for the Nintendo Game and Watch
C
138
star
4

lox

Threading and Multiprocessing made easy.
Python
90
star
5

autoregistry

Automatic registry design-pattern library for mapping names to functionality.
Python
38
star
6

tamp

Tamp is a low-memory, DEFLATE-inspired lossless compression library.
Python
24
star
7

gnwmanager

C
15
star
8

cookiecutter-esp32-webserver

Cookiecutter template to get you quickly started with an ESP32-based webserver project.
C
13
star
9

cookiecutter-esp-idf-component

Cookiecutter template for an ESP-IDF component
C
5
star
10

pugh_torch

Functions, losses, and module blocks to share between experiments.
Python
4
star
11

micropython-libs

Python
4
star
12

install-micropython

Github Action to install micropython.
JavaScript
4
star
13

python-rai-rpc

Rai_node rpc commands wrapped for python
Python
3
star
14

RaiBlocks-Live-TPS

A simple python script that will display the transactions per second (TPS) of the incoming transactions on a rai_node/rai_wallet.
Python
3
star
15

magnetometer

CLI Magnetometer using a CircuitPython board + Belay
Python
3
star
16

micropython-fnv1a32

Micropython native module for the FNV1a hashing algorithm.
Python
3
star
17

raiblocks-docker

Docker for RaiBlocks
Dockerfile
2
star
18

esp-tamp-demo

C
2
star
19

makerdiary-m60-config

Lightweight repo to be directly used on the 8MB partition of the MakerDiary M60 keyboard
Python
2
star
20

micropython-native-module-template

Template for creating Micropython native module libraries with pre-built binaries
Python
2
star
21

dotfiles

Shell
1
star
22

pytorch-lightning-template

Python
1
star
23

monerod-docker

Dockerfile
1
star
24

esp32_unit_tester

ESP32 Unit Test App for ESP-IDF
C
1
star