From a46a7483c168d89f48f643e0e364a28b6f154c01 Mon Sep 17 00:00:00 2001 From: Vivek Date: Fri, 8 Mar 2024 08:55:58 -0800 Subject: [PATCH] [docker-ptf]: Upgrade ptf-py3 to 0.10.0 (#18263) ptf-py3 0.9.3 couldn't compile on bookworm Update ptf-py3 to latest release. How to verify it Verify the build and installation is successful in bookworm, buster and bullseye environment Test docker-ptf.gz is built properly. Ran sonic-mgmt tests with this docker-ptf.gz Signed-off-by: Vivek Reddy Karri --- rules/ptf-py3.dep | 2 +- rules/ptf-py3.mk | 2 +- sonic-slave-bookworm/Dockerfile.j2 | 5 +++- src/ptf-py3 | 2 +- ...cal-version-scheme-by-setuptools-scm.patch | 23 +++++++++++++++++++ src/ptf-py3.patch/series | 3 ++- 6 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/ptf-py3.patch/0003-Avoid-local-version-scheme-by-setuptools-scm.patch diff --git a/rules/ptf-py3.dep b/rules/ptf-py3.dep index eadb32aabd..7dbd9b3d55 100644 --- a/rules/ptf-py3.dep +++ b/rules/ptf-py3.dep @@ -2,7 +2,7 @@ SPATH := $($(PTF_PY3)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/ptf-py3.mk rules/ptf-py3.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) -SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && find . -type f -exec sh -c 'git ls-files --error-unmatch "$0" >/dev/null 2>&1' {} \; -printf '%P\n')) $(PTF_PY3)_CACHE_MODE := GIT_CONTENT_SHA $(PTF_PY3)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) diff --git a/rules/ptf-py3.mk b/rules/ptf-py3.mk index bf583b57b6..1c85c45f3c 100644 --- a/rules/ptf-py3.mk +++ b/rules/ptf-py3.mk @@ -1,6 +1,6 @@ # ptf package -PTF_PY3 = ptf-0.9.3-py3-none-any.whl +PTF_PY3 = ptf-0.10.0.post0-py3-none-any.whl $(PTF_PY3)_SRC_PATH = $(SRC_PATH)/ptf-py3 $(PTF_PY3)_PYTHON_VERSION = 3 $(PTF_PY3)_TEST = n diff --git a/sonic-slave-bookworm/Dockerfile.j2 b/sonic-slave-bookworm/Dockerfile.j2 index 6bf09c425c..4af1b401cc 100644 --- a/sonic-slave-bookworm/Dockerfile.j2 +++ b/sonic-slave-bookworm/Dockerfile.j2 @@ -68,7 +68,7 @@ RUN pip3 install virtualenv RUN mkdir /python_virtualenv RUN cd /python_virtualenv && python3 -m virtualenv --copies -p /usr/bin/python3 env3 -RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install setuptools==66.1.1 wheel==0.38.4 fastentrypoints pytest pytest-cov pytest-runner==5.2 nose==1.3.7 mockredispy==2.9.3 mock==3.0.5 PyYAML==6.0.1 redis==3.5.3 pexpect==4.8.0 Pympler==0.8 parameterized natsort==6.2.1 MarkupSafe==2.0.1 Jinja2==3.0.3 click tabulate netaddr netifaces pyroute2 pyfakefs sphinx && ln -s /python_virtualenv/env3/bin/pytest /python_virtualenv/env3/bin/pytest-3 +RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install setuptools==66.1.1 setuptools-scm==8.0.4 setuptools-scm-git-archive==1.4.1 wheel==0.38.4 fastentrypoints pytest pytest-cov pytest-runner==5.2 nose==1.3.7 mockredispy==2.9.3 mock==3.0.5 PyYAML==6.0.1 redis==3.5.3 pexpect==4.8.0 Pympler==0.8 parameterized natsort==6.2.1 MarkupSafe==2.0.1 Jinja2==3.0.3 click tabulate netaddr netifaces pyroute2 pyfakefs sphinx && ln -s /python_virtualenv/env3/bin/pytest /python_virtualenv/env3/bin/pytest-3 RUN apt-get --fix-broken install -y RUN LIBPYTHON3_DEPS="`apt-cache depends libpython3-dev:$arch |grep Depends|awk {'print \$2;'}|tr "\n" " "`" && apt-get install -y libpython2.7-dev:$arch $LIBPYTHON3_DEPS libxml2-dev:$arch libxslt-dev:$arch libssl-dev:$arch libz-dev:$arch @@ -510,6 +510,9 @@ RUN pip3 install pyang==2.4.0 # For mgmt-framework build RUN pip3 install mmh3==2.5.1 +# For ptf-py3 0.10.0 +RUN pip3 install setuptools==66.1.1 setuptools-scm==8.0.4 setuptools-scm-git-archive==1.4.1 + RUN apt-get install -y xsltproc # Install dependencies for isc-dhcp-relay build diff --git a/src/ptf-py3 b/src/ptf-py3 index 405513bcad..978598dd04 160000 --- a/src/ptf-py3 +++ b/src/ptf-py3 @@ -1 +1 @@ -Subproject commit 405513bcad2eae3092b0ac4ceb31e8dec5e32311 +Subproject commit 978598dd04434b5270495ac0c6466eb2c6c752f5 diff --git a/src/ptf-py3.patch/0003-Avoid-local-version-scheme-by-setuptools-scm.patch b/src/ptf-py3.patch/0003-Avoid-local-version-scheme-by-setuptools-scm.patch new file mode 100644 index 0000000000..776172da56 --- /dev/null +++ b/src/ptf-py3.patch/0003-Avoid-local-version-scheme-by-setuptools-scm.patch @@ -0,0 +1,23 @@ +From 5e46050967f5c29c6572b318d9aebb184f8275cf Mon Sep 17 00:00:00 2001 +From: Vivek Reddy +Date: Wed, 21 Feb 2024 19:04:40 +0000 +Subject: [PATCH] Avoid local version scheme by setuptools-scm + +Signed-off-by: Vivek Reddy +--- + pyproject.toml | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/pyproject.toml b/pyproject.toml +index 74a5350..33af092 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -11,4 +11,5 @@ build-backend = 'setuptools.build_meta' + root = "./" + # use current tag and not next one + version_scheme = "post-release" ++local_scheme = "no-local-version" + write_to = "src/ptf/_version.py" +-- +2.17.1 + diff --git a/src/ptf-py3.patch/series b/src/ptf-py3.patch/series index d18987dd59..9bbcdfcbfd 100644 --- a/src/ptf-py3.patch/series +++ b/src/ptf-py3.patch/series @@ -1,2 +1,3 @@ 0001-Remove-ord-in-get_mac-to-avoid-TypeError.patch -0002-Fill-byte-formatted-client-mac-address-in-DHCP-Disco.patch \ No newline at end of file +0002-Fill-byte-formatted-client-mac-address-in-DHCP-Disco.patch +0003-Avoid-local-version-scheme-by-setuptools-scm.patch