Skip to content

Python cookiecutter template with CI/CD, flake8 Linter, Black style formatting, Dockerfile, semantic version control etc.

License

Notifications You must be signed in to change notification settings

LeisureTech/cookiecutter-python

Repository files navigation

Cookiecutter Python

LeisureTech

A cookiecutter template that is aimed for all kinds of python project. It's straight-forward and easy to use. You can create a brand new python project by executing one command.

Features

  • Black Code style formatting
  • flake8 Linter.
  • Docker-compose & Dockerfile.
  • PyPackage release (Semantic version release)
  • CircleCi CI/CD.
  • Extra support for Cookiecutter replay

Python Project Structure 🐍

It does not necessairly to follow this structure. Feel free to fork this project and create a project of your own accord 💖

{{ cookiecutter.project_slug }}
├── src  # source folder
    ├── main.py  # python script
    ├── Dockerfile
    ├── pytest.ini
    └── requirements.txt
├── .template  # cookiecutter replay dir
    ├── cookiecutter-python.json # cookiecutter-replay
    └── cookiecutter-config.yml  # user config
├── .circleci
    ├── config.yml
├── docs
    ├── AUTHORS.md  
├── .gitignore
├── .pre-commit-config.yaml
├── CHANGELOG.md
├── docker-compose.yml
├── LICENSE
├── pyproject.toml
├── README.md
├── setup.cfg
└── setup.py

Get Started 🚀

Step 1: Install cookiecutter

Please follow the documentation to install the package.

Step 2: Create your new project

$cookiecutter https://github.com/LeisureTech/cookiecutter-python

Follow the terminal and set up parameters accordingly.

You're all set!

Step 3: Run your project

cd {{cookiecutter.project_slug}}/src
docker build --tag python-project .
docker run python-project

Project Replay 💫

Cookiecutter replay is tricky. To make it easier, we keep the replay file in the template so we don't need to worry about the default replay parameters have been overwritten. It comes in handy for the situation where multiple projects were generated from the same template.

To perform a replay, the first thing you need to do is to edit the cookiecutter-config.yml file from the /.template folder according to your situation:

default_context:
    full_name: "Leisure Mojo"
    email: "leisuremojotech@gmail.com"
    github_username: "leisuremojo"
cookiecutters_dir: "~/.cookiecutters/"
replay_dir: "~/cookiecutter_python_example/.template" # set a relative/absolute path

Next, run the following command:

cookiecutter --replay --config-file {{cookiecutter.project_slug}}/.template/cookiecutter-config.yml -f gh:LeisureTech/cookiecutter-python

Caveats

Before replaying, you better backup CHANGELOG.md and update the {{cookiecutter.version}} from .template/cookiecutter-python.json to the current version of your project. This is due to the fact that replaying overwirtes those files, so by this way your git logs will not be contaminated.

About

Python cookiecutter template with CI/CD, flake8 Linter, Black style formatting, Dockerfile, semantic version control etc.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published