|
| 1 | +# Automate pip package development |
| 2 | +# |
| 3 | +# Usage |
| 4 | +# To release a package. |
| 5 | +# - update version in serpapi/_version.py |
| 6 | +# - review README version |
| 7 | +# - run |
| 8 | +# $ make release |
| 9 | + |
| 10 | +# current version |
| 11 | +version=$(shell grep version setup.py | cut -d"'" -f2) |
| 12 | +dist=dist/serpapi-$(version).tar.gz |
| 13 | + |
| 14 | +.PHONY: build |
| 15 | + |
| 16 | +all: clean install readme doc lint test build oobt check |
| 17 | + |
| 18 | +clean: |
| 19 | + find . -name '*.pyc' -delete |
| 20 | + find . -type d -name "__pycache__" -delete |
| 21 | + python3 -m pip uninstall serpapi |
| 22 | + |
| 23 | +# lint check |
| 24 | +lint: |
| 25 | + python3 -m pylint serpapi |
| 26 | + |
| 27 | +# test with Python 3 |
| 28 | +test: |
| 29 | + python3 -mpytest --cov=serpapi --cov-report html tests/*.py |
| 30 | + |
| 31 | +# install dependencies |
| 32 | +# |
| 33 | +# pytest-cov - code coverage extension for pytest |
| 34 | +# sphinx - documentation |
| 35 | +# twine - release automation |
| 36 | +install: |
| 37 | + python3 -m pip install -U setuptools |
| 38 | + python3 -m pip install -r requirements.txt |
| 39 | + python3 -m pip install pylint |
| 40 | + python3 -m pip install pytest-cov |
| 41 | + python3 -m pip install twine |
| 42 | + python3 -m pip install sphinx |
| 43 | + |
| 44 | +readme: |
| 45 | + erb -T '-' README.md.erb > README.md |
| 46 | + |
| 47 | +doc: readme |
| 48 | + $(MAKE) -C docs/ html |
| 49 | + |
| 50 | +# TODO upgrade those commands |
| 51 | +# https://packaging.python.org/tutorials/packaging-projects/ |
| 52 | +build: |
| 53 | + python3 setup.py sdist |
| 54 | + |
| 55 | +# out of box testing / user acceptance before delivery |
| 56 | +oobt: build |
| 57 | + python3 -m pip install ./${dist} |
| 58 | + python3 oobt/demo.py |
| 59 | + |
| 60 | +check: oobt |
| 61 | + python3 -m twine check ${dist} |
| 62 | + |
| 63 | +release: # check |
| 64 | + python3 -m twine upload ${dist} |
| 65 | + |
| 66 | +# run example only |
| 67 | +# and display output (-s) |
| 68 | +example: |
| 69 | + python3 -m pytest -s "tests/test_example.py::TestExample::test_async" |
0 commit comments