forked from timbertson/python-readability
-
Notifications
You must be signed in to change notification settings - Fork 351
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (64 loc) · 1.96 KB
/
Copy pathMakefile
File metadata and controls
82 lines (64 loc) · 1.96 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
# Makefile to help automate tasks
PYTHON_SYSTEM ?= python3
PY := $(CURDIR)/.venv/bin/python
BENCHMARK_MIN_SCORE ?= 0.95
VERSION := $(shell sed -n 's/^__version__ = "\(.*\)"/\1/p' readability/__init__.py)
DIST_FILES := dist/readability_lxml-$(VERSION)-py3-none-any.whl \
dist/readability_lxml-$(VERSION).tar.gz
# ###########
# Tests rule!
# ###########
.PHONY: test
test: develop
$(PY) -m pytest -q
.PHONY: benchmark
benchmark: venv develop
$(PY) -m readability.benchmark --min-score $(BENCHMARK_MIN_SCORE)
# #######
# INSTALL
# #######
.PHONY: all
all: setup develop
venv: .venv/bin/python
setup: venv
$(PY) -m pip install -U pip
$(PY) -m pip install -r requirements-dev.txt
.venv/bin/python:
test -x .venv/bin/python || $(PYTHON_SYSTEM) -m venv .venv
.PHONY: clean
clean:
rm -rf .venv
.PHONY: develop
develop: setup
$(PY) -m pip install -e .
# ###########
# Development
# ###########
.PHONY: clean_all
clean_all: clean
.PHONY: lint
lint: setup
$(PY) -m flake8 readability tests benchmarks
.PHONY: check-version
check-version:
test "$(VERSION)" = "$$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml | head -n 1)"
.PHONY: build
build:
$(PY) -m build
.PHONY: check-dist
check-dist: setup build
$(PY) -m twine check $(DIST_FILES)
.PHONY: check pre-release
check pre-release: develop lint test benchmark check-version check-dist
# ###########
# Deploy
# ###########
.PHONY: dist
dist: check-dist
.PHONY: upload
upload: check-dist
$(PY) -m twine upload $(DIST_FILES)
.PHONY: bump
bump:
test -n "$(NEW_VERSION)"
$(PYTHON_SYSTEM) -c 'from pathlib import Path; files = [(Path("readability/__init__.py"), "__version__ = \"$(VERSION)\"", "__version__ = \"$(NEW_VERSION)\""), (Path("pyproject.toml"), "version = \"$(VERSION)\"", "version = \"$(NEW_VERSION)\"")]; contents = [(path, path.read_text(), old, new) for path, old, new in files]; assert all(old in text for path, text, old, new in contents); [path.write_text(text.replace(old, new, 1)) for path, text, old, new in contents]'