-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
145 lines (126 loc) · 4.53 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
135
136
137
138
139
140
141
142
143
144
145
.PHONY: help start clean build install build_dist pypi_token test release pytest git check \
version patch minor major
refresh: clean build install
ifeq ($(OS),Windows_NT)
RM = cmd.exe /C del /F /Q
RMDIR = cmd.exe /C rd /S /Q
PATHSEP = \\
PIPINSTALL = cmd.exe /C "FOR %%i in (dist\*.whl) DO python -m pip install --no-index --no-deps %%i"
CLEAN_PYCACHE = for /d /r . %%d in (__pycache__) do @(if exist "%%d" (rd /s /q "%%d"))
CLEAN_PYTESTCACHE = for /d /r . %%d in (.pytest_cache) do @(if exist "%%d" (rd /s /q "%%d"))
CLEAN_MYPYCACHE = for /d /r . %%d in (.mypy_cache) do @(if exist "%%d" (rd /s /q "%%d"))
else
UNAME_S := $(shell uname -s 2>/dev/null || echo "unknown")
ifeq ($(UNAME_S),Linux)
RM = rm -f
RMDIR = rm -rf
PATHSEP = /
PIPINSTALL = pip install dist/*.tar.gz
CLEAN_PYCACHE = find . -type d -name '__pycache__' -print0 | xargs -0 rm -rf
CLEAN_PYTESTCACHE = find . -type d -name '.pytest_cache' -print0 | xargs -0 rm -rf
CLEAN_MYPYCACHE = find . -type d -name '.mypy_cache' -print0 | xargs -0 rm -rf
endif
ifeq ($(UNAME_S),Darwin)
RM = rm -f
RMDIR = rm -rf
PATHSEP = /
PIPINSTALL = pip install dist/*.tar.gz
CLEAN_PYCACHE = find . -type d -name '__pycache__' -print0 | xargs -0 rm -rf
CLEAN_PYTESTCACHE = find . -type d -name '.pytest_cache' -print0 | xargs -0 rm -rf
CLEAN_MYPYCACHE = find . -type d -name '.mypy_cache' -print0 | xargs -0 rm -rf
endif
endif
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " pypi_token Set the poetry pypi-token, Run 'make pypi_token token=<token>' to set the poetry pypi_token"
@echo " release Publish package to PyPI:"
@echo " 1. Run 'make release token=<token>'"
@echo " 2. Run 'make release' if poetry pypi_token is already set"
@echo " version Shows the version of the project or bumps it when a valid bump rule is provided."
@echo " clean Clean up test files, mypy cache and dist folders"
@echo " git Set git proxy and line separator"
@echo " test Code test and coverage report"
@echo " start Pre-development setup steps"
@echo " build Poetry build"
@echo " build_dist Setuptools build"
@echo " install Install whl/tar.gz file from the dist folder"
@echo " check Code check"
@echo " pytest Code test"
@echo " help Show this help message"
start:
pip install poetry==2.0.1
poetry config virtualenvs.in-project true
poetry self add poetry-bumpversion
poetry env use python
poetry install -E "all"
poetry run pre-commit install
build:
poetry build
install:
$(PIPINSTALL)
build_dist:
make clean
python setup.py sdist bdist_wheel
pypi_token:
@echo "==> Setting up the poetry pypi-token..."
@poetry config pypi-token.pypi $(token)
@echo ":) Poetry pypi_token set successfully!"
release:
@if [ -n "$(token)" ]; then \
make pypi_token token=$(token); \
else \
echo "Please ensure the pypi-token is configured!"; \
fi
@echo "==> Publishing package to PyPI..."
poetry publish
@echo ":) Publish successfully"
test:
poetry install -E "all"
poetry run coverage run -m pytest
poetry run coverage combine
poetry run coverage report
pytest:
poetry install -E "all"
poetry run pytest -W ignore::DeprecationWarning
check:
poetry run pre-commit run --all-files
poetry run mypy .
poetry check
version:
@if [ "$(filter patch minor major,$(MAKECMDGOALS))" = "" ]; then \
poetry version; \
echo "Usage: make version [patch|minor|major]"; \
else \
poetry version $(filter patch minor major,$(MAKECMDGOALS)); \
fi
patch:
@:
minor:
@:
major:
@:
git:
git config core.eol lf
git config core.autocrlf input
git config core.safecrlf true
git config --global http.proxy http://127.0.0.1:7897
git config --global https.proxy http://127.0.0.1:7897
path = $(subst /,$(strip $(PATHSEP)),$1)
clean:
-$(CLEAN_PYCACHE)
-$(CLEAN_PYTESTCACHE)
-$(CLEAN_MYPYCACHE)
-$(RMDIR) $(call path, dist)
-$(RMDIR) $(call path, file.log)
-$(RMDIR) $(call path, docs$(PATHSEP)_build)
-$(RMDIR) $(call path, htmlcov)
-$(RM) $(call path, .coverage)
-$(RM) $(call path, .coverage.*)
-$(RM) $(call path, coverage.xml)
-$(RMDIR) $(call path, .tox)
-$(RM) $(call path, tests$(PATHSEP)docs$(PATHSEP)txt$(PATHSEP)run.log)
-$(RM) $(call path, tests$(PATHSEP)keys$(PATHSEP)localhost.crt)
-$(RM) $(call path, tests$(PATHSEP)keys$(PATHSEP)localhost.key)
pip uninstall -y ayugespidertools