diff --git a/.gitignore b/.gitignore index f78ec3d..7e2386d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /vald-origin /vald +wordvecs1000.json # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/Makefile b/Makefile index 28e2069..aea417e 100755 --- a/Makefile +++ b/Makefile @@ -21,11 +21,10 @@ LANGUAGE = python PKGNAME = $(NAME)-client-$(LANGUAGE) PKGREPO = github.com/$(REPO)/$(PKGNAME) -PYTHON = python - VALD_DIR = vald-origin VALD_SHA = VALD_SHA VALD_CLIENT_PYTHON_VERSION = VALD_CLIENT_PYTHON_VERSION +VALD_CHECKOUT_REF ?= main BINDIR ?= /usr/local/bin @@ -58,6 +57,9 @@ PB2PYS = $(PROTOS:$(PROTO_ROOT)/%.proto=$(PB2DIR_ROOT)/$(SHADOW_ROOT)/%_pb2.py) MAKELISTS = Makefile +PYTHON_VERSION := $(eval PYTHON_VERSION := $(shell cat PYTHON_VERSION))$(PYTHON_VERSION) +TEST_DATASET_PATH = wordvecs1000.json + red = /bin/echo -e "\x1b[31m\#\# $1\x1b[0m" green = /bin/echo -e "\x1b[32m\#\# $1\x1b[0m" yellow = /bin/echo -e "\x1b[33m\#\# $1\x1b[0m" @@ -112,7 +114,17 @@ $(PB2DIR_ROOT): $(PB2PYS): proto/deps $(PB2DIR_ROOT) $(SHADOWS) $(VALD_DIR): - git clone --depth 1 https://$(VALDREPO) $(VALD_DIR) + git clone https://$(VALDREPO) $(VALD_DIR) + +.PHONY: vald/checkout +## checkout vald repository +vald/checkout: $(VALD_DIR) + cd $(VALD_DIR) && git checkout $(VALD_CHECKOUT_REF) + +.PHONY: vald/origin/sha/print +## print origin VALD_SHA value +vald/origin/sha/print: $(VALD_DIR) + @cd $(VALD_DIR) && git rev-parse HEAD | tr -d '\n' .PHONY: vald/sha/print ## print VALD_SHA value @@ -121,35 +133,20 @@ vald/sha/print: .PHONY: vald/sha/update ## update VALD_SHA value -vald/sha/update: vald - (cd vald; git rev-parse HEAD | tr -d '\n' > ../$(VALD_SHA)) +vald/sha/update: $(VALD_DIR) + (cd $(VALD_DIR); git rev-parse HEAD | tr -d '\n' > ../$(VALD_SHA)) -.PHONY: vald/client/python/version/print +.PHONY: vald/client/version/print ## print VALD_CLIENT_PYTHON_VERSION value -vald/client/python/version/print: +vald/client/version/print: @cat $(VALD_CLIENT_PYTHON_VERSION) -.PHONY: vald/client/python/version/update +.PHONY: vald/client/version/update ## update VALD_CLIENT_PYTHON_VERSION value -vald/client/python/version/update: vald +vald/client/version/update: $(VALD_DIR) (vald_version=`cat $(VALD_DIR)/versions/VALD_VERSION | sed -e 's/^v//'`; \ - client_version=`cat $(VALD_CLIENT_PYTHON_VERSION)`; \ - major=$${client_version%%.*}; client_version="$${client_version#*.}"; \ - minor=$${client_version%%.*}; client_version="$${client_version#*.}"; \ - patch=$${client_version%%.*}; client_version="$${client_version#*.}"; \ - if [ "$${vald_version}" = "$${major}.$${minor}.$${patch}" ]; then \ - if [ "$${patch}" = "$${client_version}" ]; then \ - new_version="$${major}.$${minor}.$${patch}.post1"; \ - else \ - rev="$${client_version#post}"; \ - rev=$$((rev+1)); \ - new_version="$${major}.$${minor}.$${patch}.post$${rev}"; \ - fi; \ - else \ - new_version="$${vald_version}"; \ - fi; \ - echo "VALD_VERSION: $${vald_version}, NEW_CLIENT_VERSION: $${new_version}"; \ - echo "$${new_version}" > VALD_CLIENT_PYTHON_VERSION) + echo "VALD_VERSION: $${vald_version}"; \ + echo "$${vald_version}" > VALD_CLIENT_PYTHON_VERSION) sed -i -e "s/^version = .*\$$/version = `cat VALD_CLIENT_PYTHON_VERSION`/" setup.cfg .PHONY: proto/deps @@ -166,3 +163,32 @@ $(BINDIR)/buf: "https://github.com/bufbuild/buf/releases/download/$$version/buf-$(shell uname -s)-$(shell uname -m)" \ -o "${BINDIR}/buf" && \ chmod +x "${BINDIR}/buf" + +.PHONY: ci/deps/install +## install deps for CI environment +ci/deps/install: + sudo apt-get update -y && sudo apt-get install -y \ + python3-setuptools \ + libprotobuf-dev \ + libprotoc-dev \ + protobuf-compiler + pip3 install grpcio-tools + +.PHONY: ci/test +## Execute test for CI environment +ci/test: $(TEST_DATASET_PATH) + python src/test.py + +$(TEST_DATASET_PATH): + curl -L https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs1000.json -o $(TEST_DATASET_PATH) + +.PHONY: ci/package/prepare +## prepare package to publish +ci/package/prepare: + python3 setup.py sdist + python3 setup.py bdist_wheel + +.PHONY: version/python +## Print Python version +version/python: + @echo $(PYTHON_VERSION) diff --git a/PYTHON_VERSION b/PYTHON_VERSION new file mode 100644 index 0000000..c8cfe39 --- /dev/null +++ b/PYTHON_VERSION @@ -0,0 +1 @@ +3.10