Add Makefile for Python bindings

This commit is contained in:
Lauri Virtanen
2024-09-01 15:48:42 +03:00
parent 9cb2164bfa
commit a09c6ef493
2 changed files with 40 additions and 12 deletions

View File

@@ -72,11 +72,8 @@ jobs:
- name: Install dev dependencies
run: pip install -r requirements-dev.txt
- name: Run Ruff check
run: ruff check
- name: Run Ruff format check
run: ruff format --diff
- name: Run lint
run: make lint
check-requirements:
runs-on: ubuntu-latest
@@ -98,10 +95,4 @@ jobs:
run: pip install pip-tools
- name: Check requirements files
run: |
mkdir .tmp
pip-compile --quiet --output-file .tmp/requirements.txt
pip-compile --quiet --extra=dev --output-file .tmp/requirements-dev.txt
diff -u requirements.txt .tmp/requirements.txt || (echo "requirements.txt doesn't match pyproject.toml" && exit 1)
diff -u requirements-dev.txt .tmp/requirements-dev.txt || (echo "requirements-dev.txt doesn't match pyproject.toml" && exit 1)
echo "Requirements files match pyproject.toml"
run: make check-requirements

37
bindings/python/Makefile Normal file
View File

@@ -0,0 +1,37 @@
REQUIREMENTS := requirements.txt
REQUIREMENTS_DEV := requirements-dev.txt
all: check-requirements install lint test
.PHONY: all
install:
@echo "Installing requirements..."
pip install -r requirements.txt -r requirements-dev.txt
.PHONY: install
test:
@echo "Running tests..."
pytest
.PHONY: test
lint:
@echo "Running linters..."
ruff check
ruff format --diff
.PHONY: lint
check-requirements:
@echo "Checking requirements files..."
mkdir -p .tmp
pip-compile pyproject.toml --quiet --output-file=.tmp/$(REQUIREMENTS)
pip-compile pyproject.toml --quiet --extra=dev --output-file=.tmp/$(REQUIREMENTS_DEV)
diff -u $(REQUIREMENTS) .tmp/$(REQUIREMENTS) || (echo "$(REQUIREMENTS) doesn't match pyproject.toml" && exit 1)
diff -u $(REQUIREMENTS_DEV) .tmp/$(REQUIREMENTS_DEV) || (echo "$(REQUIREMENTS_DEV) doesn't match pyproject.toml" && exit 1)
@echo "Requirements files match pyproject.toml"
.PHONY: check-requirements
compile-requirements:
@echo "Compiling requirements files..."
pip-compile pyproject.toml --output-file=$(REQUIREMENTS)
pip-compile pyproject.toml --extra=dev --output-file=$(REQUIREMENTS_DEV)
.PHONY: compile-requirements