Skip to content

anancarv/cookiecutter-pypackage

Repository files navigation

Cookiecutter PyPackage

Cookiecutter template for creating high quality Python packages.

Install

First, you need to Install cookiecutter

pip install cookiecutter

Generate a Python package project:

cookiecutter https://github.com/anancarv/cookiecutter-pypackage.git
full_name [Ananias CARVALHO]:
email [[email protected]]:
github_username [anancarv]:
...

Developing

To start working on your project, here are some guidelines to set up your environment:

  1. cd <YOUR_PROJECT_SLUG>
  2. Install poetry
  3. Activate virtualenvpoetry shell
  4. Install dependencies: poetry install
  5. Init a git repository: git init .
  6. Run pre-commit install --install-hooks to install precommit hooks

After having installed pre-commit, before each commit, hooks will perform static analysis, linting and code quality checks. As a result, you will be sure that each of your commit is clean.

All the code analysis features can be found in the Features section.

Create a GitHub Repo

Go to your GitHub account and create a new repo named mypackage, where mypackage matches the project_slug from your previous answers. Back to your CLI, you can do the following in the root of your generated project:

git add .
git commit -m "Initial skeleton."
git remote add origin [email protected]:<MY_USERNAME>/mypackage.git
git push -u origin master

Since your newly created project comes with github actions, every push will trigger the workflow .github/workflows/check_code.yml for analysing your code.

For publishing your package to pypi, you must create a release. Indeed, each release creation triggers the workflow .github/workflows/deploy.yml that builds and deploys your package. The only requirement is to set the PYPI_TOKEN variable within your github secrets with your token previously generated on pypi.

Features

  • poetry: Dependency management and packaging made easy.
  • github-actions: For Continuous Integration
  • black: Python code formatter
  • mypy: Static type checker for Python
  • bandit: Find common security issues in Python code.
  • flake8: Source code analyzer
  • pre-commit: A framework for managing and maintaining multi-language pre-commit hooks.

Similar Cookiecutter Templates

About

Cookiecutter template for building Python packages

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages