Skip to content

Change pycommon to use swsscommon #10099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rules/sonic-py-common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ifeq ($(ENABLE_PY2_MODULES), y)
SONIC_PY_COMMON_PY2 = sonic_py_common-1.0-py2-none-any.whl
$(SONIC_PY_COMMON_PY2)_SRC_PATH = $(SRC_PATH)/sonic-py-common
$(SONIC_PY_COMMON_PY2)_DEPENDS += $(SWSSSDK_PY2)
$(SONIC_PY_COMMON_PY2)_DEBS_DEPENDS = $(LIBSWSSCOMMON) \
Copy link
Collaborator

@qiluo-msft qiluo-msft May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LIBSWSSCOMMON

Does it depend on LIBSWSSCOMMON directly? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, remove indirect dependency to LIBSWSSCOMMON.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you fixed py3, but py2 still has the same issue.

$(PYTHON_SWSSCOMMON)
$(SONIC_PY_COMMON_PY2)_PYTHON_VERSION = 2
SONIC_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
endif
Expand All @@ -13,6 +15,7 @@ endif
SONIC_PY_COMMON_PY3 = sonic_py_common-1.0-py3-none-any.whl
$(SONIC_PY_COMMON_PY3)_SRC_PATH = $(SRC_PATH)/sonic-py-common
$(SONIC_PY_COMMON_PY3)_DEPENDS += $(SWSSSDK_PY3)
$(SONIC_PY_COMMON_PY3)_DEBS_DEPENDS = $(PYTHON3_SWSSCOMMON)
ifeq ($(ENABLE_PY2_MODULES), y)
# Synthetic dependency to avoid building the Python 2 and 3 packages
# simultaneously and any potential conflicts which may arise
Expand Down
8 changes: 0 additions & 8 deletions src/sonic-py-common/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
dependencies = [
'natsort==6.2.1', # 6.2.1 is the last version which supports Python 2
'pyyaml',
'swsssdk>=2.0.1',
]

high_performance_deps = [
'swsssdk[high_perf]>=2.0.1',
]

setup(
Expand All @@ -21,9 +16,6 @@
maintainer='Joe LeVeque',
maintainer_email='[email protected]',
install_requires=dependencies,
extras_require={
'high_perf': high_performance_deps,
},
packages=[
'sonic_py_common',
],
Expand Down
4 changes: 1 addition & 3 deletions src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import yaml
from natsort import natsorted

# TODO: Replace with swsscommon
from swsssdk import ConfigDBConnector, SonicDBConfig, SonicV2Connector
from swsscommon.swsscommon import ConfigDBConnector, SonicV2Connector

USR_SHARE_SONIC_PATH = "/usr/share/sonic"
HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device"
Expand Down Expand Up @@ -485,7 +484,6 @@ def get_all_namespaces(config_db=None):
front_ns = []
back_ns = []
num_npus = get_num_npus()
SonicDBConfig.load_sonic_global_db_config()

if is_multi_npu():
for npu in range(num_npus):
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-py-common/tests/device_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from sonic_py_common import device_info

from .mock_swsssdk import SonicV2Connector
from .mock_swsscommon import SonicV2Connector

# TODO: Remove this if/else block once we no longer support Python 2
if sys.version_info.major == 3:
Expand Down