Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-44 Github action updates #53

Merged
merged 7 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/build-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.8, 3.9]
needs: [build_linux, build_windows, build_macos]
steps:
- uses: actions/checkout@v2
Expand All @@ -203,9 +203,12 @@ jobs:
cd python
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Test with pytest
run: |
cd python
pip install pytest
pip install pytest-cov
pytest test_keys.py test_ldproofs.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
pytest --cache-clear ./tests --cov=src > pytest-coverage.txt
- name: Comment coverage
uses: coroo/pytest-coverage-commentator@v1.0.2
with:
pytest-coverage: ./python/pytest-coverage.txt
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,5 @@ native/out.h
/Android/.idea
/Android/app/local.properties
/java/.idea
/dotnet/.idea
/dotnet/.idea
python/pytest-coverage.txt
38 changes: 17 additions & 21 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
# In Progress

Development in progress...
# Trinsic Okapi SDK
Python3 bindings for the Trinsic Okapi SDK:
1. didcomm implementation in `src/okapi`
2. Trinsic service gRPC bindings in `src/trinsic`
3. Unit tests `tests`
4. Binary libraries `libs`

## Installation

Install `grpcio`

First, upgrade pip

`pip3 install --upgrade pip`

Then, update the setup tools:

`python3 -m pip install --upgrade setuptools`

`pip3 install --no-cache-dir --force-reinstall -Iv grpcio==1.33.2`
1. `pip3 install --upgrade pip`
2. `pip3 install -r requirements.txt`
3. *TODO: Downloader for the binary libraries*
1. In the `libs` folder, place the binary library files. They are currently named:
1. Windows = `okapi.dll`
2. Mac OS X = `libokapi.dylib`
3. LINUX = `libokapi.so`
2. To find the latest binary packages, go to the [output of this action](https://github.com/trinsic-id/okapi/actions/workflows/build-libs.yml)
3. Click on the latest successful run, scroll down
4. Download appropriate output file

> Big Sure issue

```
pip install wheel && GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install grpcio
```

https://github.com/grpc/grpc/issues/24677

## To run the tests

Copy the platform specific library for your OS from the `libs` folder into `python` folder and rename to `libdidcommgrpc.so` regardless of which OS you are running. Python takes fixed library names.
https://github.com/grpc/grpc/issues/24677
171 changes: 0 additions & 171 deletions python/poetry.lock

This file was deleted.

21 changes: 5 additions & 16 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
[tool.poetry]
name = "didcomm-grpc"
version = "0.1.0"
description = "DIDComm extension for gRPC"
authors = ["Tomislav Markovski <tomislav@trinsic.id>"]
license = "Apache-2.0"

[tool.poetry.dependencies]
python = "^3.8"
grpcio = "^1.33.2"

[tool.poetry.dev-dependencies]
grpcio-tools = "^1.33.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
24 changes: 24 additions & 0 deletions python/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[metadata]
name = trinsic-okapi
version = 0.1.0
author = Scott Phillips
author_email = scott.phillips@trinsic.id
description = Trinsic okapi SDK bindings
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/trinsic-id/okapi/
project_urls =
Bug Tracker = https://github.com/trinsic-id/okapi/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: Apache License
Operating System :: OS Independent

[options]
package_dir =
= src
packages = find:
python_requires = >=3.8

[options.packages.find]
where = src
2 changes: 2 additions & 0 deletions python/src/okapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import examples_pb2, keys_pb2, proofs_pb2, transport_pb2
from . import okapi_utils
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def generate_proto_files() -> None:
:return:
"""
file_path = abspath(dirname(abspath(__file__)))
base_path = abspath(join(file_path, '..', 'proto'))
base_path = abspath(join(file_path, '../../..', 'proto'))
proto_file_path = abspath(join(base_path, "**", "*.proto"))
base_command = ['C:\\bin\\protoc.exe', f'--proto_path={base_path}', f'--proto_path=C:\\bin',
f'--python_out={file_path}']
Expand All @@ -27,7 +27,7 @@ def generate_better_proto_files() -> None:
:return:
"""
output_path = abspath(dirname(abspath(__file__)))
base_path = abspath(join(output_path, '', '..', 'proto'))
base_path = abspath(join(output_path, '', '../../..', 'proto'))
proto_file_path = abspath(join(base_path, "**", "*.proto"))
# Inject an empty python code file path to mimic the first argument.
# TODO - Come up with better locations, import google defaults from the package location (see code in protoc.main)
Expand All @@ -38,5 +38,10 @@ def generate_better_proto_files() -> None:
protoc.main(base_command)


def download_binary_files() -> None:
# TODO - Download the appropriate library files
raise NotImplementedError


if __name__ == "__main__":
generate_proto_files()
8 changes: 4 additions & 4 deletions python/okapi.py → python/src/okapi/keys.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from keys_pb2 import GenerateKeyRequest, GenerateKeyResponse, ResolveRequest, ResolveResponse
from okapi_utils import typed_wrap_and_call
from proofs_pb2 import CreateProofRequest, CreateProofResponse, VerifyProofRequest, VerifyProofResponse
from transport_pb2 import PackRequest, UnpackRequest, PackResponse, UnpackResponse, SignRequest, SignResponse, \
from .keys_pb2 import GenerateKeyRequest, GenerateKeyResponse, ResolveRequest, ResolveResponse
from .okapi_utils import typed_wrap_and_call
from .proofs_pb2 import CreateProofRequest, CreateProofResponse, VerifyProofRequest, VerifyProofResponse
from .transport_pb2 import PackRequest, UnpackRequest, PackResponse, UnpackResponse, SignRequest, SignResponse, \
VerifyRequest, VerifyResponse


Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion python/okapi_utils.py → python/src/okapi/okapi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def raise_error_if_needed(self):
def load_library() -> ctypes.CDLL:
global OKAPI_DLL
if OKAPI_DLL is None:
lib_path = join(dirname(abspath(__file__)), 'libs')
lib_path = join(dirname(abspath(__file__)), '../../libs')
sys = platform.system()
try:
OKAPI_DLL = ctypes.CDLL(abspath(join(lib_path, library_name[platform.system()])))
Expand Down
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion python/proofs_pb2.py → python/src/okapi/proofs_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions python/transport_pb2.py → python/src/okapi/transport_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions python/okapi_demo.py → python/src/okapi_demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from okapi import DIDKey
from keys_pb2 import GenerateKeyRequest, KeyType
from okapi.keys import DIDKey
from okapi.keys_pb2 import GenerateKeyRequest, KeyType

request = GenerateKeyRequest()
request.key_type = KeyType.Ed25519
Expand Down
Empty file added python/src/trinsic/__init__.py
Empty file.
Empty file added python/tests/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions python/test_keys.py → python/tests/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import unittest
import base58

from okapi import DIDKey
from keys_pb2 import GenerateKeyRequest, KeyType, GenerateKeyResponse
from okapi_utils import DidError
from src.okapi.keys import DIDKey
from src.okapi.keys_pb2 import GenerateKeyRequest, KeyType, GenerateKeyResponse
from src.okapi.okapi_utils import DidError


def base64_padding(base_64: str) -> str:
Expand Down
6 changes: 3 additions & 3 deletions python/test_ldproofs.py → python/tests/test_ldproofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import google.protobuf.struct_pb2

from keys_pb2 import GenerateKeyRequest, KeyType
from okapi import DIDKey, LDProofs
from proofs_pb2 import CreateProofRequest, LdSuite
from src.okapi.keys_pb2 import GenerateKeyRequest, KeyType
from src.okapi.keys import DIDKey, LDProofs
from src.okapi.proofs_pb2 import CreateProofRequest, LdSuite


class LdProofsTests(unittest.TestCase):
Expand Down