agri-gaia/seerep

pypi package and imports in auto-generated gRPC python files do not match

Closed this issue · 0 comments

The python files for the flatbuffers and protobuf gRPC interface are auto-generated. In this generated files the imports do not obey the same scheme as the python package published to pypi. Thus, the imports do not work after installation.

Current lines for the pypi package creation:

#python package
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel twine build dunamai
- name: prepare python package
run: |
mkdir -p $GITHUB_WORKSPACE/src/python-package/seerep-msgs-pb
touch $GITHUB_WORKSPACE/src/python-package/seerep-msgs-pb/__init__.py
cp $GITHUB_WORKSPACE/devel/include/seerep-msgs/*_pb2.py $GITHUB_WORKSPACE/src/python-package/seerep-msgs-pb/
mkdir -p $GITHUB_WORKSPACE/src/python-package/seerep-msgs-fb
touch $GITHUB_WORKSPACE/src/python-package/seerep-msgs-fb/__init__.py
cp $GITHUB_WORKSPACE/devel/include/seerep-msgs/fbs/seerep/fb/*.py $GITHUB_WORKSPACE/src/python-package/seerep-msgs-fb/
mkdir -p $GITHUB_WORKSPACE/src/python-package/seerep-com-pb
touch $GITHUB_WORKSPACE/src/python-package/seerep-com-pb/__init__.py
cp $GITHUB_WORKSPACE/devel/include/seerep-com/*.py $GITHUB_WORKSPACE/src/python-package/seerep-com-pb/
mkdir -p $GITHUB_WORKSPACE/src/python-package/seerep-com-fb
touch $GITHUB_WORKSPACE/src/python-package/seerep-com-fb/__init__.py
cp $GITHUB_WORKSPACE/devel/include/seerep-com/fbs/seerep/fb/*_grpc_fb.py $GITHUB_WORKSPACE/src/python-package/seerep-com-fb/
cp $GITHUB_WORKSPACE/src/setup.py $GITHUB_WORKSPACE/src/python-package/
cp $GITHUB_WORKSPACE/src/pyproject.toml $GITHUB_WORKSPACE/src/python-package/
cp $GITHUB_WORKSPACE/src/LICENSE $GITHUB_WORKSPACE/src/python-package/
cp $GITHUB_WORKSPACE/src/README.md $GITHUB_WORKSPACE/src/python-package/
- name: run setup.py
run: |
cd $GITHUB_WORKSPACE/src/python-package
python3 -m build --sdist
- name: publish
if: github.ref_type == 'tag'
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload $GITHUB_WORKSPACE/src/python-package/dist/*

  1. protobuf
    Example of import in generated protobuf python file of image :
    import header_pb2 as header__pb2
    but for the current pypi package it needs to be
    import seerep_grpc_pb.header_pb2 as header__pb2

  2. flatbuffers
    Example of import in generated flatbuffers python file of image :
    from seerep.fb.Header import Header
    but for the current pypi package it needs to be
    from seerep_grpc_fb.Header import Header

Either the auto-generation or the pypi creation has to be adjusted.

latest branch for this: https://github.com/agri-gaia/seerep/tree/pypi_buildWheel