Skip to content

Commit ccd7b21

Browse files
Onboard python 3.14 ubuntu image (#2635)
* Activate Yarn Versions in image using corepack * add python 3.14 noble based image * update debianFlavours * update debianFlavours * install odbc2 package only for ubuntu based image * update debianflavors variables * fix sdk building for 3.14 * update DEBIAN_FLAVOR * revert nodeRuntimeBase deletion * update debian flavor env * update python dockerfile * fix syntax error * remove githubactions buster * resolve merge conflicts * update variable name for more clarity * verify SHA after installing python source code * Add python314osFlavors * Verify SHA for python tar * Verify SHA for python tar * test sdk generation * fix arguments in buildPythonSdkByVersion.sh * revert versionsToBuild changes
1 parent 7d503db commit ccd7b21

File tree

13 files changed

+247
-189
lines changed

13 files changed

+247
-189
lines changed

build/buildPythonSdkByVersion.sh

Lines changed: 84 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,103 @@ set -ex
88
declare -r REPO_DIR=$( cd $( dirname "$0" ) && cd .. && pwd )
99

1010
pythonVersionGPG=''
11+
python_sha=''
1112

1213
version="$1"
1314

1415
buildPythonfromSource()
1516
{
1617
pythonVersion=$PYTHON_VERSION
17-
18-
if [ ! -z "$1" ]; then
19-
echo "$1"
20-
pythonVersion=$1
21-
fi
2218

23-
if [ ! -z "$2" ]; then
24-
echo "$2"
25-
gpgKey=$2
26-
fi
19+
# Parse named parameters
20+
while [[ $# -gt 0 ]]; do
21+
case $1 in
22+
version=*)
23+
pythonVersion="${1#*=}"
24+
shift
25+
;;
26+
gpg=*)
27+
gpgKey="${1#*=}"
28+
shift
29+
;;
30+
python_sha=*)
31+
python_sha="${1#*=}"
32+
shift
33+
;;
34+
*)
35+
echo "Unknown parameter: $1"
36+
shift
37+
;;
38+
esac
39+
done
2740

2841
mkdir -p "tmpFiles"
2942
wget https://www.python.org/ftp/python/${pythonVersion%%[a-z]*}/Python-$pythonVersion.tar.xz -O /tmpFiles/python.tar.xz
30-
wget https://www.python.org/ftp/python/${pythonVersion%%[a-z]*}/Python-$pythonVersion.tar.xz.asc -O /tmpFiles/python.tar.xz.asc
43+
44+
if [ -n "$python_sha" ]; then
45+
echo "Verifying Python source code using SHA256 checksum..."
46+
echo "$python_sha /tmpFiles/python.tar.xz" | sha256sum -c -
47+
echo "SHA256 verification successful!"
48+
fi
49+
50+
if [ -n "$gpgKey" ]
51+
then
52+
wget https://www.python.org/ftp/python/${pythonVersion%%[a-z]*}/Python-$pythonVersion.tar.xz.asc -O /tmpFiles/python.tar.xz.asc
53+
54+
# Try getting the keys 5 times at most
55+
/tmp/receiveGpgKeys.sh $gpgKey
56+
gpg --batch --verify /tmpFiles/python.tar.xz.asc /tmpFiles/python.tar.xz
57+
fi
3158

3259
PYTHON_GET_PIP_URL="https://bootstrap.pypa.io/get-pip.py"
3360

3461
# for buster and ubuntu we would need following libraries
35-
apt-get update && \
36-
apt-get upgrade -y && \
37-
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
38-
# Adding additional python packages to support all optional python modules:
39-
# https://devguide.python.org/getting-started/setup-building/index.html#install-dependencies
40-
build-essential \
41-
gdb \
42-
lcov \
43-
libbluetooth-dev \
44-
libbz2-dev \
45-
libffi-dev \
46-
libgdbm-dev \
47-
libgdm-dev \
48-
libgeos-dev \
49-
liblzma-dev \
50-
libncurses5-dev \
51-
libreadline-dev \
52-
libreadline6-dev \
53-
libsqlite3-dev \
54-
libssl-dev \
55-
lzma \
56-
lzma-dev \
57-
pkg-config \
58-
python3-dev \
59-
tk-dev \
60-
uuid-dev
61-
uuid-dev \
62-
zlib1g-dev \
63-
64-
# Try getting the keys 5 times at most
65-
/tmp/receiveGpgKeys.sh $gpgKey
66-
67-
gpg --batch --verify /tmpFiles/python.tar.xz.asc /tmpFiles/python.tar.xz
62+
apt-get update && \
63+
apt-get upgrade -y && \
64+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
65+
build-essential \
66+
gdb \
67+
lcov \
68+
libbluetooth-dev \
69+
libbz2-dev \
70+
libffi-dev \
71+
libgdbm-dev \
72+
libgdm-dev \
73+
libgeos-dev \
74+
liblzma-dev \
75+
libncurses5-dev \
76+
libreadline-dev \
77+
libreadline6-dev \
78+
libsqlite3-dev \
79+
libssl-dev \
80+
lzma \
81+
lzma-dev \
82+
pkg-config \
83+
python3-dev \
84+
tk-dev \
85+
uuid-dev \
86+
zlib1g-dev
87+
6888
tar -xJf /tmpFiles/python.tar.xz --strip-components=1 -C .
6989

7090
INSTALLATION_PREFIX=/opt/python/$PYTHON_VERSION
7191

72-
if [ "${PYTHON_VERSION::1}" == "2" ]; then
73-
./configure \
74-
--prefix=$INSTALLATION_PREFIX \
75-
--build=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) \
76-
--enable-shared \
77-
--enable-unicode=ucs4
78-
else
79-
./configure \
80-
--prefix=$INSTALLATION_PREFIX \
81-
--build=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) \
82-
--enable-loadable-sqlite-extensions \
83-
--enable-shared \
84-
--with-system-expat \
85-
--with-system-ffi \
86-
--without-ensurepip
87-
fi
92+
93+
./configure \
94+
--prefix=$INSTALLATION_PREFIX \
95+
--build=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE) \
96+
--enable-loadable-sqlite-extensions \
97+
--enable-shared \
98+
--with-system-expat \
99+
--with-system-ffi \
100+
--without-ensurepip
88101

89102
make -j $(nproc)
90103

91104
make install
92105

106+
export LD_LIBRARY_PATH="/opt/python/$PYTHON_VERSION/lib/"
107+
$INSTALLATION_PREFIX/bin/python3 --version
93108
rm -rf /usr/src/python
94109
find /usr/local -depth \
95110
\( \
@@ -98,21 +113,18 @@ buildPythonfromSource()
98113
\) -exec rm -rf '{}' + \
99114

100115
ldconfig
101-
python3 --version
102116

103-
# make some useful symlinks that are expected to exist
104-
cd /usr/local/bin
117+
# make some useful symlinks that are expected to exist in the installation prefix
118+
cd $INSTALLATION_PREFIX/bin
105119
ln -s idle3 idle
106120
ln -s pydoc3 pydoc
107121
ln -s python3 python
108122
ln -s python3-config python-config
109123

110-
PYTHON_GET_PIP_SHA256="c518250e91a70d7b20cceb15272209a4ded2a0c263ae5776f129e0d9b5674309"
111-
112124
# Install pip
113125
wget "$PYTHON_GET_PIP_URL" -O /tmpFiles/get-pip.py
114126

115-
python3 /tmpFiles/get-pip.py \
127+
$INSTALLATION_PREFIX/bin/python3 /tmpFiles/get-pip.py \
116128
--trusted-host pypi.python.org \
117129
--trusted-host pypi.org \
118130
--trusted-host files.pythonhosted.org \
@@ -139,7 +151,7 @@ buildPythonfromSource()
139151
rm -rf /Python /PCbuild /Grammar /python /Objects /Parser /Misc /Tools /Programs /Modules /Include /Mac /Doc /PC /Lib
140152
}
141153

142-
getPythonGpgByVersion() {
154+
getPythonGpgAndShaByVersion() {
143155
local versionFile="$1"
144156
local versionPython="$2"
145157

@@ -153,24 +165,25 @@ getPythonGpgByVersion() {
153165
arg="$(echo -e "${VERSION_INFO}" | sed -e 's/^[[:space:]]*//')"
154166
test1=$(echo $arg | cut -d',' -f 1)
155167
test2=$(echo $arg | cut -d',' -f 2)
168+
test3=$(echo $arg | cut -d',' -f 3)
156169

157170
if [ "$versionPython" == "$test1" ];then
158171
pythonVersionGPG="$test2"
172+
python_sha="$test3"
159173
fi
160174
done < "$versionFile"
161175
}
162176

163-
164177
echo
165-
# TODO: Determine if we need to continue building newer versions of Python from scratch
166178
echo "Building python 3.14 or newer from source code..."
167179

168-
getPythonGpgByVersion "/tmp/versionsToBuild.txt" $version
169-
IFS='.' read -ra SPLIT_VERSION <<< "$PYTHON_VERSION"
180+
getPythonGpgAndShaByVersion "/tmp/versionsToBuild.txt" $version
181+
IFS='.' read -ra SPLIT_VERSION <<< "$version"
170182

171183
if [ "${SPLIT_VERSION[0]}" == "3" ] && [ "${SPLIT_VERSION[1]}" -ge "14" ]
172184
then
173-
buildPythonfromSource $version $pythonVersionGPG
185+
echo "version=$version, gpg='$pythonVersionGPG', sha='$python_sha'"
186+
buildPythonfromSource version=$version gpg="$pythonVersionGPG" python_sha="$python_sha"
174187
else
175188
source /tmp/oryx/images/installPlatform.sh python $version --dir /opt/python/$version --links false
176189
fi

images/constants.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@ variables:
1616
python311osFlavors: bullseye,bookworm
1717
python312osFlavors: bullseye,bookworm
1818
python313osFlavors: bullseye,bookworm
19+
python314osFlavors: noble
1920
dotnet80osFlavors: bullseye,bookworm
2021
dotnet90osFlavors: bookworm
2122
dotnet100osFlavors: noble
2223
php81osFlavors: bullseye
2324
php82osFlavors: bullseye
2425
php83osFlavors: bullseye,bookworm
2526
php84osFlavors: bullseye,bookworm
26-
osFlavors: bullseye,bookworm
27+
osFlavors: bullseye,bookworm,noble
2728
dotnetosFlavors: bookworm,bullseye,noble
2829
nodejsosFlavors: bookworm,bullseye
2930
phposFlavors: bookworm,bullseye
30-
pythonosFlavors: bookworm,bullseye
31+
pythonosFlavors: bookworm,bullseye,noble
3132
cliDebianFlavors: bullseye
3233
cliBuilderDebianFlavors: bullseye
3334
fullDebianFlavors: bullseye
@@ -70,4 +71,5 @@ variables:
7071
python310Version: 3.10.18
7172
python311Version: 3.11.13
7273
python312Version: 3.12.11
73-
python313Version: 3.13.5
74+
python313Version: 3.13.5
75+
python314Version: 3.14.0rc2

images/runtime/commonbase/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
ARG DEBIAN_FLAVOR
2-
FROM mcr.microsoft.com/mirror/docker/library/debian:${DEBIAN_FLAVOR}
1+
ARG OS_FLAVOR
2+
ARG OS_TYPE
3+
FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR}
34
ARG IMAGES_DIR=/tmp/oryx/images
45
ARG BUILD_DIR=/tmp/oryx/build
56

@@ -13,8 +14,8 @@ RUN apt-get update \
1314
netbase \
1415
wget
1516

16-
ARG DEBIAN_FLAVOR
17-
RUN if [ "${DEBIAN_FLAVOR}" = "bookworm" ] ; then \
17+
ARG OS_FLAVOR
18+
RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \
1819
apt-get update && apt-get install -y --no-install-recommends sq ; \
1920
fi
2021

images/runtime/python/install-dependencies.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66

77
set -ex
88

9-
debianFlavor=$DEBIAN_FLAVOR
9+
osFlavor=${DEBIAN_FLAVOR:-$OS_FLAVOR}
10+
11+
# Install ODBC library based on Debian flavor
12+
if [ "$osFlavor" == "noble" ]; then
13+
odbcPackage="libodbc2"
14+
else
15+
odbcPackage="libodbc1"
16+
fi
1017

1118
# libpq-dev is for PostgreSQL
1219
apt-get update \
@@ -18,7 +25,7 @@ apt-get update \
1825
libpq-dev \
1926
default-libmysqlclient-dev \
2027
unzip \
21-
libodbc1 \
28+
$odbcPackage \
2229
apt-transport-https \
2330
swig \
2431
# GIS libraries for GeoDjango (https://docs.djangoproject.com/en/3.2/ref/contrib/gis/install/geolibs/)
@@ -34,15 +41,11 @@ apt-get update \
3441
export ACCEPT_EULA=Y \
3542
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
3643

37-
if [ "$debianFlavor" == "bookworm" ]; then \
44+
if [ "$osFlavor" == "bookworm" ]; then \
3845
curl https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list
3946
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
40-
elif [ "$debianFlavor" == "bullseye" ]; then \
47+
elif [ "$osFlavor" == "bullseye" ]; then \
4148
curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list
42-
elif [ "$debianFlavor" == "buster" ]; then \
43-
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list
44-
elif [ "$debianFlavor" == "stretch" ]; then \
45-
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
4649
fi
4750

4851
apt-get update \
@@ -52,7 +55,7 @@ apt-get update \
5255
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
5356
&& locale-gen
5457

55-
if [ "$debianFlavor" != "bookworm" ]; then \
58+
if [ "$osFlavor" != "bookworm" ]; then \
5659
ACCEPT_EULA=Y apt-get install -y msodbcsql17=17.10.4.1-1 \
5760
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18=18.2.2.1-1
5861
else

0 commit comments

Comments
 (0)