Cookiecutter template for creating high quality Python packages.
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]:
...
To start working on your project, here are some guidelines to set up your environment:
cd <YOUR_PROJECT_SLUG>
- Install poetry
- Activate virtualenv
poetry shell
- Install dependencies:
poetry install
- Init a git repository:
git init .
- 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.
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.
- 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.