This is an automated email from the ASF dual-hosted git repository.

dianfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-playgrounds.git


The following commit(s) were added to refs/heads/master by this push:
     new 22f1ba8  Build PyFlink image with compatible Python version (#28)
22f1ba8 is described below

commit 22f1ba831cde6cafd43108ea46c66306b8a67902
Author: Fred Thomsen <[email protected]>
AuthorDate: Sun May 8 23:04:57 2022 -0400

    Build PyFlink image with compatible Python version (#28)
    
    The underlying base image is now debian bullseye which ships with
    Python 3.9 and this version of Python is not compatible with PyFlink.
    Thus build and add Python 3.7 to image.
---
 pyflink-walkthrough/Dockerfile | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/pyflink-walkthrough/Dockerfile b/pyflink-walkthrough/Dockerfile
index ae9ef03..352adaf 100644
--- a/pyflink-walkthrough/Dockerfile
+++ b/pyflink-walkthrough/Dockerfile
@@ -23,20 +23,28 @@
 FROM apache/flink:1.13.1-scala_2.12-java8
 ARG FLINK_VERSION=1.13.1
 
-# Install pyflink
+# Install python3.7 and pyflink
+# Pyflink does not yet function with python3.9, and this image is build on
+# debian bullseye which ships with that version, so build python3.7 here.
 RUN set -ex; \
-  apt-get update; \
-  apt-get -y install python3; \
-  apt-get -y install python3-pip; \
-  apt-get -y install python3-dev; \
-  ln -s /usr/bin/python3 /usr/bin/python; \
-  ln -s /usr/bin/pip3 /usr/bin/pip; \
-  apt-get update; \
+  apt-get update && \
+  apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev 
libffi-dev && \
+  wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz && \
+  tar -xvf Python-3.7.9.tgz && \
+  cd Python-3.7.9 && \
+  ./configure --without-tests --enable-shared && \
+  make -j4 && \
+  make install && \
+  ldconfig /usr/local/lib && \
+  cd .. && rm -f Python-3.7.9.tgz && rm -rf Python-3.7.9 && \
+  ln -s /usr/local/bin/python3 /usr/local/bin/python && \
+  ln -s /usr/local/bin/pip3 /usr/local/bin/pip && \
+  apt-get clean && \
+  rm -rf /var/lib/apt/lists/* && \
   python -m pip install --upgrade pip; \
   pip install apache-flink==1.13.1; \
   pip install kafka-python;
 
-
 # Download connector libraries
 RUN wget -P /opt/flink/lib/ 
https://repo.maven.apache.org/maven2/org/apache/flink/flink-json/${FLINK_VERSION}/flink-json-${FLINK_VERSION}.jar;
 \
     wget -P /opt/flink/lib/ 
https://repo.maven.apache.org/maven2/org/apache/flink/flink-sql-connector-kafka_2.12/${FLINK_VERSION}/flink-sql-connector-kafka_2.12-${FLINK_VERSION}.jar;
 \

Reply via email to