https://github.com/habedi/template-python-library
A template for Python libraries
https://github.com/habedi/template-python-library
project-template python python-library python-package quality-of-life template
Last synced: 7 months ago
JSON representation
A template for Python libraries
- Host: GitHub
- URL: https://github.com/habedi/template-python-library
- Owner: habedi
- License: mit
- Created: 2024-10-04T11:06:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-18T16:30:45.000Z (8 months ago)
- Last Synced: 2025-02-18T17:28:27.918Z (8 months ago)
- Topics: project-template, python, python-library, python-package, quality-of-life, template
- Language: Makefile
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Template for a Python Library
[](https://github.com/habedi/template-python-library/actions/workflows/tests.yml)
[](https://badge.fury.io/py/template-python-library-placeholder)
[](https://github.com/habedi/template-python-library/blob/main/LICENSE)
[](https://github.com/habedi/template-python-library)
[](https://pypi.org/project/template-python-library-placeholder)
[](https://www.codefactor.io/repository/github/habedi/template-python-library)
[](https://codecov.io/gh/habedi/template-python-library)This repository is a template to make the development of Python libraries easier.
It includes a basic structure, dummy package, unit tests, and GitHub Actions workflows for testing and deployment.
I'm sharing this template in case others find it useful.## Features
- **Poetry**: for dependency and virtual environment management.
- **Makefile**: for managing common tasks like testing, linting, and formatting.
- **GitHub Actions**: for running tests, linting, and deploying to PyPI.
- **Badges**: for showing the status of tests, code quality, version, etc.## Structure
- `.github`: GitHub Actions workflows.
- `assets`: Asset files (e.g., images, logos, etc.).
- `docs`: Documentation for the library.
- `src`: Library's source code.
- `tests`: Unit tests.
- `.editorconfig`: Editor settings for consistent coding style.
- `.gitignore`: Excludes files generated by Python and Poetry.
- `.gitattributes`: Git LFS configuration.
- `LICENSE`: License file.
- `Makefile`: Manage tasks like testing, linting, and formatting.
- `pyproject.toml`: Poetry's configuration file.## Getting Started
### Prerequisites
- `Python` >= 3.10
- `Poetry` (should work with `uv` as well)
- `GNU Make`Tested on `Ubuntu 24.04 LTS` and `Debian 12`. But the template should work on other operating systems as well.
### Setting Things Up
1. **Clone the repository**:
```sh
git clone https://github.com/habedi/template-python-library.git
cd template-python-library
```2. **Install dependencies**:
```sh
make setup
make install
```### Development Workflow Management
```sh
# See the help for available commands
make help
``````sh
# Run the unit tests
make test
``````sh
# Lint the code
make lint
``````sh
# Format the code
make format
``````sh
# Perform type checking
make typecheck
``````sh
# Build the library
make build
``````sh
# Publish the library to PyPI
make publish
```> [!NOTE]
> To publish the library to PyPI, make sure you have a PyPI account and a valid API token.
> Set the `PYPI_API_TOKEN` secret in your GitHub repository settings, and `PYPI_TOKEN` environment variable in your
> local environment.
> For more information, refer to the [Poetry documentation](https://python-poetry.org/docs/repositories/)
> and [GitHub documentation](https://docs.github.com/en/actions/reference/encrypted-secrets).