Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.14'

- name: Install Dependencies
- name: Install dependencies
run: |
make setup
make install

- name: Build Documentation
- name: Build documentation
run: make docs

- name: Setup Pages
- name: Setup pages
uses: actions/configure-pages@v5

- name: Upload Documentation as Artifact
- name: Upload documentation as artifact
uses: actions/upload-pages-artifact@v3
with:
path: './site'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ jobs:
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]

steps:
- name: Checkout Repository
- name: Checkout repository
uses: actions/checkout@v4

- name: Set Up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
- name: Install dependencies
run: |
make setup
make install

- name: Run Tests with Coverage
- name: Run linter checks
run: |
make lint
continue-on-error: false
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ jobs:
needs: call_tests

steps:
- name: Checkout Repository
- name: Checkout repository
uses: actions/checkout@v4

- name: Set Up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.14"

- name: Install Dependencies
- name: Install dependencies
run: |
make setup
make install

- name: Build and Publish Package
- name: Build and publish package
run: |
PYPI_TOKEN=${{ secrets.PYPI_API_TOKEN }} make publish # Need `PYPI_API_TOKEN` secret
12 changes: 8 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
permissions:
contents: read

#concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -29,20 +33,20 @@ jobs:
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]

steps:
- name: Checkout Repository
- name: Checkout repository
uses: actions/checkout@v4

- name: Set Up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
- name: Install dependencies
run: |
make setup
make install

- name: Run Tests with Coverage
- name: Run tests with coverage
run: |
make test

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ site/
# Miscellaneous files and directories to ignore
# Add any additional file patterns a directory names that should be ignored down here
.env
.agents/
.claude/
.codex
.antigravitycli/
22 changes: 5 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
# Generic Makefile for Python projects

# Load environment variables from .env file
ifneq (,$(wildcard ./.env))
include .env
export $(shell sed 's/=.*//' .env)
else
$(warning .env file not found. Environment variables not loaded.)
endif

# Variables
PYTHON ?= python3
PIP ?= pip3
DEP_MNGR ?= poetry
DEP_MNGR ?= uv
DOCS_DIR ?= docs

# Directories and files to clean
Expand All @@ -29,16 +19,15 @@ help: ## Show help messages for all available targets

# Setup and Installation
.PHONY: setup
setup: ## Install system dependencies and dependency manager (default: Poetry)
setup: ## Install system dependencies and dependency manager
sudo apt-get update
sudo apt-get install -y python3-pip
$(PIP) install --upgrade pip
$(PIP) install $(DEP_MNGR)

.PHONY: install
install: ## Install Python dependencies
$(DEP_MNGR) install --all-extras --no-interaction # For Poetry
#(DEP_MNGR) sync --all-extras # For uv
$(DEP_MNGR) sync --all-extras

# Quality and Testing
.PHONY: test
Expand Down Expand Up @@ -78,9 +67,8 @@ build: ## Build distributions
$(DEP_MNGR) build

.PHONY: publish
publish: ## Publish to PyPI (requires PYPI_TOKEN)
$(DEP_MNGR) config pypi-token.pypi $(PYPI_TOKEN)
$(DEP_MNGR) publish --build
publish: build ## Publish to PyPI (requires PYPI_TOKEN)
$(DEP_MNGR) publish $(if $(PYPI_TOKEN),--token $(PYPI_TOKEN),)

# Maintenance
.PHONY: clean
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

[![Tests](https://img.shields.io/github/actions/workflow/status/habedi/template-python-library/tests.yml?label=tests&style=flat&labelColor=333333&logo=github&logoColor=white)](https://github.com/habedi/template-python-library/actions/workflows/tests.yml)
[![Code Coverage](https://img.shields.io/codecov/c/github/habedi/template-python-library?style=flat&label=coverage&labelColor=333333&logo=codecov&logoColor=white)](https://codecov.io/gh/habedi/template-python-library)
[![Code Quality](https://img.shields.io/codefactor/grade/github/habedi/template-python-library?style=flat&label=code%20quality&labelColor=333333&logo=codefactor&logoColor=white)](https://www.codefactor.io/repository/github/habedi/template-python-library)
[![PyPI Version](https://img.shields.io/pypi/v/template-python-library-placeholder.svg?style=flat&label=pypi&labelColor=333333&logo=pypi&logoColor=white&color=3775a9)](https://pypi.org/project/template-python-library-placeholder/)
[![Python Version](https://img.shields.io/badge/python-%3E=3.10-3776ab?style=flat&labelColor=333333&logo=python&logoColor=white)](https://github.com/habedi/template-python-library)
[![Documentation](https://img.shields.io/badge/docs-latest-8ca0d7?style=flat&labelColor=333333&logo=read-the-docs&logoColor=white)](https://github.com/habedi/template-python-library/blob/main/docs)
[![License](https://img.shields.io/badge/license-MIT-00acc1?style=flat&labelColor=333333&logo=open-source-initiative&logoColor=white)](https://github.com/habedi/template-python-library/blob/main/LICENSE)
[![Documentation](https://img.shields.io/badge/docs-latest-3776ab?style=flat&labelColor=333333&logo=read-the-docs&logoColor=white)](https://github.com/habedi/template-python-library/blob/main/docs)
[![License](https://img.shields.io/badge/license-MIT-3776ab?style=flat&labelColor=333333&logo=open-source-initiative&logoColor=white)](https://github.com/habedi/template-python-library/blob/main/LICENSE)
[![PyPI Version](https://img.shields.io/pypi/v/template-python-library-placeholder.svg?style=flat&label=pypi&labelColor=333333&logo=pypi&logoColor=white&color=3775a9)](https://pypi.org/project/template-python-library-placeholder/)

---

Expand All @@ -23,7 +22,7 @@ I am sharing this template in case others find it useful.

### Features

- **Poetry (or uv)**: for dependency management, packaging, publishing, etc.
- **Uv**: for dependency management, packaging, publishing, etc.
- **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.
Expand All @@ -32,7 +31,7 @@ I am sharing this template in case others find it useful.
### Prerequisites

- `Python` >= 3.10
- `Poetry 2.0+` (or any other modern Python dependency manager like `uv`)
- `Uv` (or any other modern Python dependency manager like `uv`)
- `GNU Make`

### Usage
Expand Down
4 changes: 2 additions & 2 deletions library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from importlib.metadata import PackageNotFoundError, version

from package import DummyClass
from .package import DummyClass

_logger = logging.getLogger(__name__)

Expand All @@ -14,4 +14,4 @@
"Is the library installed correctly?"
)

__all__ = ["DummyClass"]
__all__ = ["DummyClass", "__version__"]
2 changes: 0 additions & 2 deletions poetry.toml

This file was deleted.

47 changes: 23 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,41 @@ classifiers = [

requires-python = ">=3.10,<4.0"
dependencies = [
"python-dotenv (>=1.1.0,<2.0.0)"
"python-dotenv>=1.1.0"
]

[project.optional-dependencies]
dev = [
"pytest (>=8.0.1,<10.0.0)",
"pytest-cov (>=6.0.0,<8.0.0)",
"pytest-mock (>=3.14.0,<4.0.0)",
"pytest-asyncio (>=1.1.0,<2.0.0)",
"mypy (>=1.11.1,<2.0.0)",
"ruff (>=0.9.3,<1.0.0)",
"pre-commit (>=4.2.0,<5.0.0)",
"icecream (>=2.1.4,<3.0.0)",
"mkdocs (>=1.6.1,<2.0.0)",
"mkdocs-material (>=9.6.12,<10.0.0)",
"mkdocstrings-python (>=1.16.10,<2.0.0)",
"pyyaml (>=6.0.1,<7.0.0)",
"rundoc (>=0.2.3,<0.3.0)",
"hypothesis (>=6.150.2,<7.0.0)",
"griffe (>=1.7.3,<2.0.0)",
"pytest>=8.0.1",
"pytest-cov>=6.0.0",
"pytest-mock>=3.14.0,<4.0.0",
"pytest-asyncio>=1.1.0,<2.0.0",
"mypy>=1.11.1,<2.0.0",
"ruff>=0.9.3,<1.0.0",
"pre-commit>=4.2.0,<5.0.0",
"icecream>=2.1.4",
"mkdocs>=1.6.1,<2.0.0",
"mkdocs-material>=9.6.12,<10.0.0",
"mkdocstrings-python>=1.16.10,<2.0.0",
"pyyaml>=6.0.1,<7.0.0",
"rundoc>=0.2.3,<0.3.0",
"hypothesis>=6.150.2,<7.0.0",
"griffe>=1.7.3,<2.0.0",
]

[project.urls]
Repository = "https://github.com/habedi/template-python-library"
Documentation = "https://github.com/habedi/template-python-library/blob/main/docs/index.md"

[tool.poetry]
include = ["README.md"]
packages = [{ include = "library" }]
[tool.hatch.build.targets.wheel]
packages = ["library"]

[build-system]
requires = ["hatchling>=1.20", "build>=1.0"]
requires = ["hatchling>=1.20"]
build-backend = "hatchling.build"

[tool.pytest.ini_options]
pythonpath = ["library"]
pythonpath = ["."]
testpaths = ["tests"]
addopts = [
"--tb=short",
Expand Down Expand Up @@ -101,14 +100,14 @@ check_untyped_defs = true
warn_return_any = true
strict_optional = true
warn_redundant_casts = true
exclude = "^(benches/|examples/|tests/)"
exclude = "^(benches/|examples/)"

[tool.ruff]
exclude = [
".bzr", ".direnv", ".eggs", ".git", ".git-rewrite", ".hg", ".mypy_cache",
".nox", ".pants.d", ".pytype", ".ruff_cache", ".svn", ".tox", ".venv",
"__pypackages__", "_build", "buck-out", "build", "dist", "node_modules",
"venv", "tests"
"venv"
]
line-length = 100
indent-width = 4
Expand All @@ -133,4 +132,4 @@ line-ending = "auto"
convention = "google"

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = []
"tests/**/*.py" = ["ANN"]
21 changes: 13 additions & 8 deletions tests/test_module.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
"""Tests for the library.package"""
"""Tests for the library package."""

from library.package import DummyClass
from library import DummyClass, __version__
from library.package.module import DummyClass as ModuleDummyClass


# Let us write some unit tests using pytest and arrange-act-assert pattern
# We will follow the Arrange-Act-Assert pattern for our tests


def test_dummy_class():
def test_dummy_class() -> None:
# Arrange
dummy = DummyClass()

# Act
dummy.dummy_method()
dummy.static_method()
dummy.class_method()

# Assert
assert isinstance(dummy, ModuleDummyClass)


def test_version() -> None:
# Assert
assert True
assert isinstance(__version__, str)
assert len(__version__) > 0
Loading
Loading