Closed rvolosatovs closed 6 years ago
I find it difficult to review this, as my python knowledge is pretty limited. If it works OK for @emmlejeail I think we can merge it, otherwise we should find someone in the community to try using it.
There's not much python happening, it's mostly just copying all protos from ${GOPATH}/src/github.com
to a <temp dir>/github_com
and generating the TTN protos and dependencies into <repo>/python
.
__init__.py
files are required for (sub-)packages to be imported. Those also define the values exported - I made them export all the generated code, so once you import i.e. github_com.TheThingsNetwork.api.broker
, all broker-related generated code is imported automatically.
You can try all of this out using the example line I mentioned in the description.
I believe the SDK __init.py__
can just import the github_com/TheThingsNetwork/api<...>
, export the required values from (sub-)packages in this repo and effectively hide the github_com
import paths and unnecessary stuff.
@emmlejeail please test if this works for you Note that the protobuf and grpc packages should also be installed(i.e.
pip install --user protobuf grpcio-tools
)packages should be imported relative to
./python
directory. Example:should output something similar to:
I believe the SDK users don't see the "ugly" imports to
github_com
..., right? otherwise we should come up with a better solution.Python (plugins) do not support dots in import paths, see also https://github.com/grpc/grpc/issues/10790 Currently everything in
get-python.sh
is hardcoded, we can make it work with the variables inMakefile
later, if this turns out to be an issue. Generated dependencies are included inpython
directory, maybe there is a better solution?