Skip to content

dolittle-obsolete/Python.SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python.SDK

How to build (for now)

As the dolittle-timeseries-runtime-contracts are broken atm we need to build the .proto files locally:

  1. Clone the contracts repo (ssh or https):
git clone --recursive [email protected]:dolittle-timeseries/Contracts.Runtime.git
  1. Change into the repo, setup the python env, use your choice of python environment management and folder name etc:
cd Contracts.Runtime
virtualenv -p python3 env
source env/bin/activate
# requirements are defined in dolittle-tools/Contracs.Build repo, this is enough for now
pip install grpcio grpcio-tools
  1. Setup the folders for generated files, the folder name defines the name of the imported package in python:
mkdir -p Generation/Python/dolittle_timeseries_runtime_contracts
  1. Cd into the Source folder (this is because the protoc tools is very finicky with the paths and stuff) and build the files with the grpc_tools, this also depends on your shell having the globstar option set to understand the double asterisk ** syntax (bash on default doesn't):
cd Source/
python -m grpc_tools.protoc -I./ --python_out=../Generation/Python/dolittle_timeseries_runtime_contracts/ --grpc_python_out=../Generation/Python/dolittle_timeseries_runtime_contracts/ **/*.proto
  1. Now we have the generated code in Contracts.Runtime/Generation/Python/dolittle_timeseries_runtime_contracts/ and then we can install it locally by writing a setup.py for it inside the Contracts.Runtime/Generation/Python/:
from setuptools import setup, find_namespace_packages

setup(
  # this name defines the packages name for pypi
  name = 'dolittle-timeseries-runtime-contracts',
  packages = find_namespace_packages(),
  version = '1.0.0',
  license='MIT',
  author = 'Dolittle',
  author_email = '[email protected]',
  url = 'https://github.com/dolittle-timeseries/Contracts.Runtime',
  keywords = ['Dolittle', 'gRPC', 'Contracts'],
  install_requires=[
    'protobuf3',
    'protobuf'
  ],
  python_requires='>=3.3',
  classifiers=[
    'Intended Audience :: Developers',      
    'License :: OSI Approved :: MIT License'
  ]
)
  1. Now we have everything ready for it to be installed into your Python.SDK repo so set that up first:
git clone [email protected]:dolittle-timeseries/Python.SDK.git
cd Python.SDK
virtualenv -p python3 env
source env/bin/activate
# target it into the generated dolittle_timeseries_contracts_runtime folder where the setup.py is
pip install ../Contracts.Runtime/Generation/Python
  1. Now we have everything ready for importing it into our own files inside the Python.SDK like this:
from dolittle_timeseries_runtime_contracts.Connectors import PullConnector_pb2

print(PullConnector_pb2)
print(PullConnector_pb2.PullConnector)
puller = PullConnector_pb2.PullConnector()

There are still some problems with the importing etc but this is at least a starting point.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages