[sonic-platform-common] Install Python 3 package in host OS and PMon container (#5461)
Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>
This commit is contained in:
parent
e3a0feaa47
commit
d71a4efe3b
@ -11,6 +11,7 @@ ENV DEBIAN_FRONTEND=noninteractive
|
|||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
python-pip \
|
python-pip \
|
||||||
|
python3-dev \
|
||||||
ipmitool \
|
ipmitool \
|
||||||
librrd8 \
|
librrd8 \
|
||||||
librrd-dev \
|
librrd-dev \
|
||||||
@ -21,6 +22,9 @@ RUN apt-get update && \
|
|||||||
i2c-tools && \
|
i2c-tools && \
|
||||||
pip install enum34
|
pip install enum34
|
||||||
|
|
||||||
|
# Install python3 required packages
|
||||||
|
RUN python3 -m pip install --no-cache-dir setuptools wheel
|
||||||
|
|
||||||
{% if docker_platform_monitor_debs.strip() -%}
|
{% if docker_platform_monitor_debs.strip() -%}
|
||||||
# Copy locally-built Debian package dependencies
|
# Copy locally-built Debian package dependencies
|
||||||
{{ copy_files("debs/", docker_platform_monitor_debs.split(' '), "/debs/") }}
|
{{ copy_files("debs/", docker_platform_monitor_debs.split(' '), "/debs/") }}
|
||||||
@ -47,6 +51,7 @@ RUN apt-get update && \
|
|||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
RUN apt-get purge -y \
|
RUN apt-get purge -y \
|
||||||
|
python3-dev \
|
||||||
python-pip && \
|
python-pip && \
|
||||||
apt-get clean -y && \
|
apt-get clean -y && \
|
||||||
apt-get autoclean -y && \
|
apt-get autoclean -y && \
|
||||||
|
@ -31,3 +31,20 @@ if [ $? -ne 0 ]; then
|
|||||||
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
|
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If the python3 sonic-platform package is not installed, try to install it
|
||||||
|
python3 -m pip show sonic-platform > /dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py3-none-any.whl"
|
||||||
|
echo "sonic-platform package not installed, attempting to install..."
|
||||||
|
if [ -e ${SONIC_PLATFORM_WHEEL} ]; then
|
||||||
|
python3 -m pip install ${SONIC_PLATFORM_WHEEL}
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Successfully installed ${SONIC_PLATFORM_WHEEL}"
|
||||||
|
else
|
||||||
|
echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
@ -5,7 +5,7 @@ RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return
|
|||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro install_python_wheels(packages) -%}
|
{% macro install_python2_wheels(packages) -%}
|
||||||
RUN cd /python-wheels/ && pip install {{ packages | join(' ') }}
|
RUN cd /python-wheels/ && pip install {{ packages | join(' ') }}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
@ -13,6 +13,23 @@ RUN cd /python-wheels/ && pip install {{ packages | join(' ') }}
|
|||||||
RUN cd /python-wheels/ && pip3 install {{ packages | join(' ') }}
|
RUN cd /python-wheels/ && pip3 install {{ packages | join(' ') }}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
{% macro install_python_wheels(packages) -%}
|
||||||
|
{%- set py2_pkgs, py3_pkgs = [], [] %}
|
||||||
|
{%- for pkg in packages %}
|
||||||
|
{%- if 'py3' in pkg %}
|
||||||
|
{{- py3_pkgs.append(pkg) or '' }}
|
||||||
|
{%- else %}
|
||||||
|
{{- py2_pkgs.append(pkg) or '' }}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- if py3_pkgs | length %}
|
||||||
|
{{ install_python3_wheels(py3_pkgs) }}
|
||||||
|
{%- endif %}
|
||||||
|
{%- if py2_pkgs | length %}
|
||||||
|
{{ install_python2_wheels(py2_pkgs) }}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro copy_files(prefix, files, dest) -%}
|
{% macro copy_files(prefix, files, dest) -%}
|
||||||
COPY \
|
COPY \
|
||||||
{%- for file in files %}
|
{%- for file in files %}
|
||||||
|
@ -172,6 +172,12 @@ sudo cp {{platform_common_py2_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2
|
|||||||
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $PLATFORM_COMMON_PY2_WHEEL_NAME
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $PLATFORM_COMMON_PY2_WHEEL_NAME
|
||||||
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2_WHEEL_NAME
|
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2_WHEEL_NAME
|
||||||
|
|
||||||
|
# Install sonic-platform-common Python 3 package
|
||||||
|
PLATFORM_COMMON_PY3_WHEEL_NAME=$(basename {{platform_common_py3_wheel_path}})
|
||||||
|
sudo cp {{platform_common_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||||
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||||
|
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||||
|
|
||||||
# Install Debian packages and their dependencies which are needed by sonic-utilities
|
# Install Debian packages and their dependencies which are needed by sonic-utilities
|
||||||
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f python-m2crypto
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f python-m2crypto
|
||||||
|
|
||||||
|
@ -11,8 +11,11 @@ ifeq ($(CONFIGURED_PLATFORM),barefoot)
|
|||||||
$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(PYTHON_THRIFT)
|
$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(PYTHON_THRIFT)
|
||||||
endif
|
endif
|
||||||
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2)
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2)
|
||||||
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3)
|
||||||
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY2)
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY2)
|
||||||
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY3)
|
||||||
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
|
||||||
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY3)
|
||||||
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY2)
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY2)
|
||||||
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_LEDD)
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_LEDD)
|
||||||
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PCIED)
|
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PCIED)
|
||||||
|
2
slave.mk
2
slave.mk
@ -813,6 +813,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
|||||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PY_COMMON_PY3)) \
|
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PY_COMMON_PY3)) \
|
||||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CONFIG_ENGINE)) \
|
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CONFIG_ENGINE)) \
|
||||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2)) \
|
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2)) \
|
||||||
|
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY3)) \
|
||||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2)) \
|
$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2)) \
|
||||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_API_PY2)) \
|
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_API_PY2)) \
|
||||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_YANG_MODELS_PY3)) \
|
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_YANG_MODELS_PY3)) \
|
||||||
@ -851,6 +852,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
|||||||
export swsssdk_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SWSSSDK_PY2))"
|
export swsssdk_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SWSSSDK_PY2))"
|
||||||
export swsssdk_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SWSSSDK_PY3))"
|
export swsssdk_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SWSSSDK_PY3))"
|
||||||
export platform_common_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2))"
|
export platform_common_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2))"
|
||||||
|
export platform_common_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY3))"
|
||||||
export redis_dump_load_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2))"
|
export redis_dump_load_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2))"
|
||||||
export redis_dump_load_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY3))"
|
export redis_dump_load_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY3))"
|
||||||
export install_debug_image="$(INSTALL_DEBUG_TOOLS)"
|
export install_debug_image="$(INSTALL_DEBUG_TOOLS)"
|
||||||
|
Loading…
Reference in New Issue
Block a user