https://github.com/febus982/bootstrap-python-package
A template repository to create a python package, automatically published on pypi
https://github.com/febus982/bootstrap-python-package
pypi pypi-package pypi-packages python python-lib python-library python3 template template-project template-repository
Last synced: 7 months ago
JSON representation
A template repository to create a python package, automatically published on pypi
- Host: GitHub
- URL: https://github.com/febus982/bootstrap-python-package
- Owner: febus982
- License: mit
- Created: 2024-01-06T19:01:11.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-21T13:15:43.000Z (8 months ago)
- Last Synced: 2025-06-21T14:25:57.119Z (8 months ago)
- Topics: pypi, pypi-package, pypi-packages, python, python-lib, python-library, python3, template, template-project, template-repository
- Language: Python
- Homepage: https://febus982.github.io/bootstrap-python-package/
- Size: 1.97 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# bootstrap-python-package

[](https://pypi.org/project/bootstrap-python-package/)
[](https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#beta)
[](https://github.com/febus982/bootstrap-python-package/actions/workflows/python-tests.yml)
[](https://qlty.sh/gh/febus982/projects/bootstrap-python-package)
[](https://qlty.sh/gh/febus982/projects/bootstrap-python-package)
[](https://mypy-lang.org/)
[](https://github.com/charliermarsh/ruff)
[](https://github.com/psf/black)
[](https://github.com/PyCQA/bandit)
This template repository provides the boilerplate to create a python package.
It is configured with all the following features:
* Test suite using [tox](https://tox.wiki/en/latest/index.html) and [pytest](https://docs.pytest.org/en/7.4.x/)
* Typing using [mypy](https://mypy.readthedocs.io/en/stable/)
* Linting, security and code format using [ruff](https://github.com/astral-sh/ruff) (using [black](https://pypi.org/project/black/)
code style and [bandit](https://github.com/PyCQA/bandit) security rules)
* Integration with CodeClimate for code quality and coverage checks
* CI pipeline supporting:
* testing against multiple python versions
* releases on [PyPI](https://pypi.org)
* GitHub pages documentation using [mkdocs](https://www.mkdocs.org)
* PyCharm profile basic configuration
## How to use this repository template to create a new package
* Create your github repository using this template. (The big green `Use this template` button)
* Rename the `bootstrap_python_package` directory
* Search and replace all the occurrences of `bootstrap-python-package` and `bootstrap_python_package`
* Configure a pending trusted publisher on [pypi](https://pypi.org/manage/account/publishing) using the following values:
* PyPI Project Name: The github repository name (in this case `bootstrap-python-package`)
* Owner: The github repository owner (in this case `febus982`)
* Repository name: The github repository name (in this case `bootstrap-python-package`)
* Workflow name: `release.yml`
* Create a GitHub Actions secret named `CODECLIMATE_REPORTER_ID` (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/secrets/actions`)
containing the codeclimate reporter id (you can find it at `https://codeclimate.com/repos/YOUR_REPO_ID/settings/test_reporter`).
If you don't want to use CodeClimate just delete `workflows/python-quality.yml`.
* Update the badges in `README.md`! (check [shields.io](https://shields.io/) for extra badges)
* Update the PyCharm Copyright profile in the IDE settings: Editor | Copyright | Copyright Profiles (if you want to use it)
* Setup local development:
* Clone the repository
* [Install uv](https://docs.astral.sh/uv/getting-started/installation/)
* Install dev dependencies with `make dev-dependencies`
* (optional) It is strongly recommended to install [pre-commit](https://pre-commit.com/#installation)
and run `pre-commit install` so that formatting and linting are automatically executed during `git commit`.
* Setup GitHub pages (this need local development setup):
* Initialise documentation branch `uv run mike deploy dev latest --update-aliases --push`
* Configure GitHub Pages to deploy from the `gh-pages` branch (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/pages`)
* Add the `main` branch and the `v*.*.*` tag rules to the "deployment branches and tags" list in the `gh-pages` environment (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/environments`)
**IMPORTANT:** The repository is configured to deploy on the [test PyPI repository](https://test.pypi.org/).
It's strongly recommended to create the project in the [test PyPI repository](https://test.pypi.org/) and test
the deployment pipeline. When you're happy with the result, create the project on the official [PyPI repository](https://pypi.org/)
and remove the marked lines in `workflows/release.yml`.
## Package release
This setup uses [uv-dynamic-versioning](https://github.com/ninoseki/uv-dynamic-versioning/tree/main).
This means it's not necessary to commit the version in the code but the CI pipeline
will infer it from the git tag.
To release a new version, just create a new release and tag in the GitHub repository, to:
* Build and deploy the python package to PyPI
* Build and deploy a new version of the documentation to GitHub pages
**IMPORTANT:** The default configuration requires the release name and the tag to follow
the convention `vX.X.X` (semantic versioning preceded by lowercase `v`). It will publish
the correct version on Pypi, omitting the `v` (ie. `v1.0.0` will publish `1.0.0`).
This format can be customized, refer to [uv-dynamic-versioning docs](https://github.com/ninoseki/uv-dynamic-versioning/tree/main).
## Commands for development
All the common commands used during development can be run using make targets:
* `make dev-dependencies`: Install dev requirements
* `make fix`: Run code style and lint automatic fixes (where possible)
* `make test`: Run test suite against system python version
* `make check`: Run tests against all available python versions, code style and lint checks
* `make type`, `make format`, `make lint`, `make bandit`: Run the relevant check
* `make docs`: Render the mkdocs website locally