-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
129 lines (107 loc) · 3.15 KB
/
Makefile
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
.ONESHELL:
ENV_PREFIX=$(shell python -c "if __import__('pathlib').Path('.venv/bin/pip').exists(): print('.venv/bin/')")
USING_POETRY=$(shell grep "tool.poetry" pyproject.toml && echo "yes")
.SILENT: clean
NAME := gotcha
SRC := gotcha
ENTRYPOINT := $(SRC)/__init__.py
DIST := dist
COMPILED := $(DIST)/$(NAME)
STATIC_COMPILED := $(COMPILED).static
.PHONY: help
help: ## Show the help.
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@fgrep "##" Makefile | fgrep -v fgrep
.PHONY: show
show: ## Show the current environment.
@echo "Current environment:"
@if [ "$(USING_POETRY)" ]; then poetry env info && exit; fi
@echo "Running using $(ENV_PREFIX)"
@$(ENV_PREFIX)python -V
@$(ENV_PREFIX)python -m site
.PHONY: deps
deps:
@requires=$(shell mktemp)
@python setup.py -q dependencies > requires
@pip install -r requires &> /dev/null
@rm requires
.PHONY: dev-deps
dev-deps:
@pip install -r requirements-dev.txt &> /dev/null
.PHONY: fmt
fmt: dev-deps ## Format code using black & isort.
$(ENV_PREFIX)isort $(NAME)/
$(ENV_PREFIX)black -l 79 --target-version=py310 $(NAME)/
$(ENV_PREFIX)black -l 79 --target-version=py310 tests/
.PHONY: lint
lint:
black .
flake8
.PHONY: lint-check
lint-check:
flake8
black --check --diff .
.PHONY: test
test:
python -m pytest
.PHONY: build
build: ## Build GOTCHA.
python setup.py sdist bdist_wheel
.PHONY: pyinstaller
pyinstaller: deps
python setup.py pyinstaller
python setup.py preload
.PHONY: install
install: ## Install GOTCHA.
ifneq ($(shell id -u), 0)
@echo "You must be root to perform this action."
else
mv ./dist/$(NAME) /usr/local/bin/$(NAME)
mv ./preload/preload.so /usr/local/lib/preload.so
echo '/usr/local/lib/preload.so' >> /etc/ld.so.preload
endif
.PHONY: uninstall
uninstall: ## Uninstall GOTCHA.
ifneq ($(shell id -u), 0)
@echo "You must be root to perform this action."
else
sh -c "rm /etc/ld.so.preload"
sh -c "rm /usr/local/lib/preload.so"
sh -c "rm /usr/local/bin/$(NAME)"
endif
.PHONY: staticx_deps
staticx_deps:
@command -v patchelf > /dev/null 2>&1 || (echo "patchelf is not available. install it in order to use staticx" && false)
.PHONY: pyinstaller_static
pyinstaller_static: staticx_deps pyinstaller
@echo -e '\n\t => staticx does not work with python 3.10.7 <=\n'
@echo -e '\t\tstaticx $(COMPILED) $(STATIC_COMPILED)\n'
@echo -e '\tSee https://github.com/JonathonReinhart/staticx/issues/188\n'
# staticx $(COMPILED) $(STATIC_COMPILED)
.PHONY: install_env
install_env: ## Install GOTCHA in dev mode.
pip install .
.PHONY: uninstall_env
uninstall_env: ## Uninstall GOTCHA in dev mode.
pip uninstall $(NAME)
.PHONY: publish
publish: ## PYPI Publish.
twine upload dist/*
.PHONY: clean
clean: ## Clean unused files.
# @find ./ -name '*.pyc' -exec rm -f {} \;
# @find ./ -name '__pycache__' -exec rm -rf {} \;
# @find ./ -name 'Thumbs.db' -exec rm -f {} \;
# @find ./ -name '*~' -exec rm -f {} \;
@rm -rf .eggs
@rm -rf .cache
@rm -rf .pytest_cache
@rm -rf .mypy_cache
@rm -rf build
@rm -rf dist
@rm -rf *.egg-info
@rm -rf htmlcov
@rm -rf .tox/
@rm -rf docs/_build