-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
134 lines (114 loc) · 3.85 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
129
130
131
132
133
134
export VERSION = $(shell python -c "from houdini_package_manager import __version__; print(__version__)")
export NAME = HPM
export EXECUTABLE = $(NAME)-$(VERSION)
# run the app from main.py
.PHONY: run
run:
@python main.py
# run the exe build
.PHONY: run-exe
run-exe:
.\dist\${EXECUTABLE}\${EXECUTABLE}.exe
## create the dist build and zip, and place them in the houpm site dist folder
.PHONY: prepare
prepare:
@echo "Building requirements.txt"
make toml-to-req
@echo "Updating HPM version in houpm HTML."
make update-houpm
@echo "Creating tagged version commit."
@git add .
@git commit -m "$(VERSION)"
@git tag -a "$(VERSION)" -m "$(VERSION)"
@echo "Finished prepare."
@echo "Push this tagged commit to trigger the GitHub Actions workflow that creates a GitHub release with a new build, and a PyPI release."
# build app executable from python using pyinstaller
define build_executable
@poetry run pyinstaller $(if $(filter -w,$(1)), -w,) --name="${EXECUTABLE}" --icon="Houdini_Package_Manager/resources/icons/hpm.ico" --add-data="houdini_package_manager/resources;resources" main.py
@echo "Built: ${EXECUTABLE}"
endef
# build executable, no console
# "make build-exe TEST=0" to skip testing
.PHONY: build-exe
build-exe:
ifeq ($(TEST), )
make test
else
@echo "Skipping pytests."
endif
$(call build_executable, -w)
make zip
# build executable, with console
# "make build-exe-log TEST=0" to skip testing
.PHONY: build-exe-log
build-exe-log:
ifeq ($(TEST), )
make test
else
@echo "Skipping pytests."
endif
$(call build_executable)
make zip
# convert pyproject.toml to requirement.txt
.PHONY: toml-to-req
toml-to-req:
@python dev/pyproject-to-requirements/convert.py .
# update HPM version html in houpm website
.PHONY: update-houpm
update-houpm:
@powershell -Command "(Get-Content docs/index.html) \
-replace '[0-9]+\.[0-9]+\.[0-9]+/HPM-[0-9]+\.[0-9]+\.[0-9]+.zip', '$(VERSION)/HPM-$(VERSION).zip' \
-replace '>Download HPM [0-9]+\.[0-9]+\.[0-9]+', '>Download HPM $(VERSION)' \
| Set-Content docs/index.html"
@echo "Updated HPM version html in houpm website..."
.PHONY: zip
zip:
@echo "Zipping build: ${EXECUTABLE}"
@python -c "import shutil; shutil.make_archive('dist/${EXECUTABLE}', 'zip', 'dist/${EXECUTABLE}')"
@echo ".zip created: ${EXECUTABLE}"
.PHONY: install
install: ## Install the poetry environment and install the pre-commit hooks
@echo "🚀 Creating virtual environment using pyenv and poetry"
@poetry install
@poetry run pre-commit install
@poetry shell
.PHONY: check
check: ## Run code quality tools.
@echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
@poetry lock --check
@echo "🚀 Linting code: Running pre-commit"
@poetry run pre-commit run -a
@echo "🚀 Static type checking: Running mypy"
@poetry run mypy
@echo "🚀 Checking for obsolete dependencies: Running deptry"
@poetry run deptry .
.PHONY: test
test: ## Test the code with pytest
@echo "🚀 Testing code: Running pytest"
@poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml
.PHONY: build
build: clean-build ## Build wheel file using poetry
@echo "🚀 Creating wheel file"
@poetry build
.PHONY: clean-build
clean-build: ## clean build artifacts
@rm -rf dist
.PHONY: publish
publish: ## publish a release to pypi.
@echo "🚀 Publishing: Dry run."
@poetry config pypi-token.pypi $(PYPI_TOKEN)
@poetry publish --dry-run
@echo "🚀 Publishing."
@poetry publish
.PHONY: build-and-publish
build-and-publish: build publish ## Build and publish.
.PHONY: docs-test
docs-test: ## Test if documentation can be built without warnings or errors
@poetry run mkdocs build -s
.PHONY: docs
docs: ## Build and serve the documentation
@poetry run mkdocs serve
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help