Skip to content

A git repo template project for Python open source project

License

Notifications You must be signed in to change notification settings

MacHu-GWU/cookiecutter-pyproject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Dec 25, 2024
f7b08b8 · Dec 25, 2024

History

30 Commits
Sep 25, 2023
Jun 14, 2023
Jul 28, 2024
Dec 25, 2024
Jun 14, 2023
Sep 25, 2023
Jun 15, 2023
Jun 15, 2023
Dec 25, 2024
Jul 28, 2024
Jun 14, 2023
Jul 28, 2024
Jul 28, 2024
Dec 25, 2024
Sep 25, 2023
Jun 14, 2023
Jul 28, 2024

Repository files navigation

Documentation Status https://img.shields.io/badge/Release_History!--None.svg?style=social https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social

cookiecutter-pyproject

FULL DOCUMENT IS HERE

Summary

This is an Python open source library project template I used for years. You can easily generate a folder structure with everything you need and start development, then publish to PyPI.

Best practices and automation features included in this template:

  • Virtualenv management
  • Dependencies management
  • Local unit test and code coverage test
  • Build and preview documentation site locally
  • Use GitHub Action for CI
  • Use Codecov for code coverage report
  • Use Read the Docs for documentation site hosting

Disclaimer

All the best practice used in this repo is based on my career experience, and my personal opinion. I have done over 90+ open source Python library projects and 50+ internal Python libraries for Enterprise. It is the best practice I am using for years. It allow me to publish a new Python library to PyPI in one hour when I got an idea. Again, it is my personal best practice, please use it at your own risk.

Usage

Enter the following command, it will use the latest template.

pip install cookiecutter && cookiecutter https://github.com/MacHu-GWU/cookiecutter-pyproject

Or, you can use a specific released version, you can find full list of release at here.

Use specific version:

cookiecutter https://github.com/MacHu-GWU/cookiecutter-pyproject --checkout tags/${version}

For example (v6 is the latest as of 2024-12-25)

cookiecutter https://github.com/MacHu-GWU/cookiecutter-pyproject --checkout tags/v6

Then fill in some information:

package_name [your_package_name_with_underscore]: ...
package_name_slug [your-package-name-with-hyphen]: ...
github_username [your-github-username]: ...
author_name [Firstname Lastname]: ...
author_email [firstname.lastname@email.com]: ...
...

Then it will generate a Git repo folder structures like this:

  • /.github/: GitHub action configuration
  • /${package_name}/... your python project source code
  • /tests/...: unit test
  • /.coveragerc: code coverage test config
  • /pyproject_ops.json: the pyproject_ops CLI automation tool config file

We have an example project generated from this template my_package-project. Please take a look at it.

I personally use a branch to generate code skeleton for my open source projects.

cookiecutter https://github.com/MacHu-GWU/cookiecutter-pyproject --checkout sanhe