Skip to content

Commit

Permalink
Pypi rename wechaty grpc (#118)
Browse files Browse the repository at this point in the history
* follow latest grpc proto annotations & rename

* deprecate merge-rpoto.sh (#46)

* install third party proto files

* 0.20.5

* install proto by github actions

* 0.20.6

* add cache for pypi install

* 0.20.7
  • Loading branch information
huan authored Feb 22, 2021
1 parent e0e2ec5 commit 09d245c
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 20 deletions.
41 changes: 38 additions & 3 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: 3.9
- uses: actions/cache@master
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Protoc
uses: arduino/setup-protoc@master
- name: Install Protoc 3rd party protos
run: scripts/install-protoc.sh

- name: Install dependencies
run: |
cd python
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
make install
- name: Test
run: |
cd python
Expand All @@ -37,6 +48,18 @@ jobs:
- uses: actions/setup-python@v1
with:
python-version: 3.9
- uses: actions/cache@master
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Protoc
uses: arduino/setup-protoc@master
- name: Install Protoc 3rd party protos
run: scripts/install-protoc.sh

- name: Install dependencies
run: |
cd python
Expand All @@ -60,7 +83,19 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.7'
python-version: '3.9'
- uses: actions/cache@master
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Protoc
uses: arduino/setup-protoc@master
- name: Install Protoc 3rd party protos
run: scripts/install-protoc.sh

- name: Install dependencies
run: |
cd python
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ t.*
.idea
target/

# Python
python/src/

# csharp
*.nupkg
.vs/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-grpc",
"version": "0.20.5",
"version": "0.20.7",
"description": "gRPC for Wechaty",
"main": "dist/src/mod.js",
"typings": "dist/src/mod.d.js",
Expand Down
2 changes: 1 addition & 1 deletion python/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chatie-grpc/
src/wechaty_grpc
7 changes: 4 additions & 3 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ all : generate

.PHONY: clean
clean:
rm -fr generated/*
rm -fr src/*

.PHONY: install
install:
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
../scripts/install-protoc.sh

.PHONY: test
pytest:
python3 -m pytest src/ tests/
test:
python3 -m pytest tests/

code:
code .
Expand Down
15 changes: 11 additions & 4 deletions python/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ shopt -s globstar
#

# Directory to write generated code to (.js and .d.ts files)
OUT_DIR="./src/chatie_grpc"
OUT_DIR="./src/wechaty_grpc"
[ -d ${OUT_DIR} ] || {
mkdir -p ${OUT_DIR}
}

./merge-proto.sh > "$OUT_DIR/chatie-grpc.proto"
PROTO_DIR="$OUT_DIR"
# ./merge-proto.sh > "$OUT_DIR/wechaty_grpc.proto"
# PROTO_DIR="$OUT_DIR"
PROTO_DIR=../proto/wechaty

PROTOC_CMD="python3 -m grpc_tools.protoc --proto_path=${PROTO_DIR} --proto_path=/usr/local/include/ ${PROTO_DIR}/**/*.proto"
PROTOC_CMD="python3 \
-m grpc_tools.protoc \
--proto_path=${PROTO_DIR} \
--proto_path=../third-party \
--proto_path=/usr/local/include/ \
${PROTO_DIR}/puppet.proto \
"

$PROTOC_CMD \
--python_betterproto_out=${OUT_DIR}
7 changes: 7 additions & 0 deletions python/merge-proto.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/usr/bin/env bash

#
# DEPRECATED: this script was deprecated
# https://github.com/wechaty/grpc/issues/46
#
# Huan(20200222): betterproto[compiler]>=2.0.0b2 is OK
#

set -eo pipefail

function echo_name () {
Expand Down
2 changes: 1 addition & 1 deletion python/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
betterproto[compiler]>=2.0.0b1
betterproto[compiler]>=2.0.0b2
grpcio-tools
pyee
pylint_quotes
Expand Down
6 changes: 3 additions & 3 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def setup() -> None:
version = versioning(pkg['version'])

setuptools.setup(
name='chatie-grpc',
name='wechaty-grpc',
version=version,
author='Huan LI (李卓桓)',
author_email='[email protected]',
description='gRPC for Chatie',
description='Wechaty Puppet Service gRPC API',
long_description=long_description,
long_description_content_type='text/markdown',
license='Apache-2.0',
url='https://github.com/chatie/grpc',
url='https://github.com/wechaty/grpc',
packages=setuptools.find_packages("src"),
package_dir={'': 'src'},
classifiers=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

def test_smoke_testing() -> None:
""" wechaty """
assert pytest, 'should True'
assert pytest, 'To-be added'

0 comments on commit 09d245c

Please sign in to comment.