-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (56 loc) · 2.07 KB
/
Copy pathMakefile
File metadata and controls
68 lines (56 loc) · 2.07 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
PYTHON = python3.14
NAME = withpy
VERSION := $(shell grep '__version__' withpy/__init__.py | sed 's/.*"\(.*\)".*/\1/')
DIST_DIR = dist
DIST_BIN = $(DIST_DIR)/$(NAME)
ARCHIVE = $(NAME)-v$(VERSION).tar.xz
INSTALL_DIR = /usr/local/bin
.PHONY: all build test amalgamate dist install user-install uninstall clean run help
all: build
build:
$(PYTHON) -m py_compile withpy/__init__.py
$(PYTHON) -m py_compile withpy/__main__.py
$(PYTHON) -m py_compile withpy/cli.py
$(PYTHON) -m compileall -q withpy/commands/
test: amalgamate
$(PYTHON) -m pytest tests/ -v
amalgamate:
$(PYTHON) build.py
@echo "Built $(DIST_BIN) (v$(VERSION))"
dist: amalgamate
mkdir -p $(NAME)-$(VERSION)
cp -f $(DIST_BIN) README.md LICENSE $(NAME)-$(VERSION)/
tar cJf $(ARCHIVE) $(NAME)-$(VERSION)
rm -rf $(NAME)-$(VERSION)
@echo "Created $(ARCHIVE)"
@ls -lh $(ARCHIVE)
install: amalgamate
install -d $(INSTALL_DIR)
install -m 755 $(DIST_BIN) $(INSTALL_DIR)/$(NAME)
@echo "Installed $(NAME) to $(INSTALL_DIR)"
user-install: amalgamate
install -d $(HOME)/bin
install -m 755 $(DIST_BIN) $(HOME)/bin/$(NAME)
@echo "Installed $(NAME) to $(HOME)/bin/"
uninstall:
rm -f $(INSTALL_DIR)/$(NAME)
@echo "Removed $(NAME) from $(INSTALL_DIR)"
clean:
rm -rf $(DIST_DIR) __pycache__ .pytest_cache *.egg-info $(ARCHIVE) $(NAME)-$(VERSION)
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
run:
$(PYTHON) -m $(NAME)
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " build Compile-check all source files (default)"
@echo " test Run pytest suite (builds amalgamated artifact first)"
@echo " amalgamate Build single-file dist/$(NAME) via build.py"
@echo " dist Build amalgamated + create $(NAME)-v$(VERSION).tar.xz"
@echo " install Install to $(INSTALL_DIR) (requires sudo)"
@echo " user-install Install to $(HOME)/bin/"
@echo " uninstall Remove from $(INSTALL_DIR)"
@echo " clean Remove build artifacts and caches"
@echo " run Run via python -m $(NAME)"
@echo " help Show this help"