From c55bb03cfca04e4c4153cf1c40f6844dec4633d1 Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Mon, 28 Sep 2020 19:20:15 -0700 Subject: [PATCH] [build] Add Support For Python 3 Build CONiC config gen requires jinja2<3.0.0 for stretch and byangbind versions 0.60.0/0.80.1 for Python 2/3 respectively. byangbind is installed in the build docker because when it installed it pulls enum34 as dependent package which is not required for Python 3 and it breaks the build. signed-off-by: Tamer Ahmed --- sonic-slave-buster/Dockerfile.j2 | 10 +++++++--- sonic-slave-stretch/Dockerfile.j2 | 13 ++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 88f905cb0..11d792782 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -242,7 +242,9 @@ RUN apt-get update && apt-get install -y \ sphinx-common \ python3-sphinx \ # For sonic config engine testing + python-dev \ python-lxml \ + python3-lxml \ python-jinja2 \ python-netaddr \ python-ipaddr \ @@ -362,9 +364,11 @@ RUN pip install \ crc16 # For sonic config engine testing -RUN pip install pyangbind==0.6.0 -# Note: force upgrade debian packaged jinja2, if installed -RUN pip install --force-reinstall --upgrade "jinja2>=2.10" +# Install pyangbind here, outside sonic-config-engine dependencies, as pyangbind causes enum34 to be installed. +# enum34 causes Python 're' package to not work properly as it redefines an incompatible enum.py module +# https://github.com/robshakir/pyangbind/issues/232 +RUN pip3 install pyangbind==0.8.1 +RUN pip3 uninstall -y enum34 # For templating RUN pip install j2cli==0.3.10 diff --git a/sonic-slave-stretch/Dockerfile.j2 b/sonic-slave-stretch/Dockerfile.j2 index d372450f0..fb685a2ad 100644 --- a/sonic-slave-stretch/Dockerfile.j2 +++ b/sonic-slave-stretch/Dockerfile.j2 @@ -241,7 +241,9 @@ RUN apt-get update && apt-get install -y \ sphinx-common \ python3-sphinx \ # For sonic config engine testing + python-dev \ python-lxml \ + python3-lxml \ python-jinja2 \ python-netaddr \ python-ipaddr \ @@ -341,10 +343,15 @@ RUN pip install \ ctypesgen==0.r125 \ crc16 +# Note: Stick with Jinja2 2.x branch as the 3.x dropped support for Python 2.7 +RUN pip install --force-reinstall --upgrade "Jinja2<3.0.0" + # For sonic config engine testing -RUN pip install pyangbind==0.6.0 -# Note: force upgrade debian packaged jinja2, if installed -RUN pip install --force-reinstall --upgrade "jinja2>=2.10" +# Install pyangbind here, outside sonic-config-engine dependencies, as pyangbind causes enum34 to be installed. +# enum34 causes Python 're' package to not work properly as it redefines an incompatible enum.py module +# https://github.com/robshakir/pyangbind/issues/232 +RUN pip3 install pyangbind==0.8.1 +RUN pip3 uninstall -y enum34 # For templating RUN pip install j2cli==0.3.10