eynollah/Makefile

80 lines
2.5 KiB
Makefile
Raw Normal View History

2025-03-31 14:13:16 +02:00
PYTHON ?= python3
PIP ?= pip3
2021-02-04 15:21:14 +01:00
2024-09-16 18:21:14 +02:00
# DOCKER_BASE_IMAGE = artefakt.dev.sbb.berlin:5000/sbb/ocrd_core:v2.68.0
2025-03-31 14:13:16 +02:00
DOCKER_BASE_IMAGE = docker.io/ocrd/core-cuda-tf2:v3.3.0
2024-09-16 18:21:14 +02:00
DOCKER_TAG = ocrd/eynollah
2025-03-31 14:13:16 +02:00
#MODEL := 'https://qurator-data.de/eynollah/2021-04-25/models_eynollah.tar.gz'
#MODEL := 'https://qurator-data.de/eynollah/2022-04-05/models_eynollah_renamed.tar.gz'
MODEL := 'https://qurator-data.de/eynollah/2022-04-05/models_eynollah.tar.gz'
#MODEL := 'https://github.com/qurator-spk/eynollah/releases/download/v0.3.0/models_eynollah.tar.gz'
#MODEL := 'https://github.com/qurator-spk/eynollah/releases/download/v0.3.1/models_eynollah.tar.gz'
PYTEST_ARGS ?=
2024-09-16 18:21:14 +02:00
# BEGIN-EVAL makefile-parser --make-help Makefile
help:
@echo ""
@echo " Targets"
@echo ""
2025-03-31 14:13:16 +02:00
@echo " docker Build Docker image"
@echo " build Build Python source and binary distribution"
@echo " install Install package with pip"
@echo " install-dev Install editable with pip"
2025-03-31 14:13:16 +02:00
@echo " deps-test Install test dependencies with pip"
@echo " models Download and extract models to $(CURDIR)/models_eynollah"
@echo " smoke-test Run simple CLI check"
2020-11-27 14:38:29 +01:00
@echo " test Run unit tests"
@echo ""
@echo " Variables"
2025-03-31 14:13:16 +02:00
@echo " DOCKER_TAG Docker image tag for 'docker' [$(DOCKER_TAG)]"
@echo " PYTEST_ARGS pytest args for 'test' (Set to '-s' to see log output during test execution, '-vv' to see individual tests. [$(PYTEST_ARGS)]"
@echo " MODEL URL of 'models' archive to download for 'test' [$(MODEL)]"
@echo ""
# END-EVAL
2020-11-23 13:40:54 +01:00
# Download and extract models to $(PWD)/models_eynollah
models: models_eynollah
2023-03-31 02:21:36 +02:00
models_eynollah: models_eynollah.tar.gz
2025-03-31 14:13:16 +02:00
tar zxf models_eynollah.tar.gz
2020-11-23 13:40:54 +01:00
models_eynollah.tar.gz:
2025-03-31 14:13:16 +02:00
wget $(MODEL)
build:
$(PIP) install build
$(PYTHON) -m build .
2020-11-23 13:40:54 +01:00
# Install with pip
install:
2025-03-31 14:13:16 +02:00
$(PIP) install .
# Install editable with pip
install-dev:
2025-03-31 14:13:16 +02:00
$(PIP) install -e .
deps-test:
$(PIP) install -r requirements-test.txt
2020-11-23 13:40:54 +01:00
2025-03-31 14:13:16 +02:00
smoke-test: deps-test
eynollah layout -i tests/resources/kant_aufklaerung_1784_0020.tif -o . -m $(CURDIR)/models_eynollah
2020-11-27 14:38:29 +01:00
# Run unit tests
2025-03-31 14:13:16 +02:00
test: deps-test
EYNOLLAH_MODELS=$(CURDIR)/models_eynollah $(PYTHON) -m pytest tests --durations=0 --continue-on-collection-errors $(PYTEST_ARGS)
2024-09-16 18:21:14 +02:00
# Build docker image
docker:
docker build \
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
--build-arg VCS_REF=$$(git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
-t $(DOCKER_TAG) .
2025-03-31 14:13:16 +02:00
.PHONY: models build install install-dev test smoke-test docker help