sonic-net / sonic-platform-daemons

Platform module daemons for SONiC
Other
25 stars 159 forks source link

[ycabled][build] Fix sonic_ycabled build failure in Bookworm #432

Closed ArunSaravananBalachandran closed 8 months ago

ArunSaravananBalachandran commented 9 months ago

Description

Use 'build_py' command to include the gRPC libraries in the package while building with 'python3 -m build'

Motivation and Context

In Bookworm, python3 -m build -n is used to build python wheel packages inplace of python3 setup.py bdist_wheel. (Ref: https://github.com/sonic-net/sonic-buildimage/commit/9dfa546e07e13861338205ee79944b17df2c6cce)

When 'python3 -m build -n' is executed, by default 'sdist' command is executed and it copies .py and other default files to separate dir and generates a sdist of it, from which a wheel is created. Since 'sdist' does not copy .proto files, the gRPC libraries are not generated while building the wheel from the sdist.

To resolve the above issue, the gRPC libraries are generated in 'build_py' initialization to ensure that they are available for 'sdist' and other commands during the build.

How Has This Been Tested?

Build sonic_y_cabled in Python3.11 with python3 -m build -n command and verify that the gRPC libraries are available in the generated wheel package.

build log before fix: sonic_ycabled_build_logs_before_fix.txt

build log with fix: sonic_ycabled_build_logs_with_fix.txt

Additional Information (Optional)

prgeor commented 9 months ago

@vdahiya12 can you review?

vivekrnv commented 9 months ago

Hi,

Tests are failing. Can you check?

=========================== short test summary info ============================
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_none - AttributeError: 'dict' object attribute 'get' is read-only
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_microsoft - AttributeError: 'dict' object attribute 'get' is read-only
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_microsoft_y_cable_presence_false - AttributeError: 'dict' object attribute 'get' is read-only
================== 3 failed, 267 passed, 67 warnings in 8.58s ==================
[  FAIL LOG END  ] [ target/python-wheels/bookworm/sonic_ycabled-1.0-py3-none-any.whl ]
ArunSaravananBalachandran commented 9 months ago

Hi,

Tests are failing. Can you check?

=========================== short test summary info ============================
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_none - AttributeError: 'dict' object attribute 'get' is read-only
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_microsoft - AttributeError: 'dict' object attribute 'get' is read-only
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_microsoft_y_cable_presence_false - AttributeError: 'dict' object attribute 'get' is read-only
================== 3 failed, 267 passed, 67 warnings in 8.58s ==================
[  FAIL LOG END  ] [ target/python-wheels/bookworm/sonic_ycabled-1.0-py3-none-any.whl ]

https://github.com/sonic-net/sonic-platform-daemons/pull/431 was raised to fix the unittest issue. Could you please let me know if the above fix is in place while running the tests ?

vivekrnv commented 8 months ago

Hi, Tests are failing. Can you check?

=========================== short test summary info ============================
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_none - AttributeError: 'dict' object attribute 'get' is read-only
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_microsoft - AttributeError: 'dict' object attribute 'get' is read-only
FAILED tests/test_y_cable_helper.py::TestYCableScript::test_check_identifier_presence_and_update_mux_table_entry_module_microsoft_y_cable_presence_false - AttributeError: 'dict' object attribute 'get' is read-only
================== 3 failed, 267 passed, 67 warnings in 8.58s ==================
[  FAIL LOG END  ] [ target/python-wheels/bookworm/sonic_ycabled-1.0-py3-none-any.whl ]

431 was raised to fix the unittest issue. Could you please let me know if the above fix is in place while running the tests ?

Oh, i see. overlooked. Will check

prgeor commented 8 months ago

@ArunSaravananBalachandran can you rebase?

ArunSaravananBalachandran commented 8 months ago

@ArunSaravananBalachandran can you rebase?

The branch has been rebased.