@@ -12,7 +12,7 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf && \
1212ENV DEBIAN_FRONTEND="noninteractive" \
1313 TZ="Europe/London"
1414
15- RUN apt-get update && \
15+ RUN dpkg --add-architecture armhf && apt-get update && \
1616 apt-get install \
1717 software-properties-common \
1818 curl \
@@ -21,7 +21,7 @@ RUN apt-get update && \
2121 tzdata \
2222 # parallel gzip
2323 pigz \
24- # Pythons \
24+ # Python
2525 python3 \
2626 python3-pip \
2727 python3-dev \
@@ -30,10 +30,10 @@ RUN apt-get update && \
3030 libhdf5-dev \
3131 # For building Python from source
3232 build-essential \
33- libffi-dev \
3433 libgdbm-dev \
3534 libc6-dev \
3635 libssl-dev \
36+ libffi-dev \
3737 zlib1g-dev \
3838 libbz2-dev \
3939 libreadline-dev \
@@ -46,6 +46,22 @@ RUN apt-get update && \
4646 libxmlsec1-dev \
4747 liblzma-dev \
4848 wget \
49+ libavcodec58:armhf \
50+ libusb-1.0-0-dev:armhf \
51+ libboost-regex-dev:armhf \
52+ crossbuild-essential-armhf \
53+ libgtk-3-dev:armhf \
54+ libavcodec-dev:armhf \
55+ libavformat-dev:armhf \
56+ libswscale-dev:armhf \
57+ libgstreamer1.0-dev:armhf \
58+ libpython-dev:armhf \
59+ libgstreamer-plugins-base1.0-dev:armhf \
60+ zlib1g-dev:armhf \
61+ nlohmann-json-dev \
62+ libgflags-dev:armhf \
63+ libtbb-dev:armhf \
64+ libffi-dev:armhf \
4965 # Compilers
5066 gcc-arm-linux-gnueabihf \
5167 g++-arm-linux-gnueabihf \
@@ -70,19 +86,140 @@ RUN mkdir ${SCCACHE_HOME} && cd ${SCCACHE_HOME} && \
7086
7187ENV PATH="$SCCACHE_HOME:$PATH"
7288
73- # Setup Python
89+ # Build Pythons
90+ # Python 3.9
91+
92+ # To cross-compile Python 3.9 we need to first compile it for the host
93+ RUN wget https://www.python.org/ftp/python/3.9.21/Python-3.9.21.tar.xz
94+
95+ RUN tar -xf Python-3.9.21.tar.xz && \
96+ cd Python-3.9.21 && \
97+ ./configure --enable-optimizations && \
98+ make -j $(nproc) && \
99+ make altinstall
100+
101+ # Compile Python 3.9 for ARM
102+ RUN cd Python-3.9.21 && make distclean && \
103+ ./configure \
104+ --host=arm-linux-gnueabihf \
105+ --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) \
106+ --disable-ipv6 \
107+ --enable-shared \
108+ --prefix=/opt/python3.9_arm \
109+ ac_cv_file__dev_ptmx=no \
110+ ac_cv_file__dev_ptc=no && \
111+ make -j $(nproc) && make altinstall
112+
113+ # Python 3.10
114+ # To cross-compile Python 3.10 we need to first compile it for the host
115+ RUN wget https://www.python.org/ftp/python/3.10.16/Python-3.10.16.tar.xz
116+
117+ RUN tar -xf Python-3.10.16.tar.xz && \
118+ cd Python-3.10.16 && \
119+ ./configure --enable-optimizations && \
120+ make -j $(nproc) && \
121+ make altinstall
122+
123+ # Compile Python 3.10 for ARM
124+ RUN cd Python-3.10.16 && make distclean && \
125+ ./configure \
126+ --host=arm-linux-gnueabihf \
127+ --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) \
128+ --disable-ipv6 \
129+ --enable-shared \
130+ --prefix=/opt/python3.10_arm \
131+ ac_cv_file__dev_ptmx=no \
132+ ac_cv_file__dev_ptc=no && \
133+ make -j $(nproc) && make altinstall
134+
135+ # Upgrade openssl to 3.3.1 for Python3.11 - 3.13 ssl module
136+ RUN wget https://www.openssl.org/source/openssl-3.3.1.tar.gz && \
137+ tar -zxf openssl-3.3.1.tar.gz && \
138+ cd openssl-3.3.1 && \
139+ ./config && \
140+ make install && \
141+ ln -sf /usr/local/bin/openssl /usr/bin/openssl && \
142+ echo /usr/local/lib64 | tee /etc/ld.so.conf.d/custom.conf && \
143+ ldconfig && \
144+ openssl version
145+
146+ # Python 3.11
147+ # To cross-compile Python 3.11 we need to first compile it for the host
74148RUN wget https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tar.xz
75149
76150RUN tar -xf Python-3.11.9.tar.xz && \
77151 cd Python-3.11.9 && \
78- ./configure --enable-optimizations && \
79- make -j 8 && \
152+ LDFLAGS="-L/usr/local/lib64" ./configure --with-openssl=/usr/local --with-openssl-rpath=auto && \
153+ make -j $(nproc) && \
154+ make altinstall
155+
156+ # Compile Python 3.11 for ARM
157+ RUN cd Python-3.11.9 && make distclean && \
158+ ./configure \
159+ --host=arm-linux-gnueabihf \
160+ --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) \
161+ --disable-ipv6 \
162+ --enable-shared \
163+ --with-build-python \
164+ --prefix=/opt/python3.11_arm \
165+ ac_cv_file__dev_ptmx=no \
166+ ac_cv_file__dev_ptc=no && \
167+ make -j $(nproc) && make altinstall
168+
169+ # Python 3.12
170+ # To cross-compile Python 3.12 we need to first compile it for the host
171+ RUN wget https://www.python.org/ftp/python/3.12.9/Python-3.12.9.tar.xz
172+
173+ RUN tar -xf Python-3.12.9.tar.xz && \
174+ cd Python-3.12.9 && \
175+ LDFLAGS="-L/usr/local/lib64" ./configure --with-openssl=/usr/local --with-openssl-rpath=auto && \
176+ make -j $(nproc) && \
177+ make altinstall
178+
179+ # Compile Python 3.12 for ARM
180+ RUN cd Python-3.12.9 && make distclean && \
181+ ./configure \
182+ --host=arm-linux-gnueabihf \
183+ --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) \
184+ --disable-ipv6 \
185+ --enable-shared \
186+ --with-build-python \
187+ --prefix=/opt/python3.12_arm \
188+ ac_cv_file__dev_ptmx=no \
189+ ac_cv_file__dev_ptc=no && \
190+ make -j $(nproc) && make altinstall
191+
192+ # Python 3.13
193+ # To cross-compile Python 3.13 we need to first compile it for the host
194+ RUN wget https://www.python.org/ftp/python/3.13.2/Python-3.13.2.tar.xz
195+
196+ RUN tar -xf Python-3.13.2.tar.xz && \
197+ cd Python-3.13.2 && \
198+ LDFLAGS="-L/usr/local/lib64" ./configure --with-openssl=/usr/local --with-openssl-rpath=auto && \
199+ make -j $(nproc) && \
80200 make altinstall
81201
202+ # Compile Python 3.13 for ARM
203+ RUN cd Python-3.13.2 && make distclean && \
204+ ./configure \
205+ --host=arm-linux-gnueabihf \
206+ --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) \
207+ --disable-ipv6 \
208+ --enable-shared \
209+ --with-build-python \
210+ --prefix=/opt/python3.13_arm \
211+ ac_cv_file__dev_ptmx=no \
212+ ac_cv_file__dev_ptc=no && \
213+ make -j $(nproc) && make altinstall
214+
82215# Setup pip
83216ENV PIP_VERSION="24.0"
84- RUN python3 -m pip install --upgrade pip==24.0
85- RUN python3.11 -m pip install --upgrade pip==24.0
217+ RUN python3 -m pip install --upgrade pip==${PIP_VERSION} && \
218+ python3.9 -m pip install --upgrade pip==${PIP_VERSION} && \
219+ python3.10 -m pip install --upgrade pip==${PIP_VERSION} && \
220+ python3.11 -m pip install --upgrade pip==${PIP_VERSION} && \
221+ python3.12 -m pip install --upgrade pip==${PIP_VERSION} && \
222+ python3.13 -m pip install --upgrade pip==${PIP_VERSION}
86223
87224# Use Python 3.11 as default
88225# Using venv here because other methods to switch the default Python break both system and wheels build
0 commit comments