Skip to content

Commit 63cc566

Browse files
committed
version-string-driven building of python interpreter builder image
1 parent a455662 commit 63cc566

File tree

4 files changed

+55
-18
lines changed

4 files changed

+55
-18
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from ssl-and-pam
2+
run apt update
3+
run apt install -y wget build-essential
4+
run apt install -y libssl-dev zlib1g-dev libffi-dev libncurses-dev wget build-essential
5+
arg python_version
6+
run wget https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tar.xz
7+
run tar xf Python-${python_version}.tar.xz
8+
workdir /Python-${python_version}
9+
run ./configure --prefix /root/python --with-ensurepip=install
10+
run make -j
11+
run mkdir /root/python
12+
run make install
13+
workdir /
14+
run /root/python/bin/python3 -m pip install python-irodsclient
15+
run chmod a+rx /root

irods/test/harness/003_prc-with-py3_12_2.Dockerfile

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

irods/test/harness/build-docker.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/usr/bin/env bash
22

3-
# IRODS_PACKAGE_VERSION if defined is like "4.3.1-0~bionic"
3+
# environment variables for build
4+
# IRODS_PACKAGE_VERSION if defined is like "4.3.4" or "5.0.1".
45
# (but contains no '~' suffix for irods versions <= 4.2.10)
6+
# PYTHON_VERSION is usually two dot-separated numbers: example "3.13", but could also have zero, one or three version numbers.
7+
# (Do not specify the triple form, X.Y.Z, if that release is not known to exist - not counting alphas and release candidates)
58

69
BASE=$(basename "$0")
710
DIR=$(realpath "$(dirname "$0")")
@@ -15,12 +18,20 @@ fi
1518
for dockerfile in "${ARGS[@]}"; do
1619
image_name=${dockerfile#[0-9]*_}
1720
image_name=${image_name%.Dockerfile}
18-
if [ "$image_name" = "install-irods" ];then
19-
package_version_option=${IRODS_PACKAGE_VERSION:+"--build-arg=irods_package_version=$IRODS_PACKAGE_VERSION"}
21+
irods_package_version_option=""
22+
python_version_option=""
23+
if [ "$image_name" = "install-irods" ]; then
24+
irods_package_version_option=${IRODS_PACKAGE_VERSION:+"--build-arg=irods_package_version=$IRODS_PACKAGE_VERSION"}
25+
elif [ "$image_name" = "compile-specific-python" ]; then
26+
temp=$(./most_recent_python.sh $PYTHON_VERSION)
27+
if [ -n "$temp" ]; then
28+
PYTHON_VERSION="$temp"
29+
fi
30+
python_version_option=${PYTHON_VERSION:+"--build-arg=python_version=$PYTHON_VERSION"}
2031
else
2132
package_version_option=""
2233
fi
23-
$DOCKER build -f $dockerfile -t $image_name . $package_version_option \
34+
$DOCKER build -f $dockerfile -t $image_name . $irods_package_version_option $python_version_option \
2435
${NO_CACHE+"--no-cache"} ||
2536
{ STATUS=$?; echo "*** Failure while building [$image_name]"; exit $STATUS; }
2637
done
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
usage() {
3+
echo >&2 "Usage:
4+
$0 major.minor"
5+
echo >&2 "Output:
6+
prints full latest python version inclusive of the patch level."
7+
exit 2
8+
}
9+
MAJOR_MINOR=$1
10+
if [ -z "${MAJOR_MINOR}" ]; then # allow blank specification: most recent overall
11+
MAJOR_MINOR='[0-9]\+\.[0-9]\+'
12+
elif [[ $MAJOR_MINOR =~ ^[0-9]+$ ]]; then # allow single integer, eg. 3 for most recent 3.y.z
13+
MAJOR_MINOR+='\.[0-9]\+'
14+
elif [[ $MAJOR_MINOR =~ [0-9]+\.[0-9]+ ]]; then # allow x.y form, will yield output of most recent x.y.z
15+
MAJOR_MINOR=$(sed 's/\./\\./'<<<"${MAJOR_MINOR}") # insert backslash in front of "."
16+
elif ! [[ $MAJOR_MINOR =~ [0-9]+\\?.[0-9]+ ]]; then
17+
usage
18+
fi
19+
20+
url='https://www.python.org/ftp/python/'
21+
22+
# Fetch the directory listing, extract version numbers, sort them to find the largest numerically.
23+
curl --silent "$url"|\
24+
sed -n 's!.*href="\('"${MAJOR_MINOR}"'\.[0-9]\+\)/".*!\1!p'|sort -rV|\
25+
head -n 1

0 commit comments

Comments
 (0)