-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (77 loc) · 3.28 KB
/
Copy pathMakefile
File metadata and controls
112 lines (77 loc) · 3.28 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
.PHONY: tests help install venv lint dstart isort tcheck build commit-checks prepare pypibuild pypipush
SHELL := /usr/bin/bash
.ONESHELL:
help:
@printf "\ninstall\n\tinstall requirements\n"
@printf "\nisort\n\tmake isort import corrections\n"
@printf "\nlint\n\tmake linter check with black\n"
@printf "\ntcheck\n\tmake static type checks with mypy\n"
@printf "\ntests\n\tLaunch tests\n"
@printf "\nprepare\n\tLaunch tests and commit-checks\n"
@printf "\ncommit-checks\n\trun pre-commit checks on all files\n"
@printf "\pypibuild \n\tbuild image package for pypi\n"
@printf "\pypipush \n\push package to pypi\n"
# check for "CI" not in os.environ || "GITHUB_RUN_ID" not in os.environ
venv_activated=if [ -z $${VIRTUAL_ENV+x} ] && [ -z $${GITHUB_RUN_ID+x} ] ; then printf "activating venv...\n" ; source .venv/bin/activate ; else printf "venv already activated or GITHUB_RUN_ID=$${GITHUB_RUN_ID} is set\n"; fi
install: venv
venv: .venv/touchfile
.venv/touchfile: requirements.txt requirements-dev.txt requirements-build.txt
@if [ -z "$${GITHUB_RUN_ID}" ]; then \
test -d .venv || python3.14 -m venv .venv; \
source .venv/bin/activate; \
pip install -r requirements-build.txt; \
touch .venv/touchfile; \
else \
echo "Skipping venv setup because GITHUB_RUN_ID is set"; \
fi
tests: venv
@$(venv_activated)
pytest .
lint: venv
@$(venv_activated)
black -l 120 .
isort: venv
@$(venv_activated)
isort .
tcheck: venv
@$(venv_activated)
mypy *.py scripts mqttstuff
.git/hooks/pre-commit: venv
@$(venv_activated)
pre-commit install
commit-checks: .git/hooks/pre-commit
@$(venv_activated)
pre-commit run --all-files
prepare: tests commit-checks
mqttstuff_SOURCES := mqttstuff/*
VENV_DEPS := requirements.txt requirements-dev.txt requirements-build.txt
# VERSION := $(shell egrep -m 1 ^version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | tr -d " " | cut -d'=' -f2)
VERSION := $(shell $(venv_activated) > /dev/null 2>&1 && hatch version 2>/dev/null || echo HATCH_NOT_FOUND)
#echo:
# @printf "VERSION: $(VERSION)"
dist/mqttstuff-$(VERSION).tar.gz dist/mqttstuff-$(VERSION)-py3-none-any.whl dist/.touchfile: $(mqttstuff_SOURCES) $(VENV_DEPS) pyproject.toml
@printf "VERSION: $(VERSION)\n"
@$(venv_activated)
# hatch version fix # would bump version
hatch build --clean
@touch dist/.touchfile
pypibuild: venv dist/mqttstuff-$(VERSION).tar.gz dist/mqttstuff-$(VERSION)-py3-none-any.whl
dist/.touchfile_push: dist/mqttstuff-$(VERSION).tar.gz dist/mqttstuff-$(VERSION)-py3-none-any.whl
@$(venv_activated)
hatch publish -r main
@touch dist/.touchfile_push
pypipush: venv dist/.touchfile_push
# From https://hatch.pypa.io/latest/publish/#authentication
# HATCH_INDEX_USER and HATCH_INDEX_AUTH
# UPLOAD (old twine):
# python3 -m twine upload --repository testpypi dist/*
# UPLOAD to pypitest with hatch:
# hatch publish -r test
# UPLOAD to pypi(main) with hatch:
# hatch publish -r main
# INSTALL from test
# python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-YOUR-USERNAME-HERE
# INSTALL from test (if not found on pypitest -> install from normal pypi
# python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ mqttstuff==0.0.1
# INSTALL from pypi(main)
# python3 -m pip install mqttstuff==0.0.1