Skip to content

Commit

Permalink
Exclude proto copy and initialization to separate script
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmittag committed Sep 12, 2024
1 parent 48edfae commit 3f44b36
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/kuksa-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,15 @@ jobs:
- name: Install pip
run: |
python -m pip --quiet --no-input install --upgrade pip
- name: Initiate submodules
run: |
git submodule update --recursive --remote
- name: Install dependencies with pip
run: |
cd kuksa-client
ls -R
python3 -m proto
pip install -r requirements.txt -e .
pip install -r test-requirements.txt -e .
pip install -r test-requirements.txt
- name: Run tests
run: |
cd kuksa-client
Expand Down
6 changes: 6 additions & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ python3 -m venv ~/.venv/kuksa-client
source ~/.venv/kuksa-client/bin/activate # Run this every time you want to activate kuksa-client's virtual environment
```

To use the right api interfaces of databroker run the following:
```console
python3 -m proto
```
This should copy the corresponding proto files to the kuksa-client directory.

Your prompt should change to somehting indicating you are in the virutal environment now, e.g.

```console
Expand Down
2 changes: 1 addition & 1 deletion kuksa-client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY . /kuksa-python-sdk/
WORKDIR /kuksa-python-sdk/kuksa-client
RUN git submodule update --recursive --remote --init
# install files from submodules to kuksa-client repo to generate protos out of it
RUN pip install -r requirements.txt -e .
RUN python3 -m proto

RUN python3 -m build
# We install globally on build container, so pyinstaller can easily gather all files
Expand Down
32 changes: 32 additions & 0 deletions kuksa-client/proto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# /********************************************************************************
# * Copyright (c) 2024 Contributors to the Eclipse Foundation
# *
# * See the NOTICE file(s) distributed with this work for additional
# * information regarding copyright ownership.
# *
# * This program and the accompanying materials are made available under the
# * terms of the Apache License 2.0 which is available at
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/

import shutil
import os

# this needs to be adapted once the submodules name or structure changes
PROTO_PATH = os.path.abspath("../submodules/kuksa-databroker/proto")


def main():
for root, dirs, files in os.walk(PROTO_PATH):
for directory in dirs:
# Create an __init__.py file in each subdirectory
init_file = os.path.join(root, directory, "__init__.py")
with open(init_file, "w") as file:
file.write("# This file marks the directory as a Python module")
shutil.copytree(PROTO_PATH, os.getcwd(), dirs_exist_ok=True)


if __name__ == "__main__":
main()
13 changes: 1 addition & 12 deletions kuksa-client/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# * SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/
import setuptools
import os
import shutil

try:
from setuptools.command import build
Expand All @@ -22,9 +20,6 @@
from setuptools.command import sdist
from setuptools.command.develop import develop as _develop

# this needs to be adapted once the submodules name or structure changes
PROTO_PATH = os.path.abspath("../submodules/kuksa-databroker/proto")


class BuildPackageProtos(setuptools.Command):
def run(self):
Expand Down Expand Up @@ -60,14 +55,8 @@ class SDistCommand(BuildPackageProtos, sdist.sdist):


class DevelopCommand(BuildPackageProtos, _develop):

def run(self):
for root, dirs, files in os.walk(PROTO_PATH):
for directory in dirs:
# Create an __init__.py file in each subdirectory
init_file = os.path.join(root, directory, "__init__.py")
with open(init_file, "w") as file:
file.write("# This file marks the directory as a Python module")
shutil.copytree(PROTO_PATH, os.getcwd(), dirs_exist_ok=True)
self.run_command("build_pb2")
super().run()

Expand Down

0 comments on commit 3f44b36

Please sign in to comment.