forked from marcinz606/NegPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (139 loc) · 5.46 KB
/
Copy pathMakefile
File metadata and controls
155 lines (139 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Variables
UV = uv run
# Optional per-developer settings, not in git. The usual content is NEGPY_USER_DIR,
# which moves the app's user directory (databases, caches, presets, logs) away from
# the production one. Absent, everything behaves as before.
-include .env.local
export NEGPY_USER_DIR
# A value that is not absolute means make did not expand what was written: it leaves ~
# alone, and reads $HOME as the variable H followed by "OME". Either one quietly puts the
# development user directory inside the checkout, so stop here with the correction.
ifneq ($(NEGPY_USER_DIR),)
ifneq ($(patsubst /%,,$(NEGPY_USER_DIR)),)
$(error NEGPY_USER_DIR is "$(NEGPY_USER_DIR)", which is not an absolute path. make does not expand ~ or $$HOME in .env.local — write $$(HOME)/your-dir, or a full path)
endif
endif
# Default target
.PHONY: all
all: format lint type test
# Install dependencies
.PHONY: install
install:
@echo "Installing dependencies with uv..."
@uv sync --all-groups
# Sync dependencies
.PHONY: sync
sync:
@echo "Syncing dependencies with uv..."
@uv sync --all-groups
# Lint checks (ruff)
.PHONY: lint
lint:
@echo "Running lint checks (ruff)..."
@$(UV) ruff check .
# Type checks (ty)
.PHONY: type
type:
@echo "Running type checks (ty)..."
@$(UV) ty check \
--exclude "tests/" --exclude "docs/" --exclude "build/" --exclude "dist/" --exclude ".venv/" \
--ignore "no-matching-overload" \
--ignore "unresolved-attribute" \
--ignore "invalid-method-override" \
--ignore "not-iterable" \
--ignore "unsupported-operator" \
--ignore "invalid-argument-type" \
--ignore "unused-type-ignore-comment" \
--ignore "unresolved-import" \
--ignore "unsupported-bool-conversion" \
--ignore "invalid-assignment" \
--ignore "invalid-parameter-default" \
--ignore "call-non-callable"
# Unit tests (pytest)
.PHONY: test
test:
@echo "Running unit tests (pytest)..."
@$(UV) pytest tests/ --cov=negpy --cov-report=term-missing
# Auto-format and fix (ruff)
.PHONY: format
format:
@echo "Running ruff format and fix..."
@$(UV) ruff format .
@$(UV) ruff check --fix .
# Run the application locally
.PHONY: run
run:
@echo "Starting NegPy Desktop..."
@$(UV) python desktop.py
# Delete the development user directory, so the next run starts with no saved edits
# and no caches. Refuses to run against the default directory: that is the real
# install. Set NEGPY_USER_DIR (see .env.local) to a scratch path first.
# FORCE=1 skips the confirmation.
.PHONY: clear-devhome
clear-devhome:
@dir="$$NEGPY_USER_DIR"; \
if [ -z "$$dir" ]; then \
echo "NEGPY_USER_DIR is not set — nothing to clear."; \
echo "Set it in .env.local to a scratch directory, then run this again."; \
exit 1; \
fi; \
default=$$($(UV) python -c "import os; os.environ.pop('NEGPY_USER_DIR', None); from negpy.kernel.system.paths import get_default_user_dir; print(get_default_user_dir())"); \
if [ "$$(cd "$$dir" 2>/dev/null && pwd)" = "$$(cd "$$default" 2>/dev/null && pwd)" ]; then \
echo "Refusing to clear $$dir — that is the default user directory."; \
exit 1; \
fi; \
if [ ! -d "$$dir" ]; then echo "$$dir does not exist — nothing to clear."; exit 0; fi; \
if [ "$(FORCE)" != "1" ]; then \
printf "Delete %s and everything in it? [y/N] " "$$dir"; \
read reply; \
case "$$reply" in [yY]*) ;; *) echo "Cancelled."; exit 1;; esac; \
fi; \
rm -rf "$$dir"; \
echo "Cleared $$dir"
# Run against a locally built sane-backends from rohanpandula's fork: coolscan3
# with infrared un-gated (stock compiles it out; LS-50 reports no IR channel),
# the frame advance corrected from the LS-30-era 1.5 in guess (38.106 mm) to the
# true 135 pitch of 38.0 mm (8 x 4.75 mm perforations — halves per-frame drift,
# A/B-measured -0.277 -> -0.143 mm/frame on an LS-50), plus load/eject parameter
# zeroing. Build: make sane-rgbi-help
SANE_RGBI ?= $(HOME)/.local/share/negpy-sane-38mm
.PHONY: run-ir
run-ir:
@test -d "$(SANE_RGBI)/lib/sane" || { \
echo "No patched sane-backends at $(SANE_RGBI)"; \
echo "Run 'make sane-rgbi-help' for how to build it, or set SANE_RGBI=<prefix>."; \
exit 1; }
@echo "Starting NegPy Desktop with IR-enabled coolscan3 ($(SANE_RGBI))..."
@LD_LIBRARY_PATH="$(SANE_RGBI)/lib" SANE_CONFIG_DIR="$(SANE_RGBI)/etc/sane.d" $(UV) python desktop.py
.PHONY: sane-rgbi-help
sane-rgbi-help:
@echo "Build the IR-enabled, 38 mm-pitch coolscan3 backend (nothing system-wide is touched):"
@echo ""
@echo " git clone --depth 30 --branch coolscan3-ls5000-38mm-frame-pitch \\"
@echo " https://gitlab.com/rohanpandula/backends.git && cd backends"
@echo " # the pitch fix is gated CS3_TYPE_LS5000 only — on an LS-50 widen the"
@echo " # gate in backend/coolscan3.c (frame_offset assignment):"
@echo " # if (s->type == CS3_TYPE_LS5000 || s->type == CS3_TYPE_LS50)"
@echo " # if ./configure errors on AX_* macros, install autoconf-archive (or drop"
@echo " # ax_create_stdint_h.m4 + ax_cxx_compile_stdcxx*.m4 into m4/), rerun autogen.sh"
@echo " ./autogen.sh"
@echo " ./configure --prefix=$(SANE_RGBI) BACKENDS=coolscan3 --disable-translations --disable-avahi"
@echo " make -j\$$(nproc) && make install"
@echo ""
@echo "Then: make run-ir (verify with: caps.ir_channel == True)"
# Build the application
.PHONY: build
build:
@echo "Building NegPy..."
rm -rf dist/
@$(UV) python build.py
# Clean up caches and build artifacts
.PHONY: clean
clean:
@echo "Cleaning up..."
rm -rf .pytest_cache
rm -rf .mypy_cache
rm -rf .ruff_cache
rm -rf build
rm -rf dist
find . -type d -name "__pycache__" -exec rm -rf {} +