-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
67 lines (53 loc) · 2.08 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
SQLFLOW_VERSION := develop
VERSION_FILE := sqlflow/_version.py
SHELL := /bin/bash
setup: ## Setup virtual environment for local development
python3 -m venv venv
source venv/bin/activate \
&& $(MAKE) install-requirements protoc
install-requirements:
pip install -e .
test: ## Run tests
python3 setup.py test
clean: ## Clean up temporary folders
rm -rf build dist .eggs *.egg-info .pytest_cache sqlflow/proto
# NOTE(typhoonzero): grpcio-tools >= 1.29.0 breaks the tests like:
# AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
protoc: ## Generate python client from proto file
python3 -m venv build/grpc
source build/grpc/bin/activate \
&& pip install grpcio-tools==1.29.0 \
&& mkdir -p build/grpc/sqlflow/proto \
&& python -m grpc_tools.protoc -Iproto --python_out=. \
--grpc_python_out=. proto/sqlflow/proto/sqlflow.proto
release: ## Release new version
$(if $(shell git status -s), $(error "Please commit your changes or stash them before you release."))
# Make sure local develop branch is up-to-date
git fetch origin
git checkout develop
git merge origin/develop
# Remove dev from version number
$(eval VERSION := $(subst .dev,,$(shell python -c "exec(open('$(VERSION_FILE)').read());print(__version__)")))
$(info release $(VERSION)...)
sed -i '' "s/, 'dev'//" $(VERSION_FILE)
git commit -a -m "release $(VERSION)"
# Tag it
git tag v$(VERSION)
# Bump version for development
$(eval NEXT_VERSION := $(shell echo $(VERSION) | awk -F. '{print $$1"."($$2+1)".0"}'))
$(eval VERSION_CODE := $(shell echo $(NEXT_VERSION) | sed 's/\./, /g'))
sed -i '' -E "s/[0-9]+, [0-9]+, [0-9]+/$(VERSION_CODE), 'dev'/" $(VERSION_FILE)
git commit -a -m "start $(NEXT_VERSION)"
git push origin develop
# Push the tag, release the package to pypi
git push --tags
doc:
$(MAKE) setup \
&& source venv/bin/activate \
&& pip install sphinx \
&& cd doc \
&& make clean && make html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help doc
.DEFAULT_GOAL := help