Skip to content

Commit 88c1d66

Browse files
authored
[python-click] No longer build our own package, let pip/setuptools install vanilla (#5549)
We were building our own python-click package because we needed features/bug fixes available as of version 7.0.0, but the most recent version available from Debian was in the 6.x range. "Click" is needed for building/testing and installing sonic-utilities. Now that we are building sonic-utilities as a wheel, with Click specified as a dependency in the setup.py file, setuptools will install a more recent version of Click in the sonic-slave-buster container when building the package, and pip will install a more recent version of Click in the host OS of SONiC when installing the sonic-utilities package. Also, we don't need to worry about installing the Python 2 or 3 version of the package, as the proper one will be installed as necessary.
1 parent 0155a15 commit 88c1d66

File tree

14 files changed

+40
-121
lines changed

14 files changed

+40
-121
lines changed

dockers/docker-config-engine-buster/Dockerfile.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ RUN apt-get update && \
1212
python-bitarray \
1313
python-pip \
1414
python-dev \
15-
python-natsort \
1615
apt-utils \
1716
python-setuptools
1817

dockers/docker-config-engine-stretch/Dockerfile.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ RUN apt-get update && \
1212
python-bitarray \
1313
python-pip \
1414
python-dev \
15-
python-natsort \
1615
python-setuptools
1716

1817
RUN pip install --upgrade pip

dockers/docker-config-engine/Dockerfile.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND=noninteractive
66
RUN apt-get update
77

88
# Dependencies for sonic-cfggen
9-
RUN apt-get install -y python-lxml python-yaml python-bitarray python-pip python-dev python-natsort
9+
RUN apt-get install -y python-lxml python-yaml python-bitarray python-pip python-dev
1010

1111
RUN pip install --upgrade pip
1212

files/build_templates/sonic_debian_extension.j2

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/iptables_*.deb || \
9393
# Install dependencies for SONiC config engine
9494
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install \
9595
python-dev \
96+
python3-dev \
9697
python-lxml \
9798
python-yaml \
9899
python-bitarray
@@ -184,14 +185,12 @@ sudo cp {{platform_common_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3
184185
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $PLATFORM_COMMON_PY3_WHEEL_NAME
185186
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME
186187

187-
# Install Debian packages and their dependencies which are needed by sonic-utilities
188-
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f python-m2crypto
188+
# Install prerequisites needed for installing the Python m2crypto package, used by sonic-utilities
189+
# These packages can be uninstalled after intallation
190+
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install build-essential libssl-dev swig
189191

190-
# Install built Python Click package (and its dependencies via 'apt-get -y install -f')
191-
# Do this before installing sonic-utilities so that it doesn't attempt to install
192-
# an older version as part of its dependencies
193-
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/python-click*_all.deb || \
194-
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
192+
# Install prerequisites needed for using the Python m2crypto package, used by sonic-utilities
193+
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install openssl
195194

196195
# Install SONiC Utilities Python 2 package
197196
SONIC_UTILITIES_PY2_WHEEL_NAME=$(basename {{sonic_utilities_py2_wheel_path}})
@@ -574,7 +573,8 @@ sudo cp $BUILD_TEMPLATES/mgmt-framework.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_S
574573
echo "mgmt-framework.timer" | sudo tee -a $GENERATED_SERVICE_FILE
575574
{% endif %}
576575

577-
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev
576+
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev python3-dev
577+
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y build-essential libssl-dev swig
578578
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y
579579
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get autoremove -y
580580

platform/p4/docker-sonic-p4/Dockerfile.j2

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ RUN apt-get install -y net-tools \
4040
iproute \
4141
libpython2.7 \
4242
grub2-common \
43-
python-click \
44-
python-natsort \
45-
python-tabulate \
4643
bash-completion \
4744
libelf1 \
48-
libmnl0
45+
libmnl0 \
46+
# For installing Python m2crypto package
47+
# (these can be uninstalled after installation)
48+
build-essential \
49+
python-dev \
50+
python3-dev \
51+
libssl-dev \
52+
swig \
53+
# For using Python m2crypto package
54+
openssl
4955

5056
RUN pip install setuptools
5157
RUN pip install py2_ipaddress
@@ -62,6 +68,8 @@ debs/{{ deb }}{{' '}}
6268
{%- endfor %}
6369

6470
## Clean up
71+
RUN apt-get purge -y build-essential libssl-dev swig
72+
RUN apt-get purge -y python-dev python3-dev
6573
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
6674
RUN rm -rf /debs
6775

platform/vs/docker-sonic-vs/Dockerfile.j2

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ RUN apt-get install -y net-tools \
3232
libc-ares2 \
3333
iproute2 \
3434
grub2-common \
35-
python-click \
36-
python-natsort \
37-
python-tabulate \
3835
bash-completion \
3936
libelf1 \
4037
libmnl0 \
@@ -47,8 +44,16 @@ RUN apt-get install -y net-tools \
4744
iptables \
4845
python3-pip \
4946
jq \
50-
python-m2crypto \
51-
libzmq5
47+
libzmq5 \
48+
# For installing Python m2crypto package
49+
# (these can be uninstalled after installation)
50+
build-essential \
51+
python-dev \
52+
python3-dev \
53+
libssl-dev \
54+
swig \
55+
# For using Python m2crypto package
56+
openssl
5257

5358
# install redis-server
5459
RUN curl -o redis-tools_6.0.6-1~bpo10+1_amd64.deb "https://sonicstorage.blob.core.windows.net/packages/redis/redis-tools_6.0.6-1~bpo10+1_amd64.deb?sv=2015-04-05&sr=b&sig=73zbmjkf3pi%2Bn0R8Hy7CWT2EUvOAyzM5aLYJWCLySGM%3D&se=2030-09-06T19%3A44%3A59Z&sp=r"
@@ -111,6 +116,8 @@ RUN pip{% if 'py3' in whl %}3{% endif %} install python-wheels/{{ whl }}
111116
{% endif %}
112117

113118
# Clean up
119+
RUN apt-get purge -y build-essential libssl-dev swig
120+
RUN apt-get purge -y python-dev python3-dev
114121
RUN apt-get clean -y
115122
RUN apt-get autoclean -y
116123
RUN apt-get autoremove -y

rules/python-click.dep

Lines changed: 0 additions & 10 deletions
This file was deleted.

rules/python-click.mk

Lines changed: 0 additions & 16 deletions
This file was deleted.

sonic-slave-buster/Dockerfile.j2

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,6 @@ RUN apt-get update && apt-get install -y \
270270
texlive-latex-extra \
271271
texlive-latex-recommended \
272272
iproute2 \
273-
# For python-click build
274-
python-sphinx \
275-
python3-pallets-sphinx-themes \
276-
python-docutils \
277-
python3-all \
278-
python3-setuptools \
279-
python3-sphinx \
280-
python3-docutils \
281-
python3-requests \
282-
python3-pytest \
283-
python3-colorama \
284273
# For bash
285274
texi2html \
286275
# For initramfs
@@ -349,6 +338,10 @@ RUN export VERSION=1.14.2 \
349338
RUN pip install setuptools==40.8.0
350339
RUN pip3 install setuptools==49.6.00
351340

341+
# For building sonic-utilities
342+
RUN pip install fastentrypoints
343+
RUN pip3 install fastentrypoints
344+
352345
# For running Python unit tests
353346
RUN pip install pytest-runner==4.4
354347
RUN pip3 install pytest-runner==5.2
@@ -375,11 +368,6 @@ RUN pip3 uninstall -y enum34
375368
# For templating
376369
RUN pip install j2cli==0.3.10
377370

378-
# Remove python-click 6.6
379-
RUN apt-get purge -y python-click
380-
# For sonic utilities testing
381-
RUN pip install click natsort tabulate netifaces==0.10.7 fastentrypoints
382-
383371
RUN pip3 install "PyYAML>=5.1"
384372

385373
# For sonic-platform-common testing

sonic-slave-jessie/Dockerfile.j2

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,6 @@ RUN apt-get update && apt-get install -y \
246246
lynx \
247247
texlive-latex-extra \
248248
texlive-latex-recommended \
249-
# For python-click build
250-
python-sphinx \
251-
python-docutils \
252-
python3-all \
253-
python3-setuptools \
254-
python3-sphinx \
255-
python3-docutils \
256-
python3-requests \
257-
python3-pytest \
258-
python3-colorama \
259249
# For bash
260250
texi2html \
261251
# For initramfs
@@ -310,9 +300,6 @@ RUN pip install --force-reinstall --upgrade "jinja2>=2.10"
310300
# For templating (requiring jinja2)
311301
RUN pip install j2cli==0.3.10
312302

313-
# For sonic utilities testing
314-
RUN pip install click natsort tabulate netifaces==0.10.7 fastentrypoints
315-
316303
# For supervisor build
317304
RUN pip install meld3 mock
318305

0 commit comments

Comments
 (0)