Skip to content

Commit d013b5e

Browse files
authored
Merge pull request #32 from CSCfi/slim_update
Fixes slim update and allows for version selection
2 parents 7926c66 + 796d8a6 commit d013b5e

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

frontends/pip-containerize.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
parser_upd.add_argument("-r","--requirements-file", type=lambda x: is_valid_file(parser, x),help="requirements file for pip")
2121
add_adv_pars(subparsers)
2222
parser_new.add_argument("--slim",action='store_true',help="Use minimal base python container")
23+
parser_new.add_argument("--pyver",help="Docker tag to use for the slim python verison, e.g 3.12.9-bookworm")
2324
parser_new.add_argument("--system-site-packages",action='store_true',help="Enable system and user site packages for the created installation")
2425

2526
ps=[parser_new,parser_upd]
@@ -34,7 +35,7 @@
3435
sys.exit(0)
3536
args = parser.parse_args()
3637
conf={}
37-
pyver="3.10.0-slim-buster"
38+
pyver="3.12.9-slim-bookworm"
3839

3940

4041

@@ -49,8 +50,14 @@
4950
conf["installation_prefix"]=args.prefix
5051
conf["mode"]="venv"
5152
if args.slim:
53+
if args.pyver:
54+
pyver=args.pyver
5255
conf["container_src"]="docker://python:{}".format(pyver)
5356
conf["isolate"]="yes"
57+
else:
58+
if args.pyver:
59+
print_warn("Using --pyver without --slim does not have an effect")
60+
5461
elif args.command == "update":
5562
conf["mode"]="venv_modify"
5663
get_old_conf(args.dir,conf)

frontends/script_shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,6 @@ def get_old_conf(d,conf):
9292
conf["installation_prefix"]=d
9393
conf["sqfs_image"]=old_conf["sqfs_image"]
9494
conf["container_image"]=old_conf["container_image"]
95+
conf["isolate"]=old_conf["isolate"]
9596
if "wrapper_paths" in old_conf:
9697
conf["wrapper_paths"] = old_conf["wrapper_paths"]

tests/validate_slim.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
4+
source $SCRIPT_DIR/setup.sh
5+
6+
rm -rf TYKKY_V_TEST
7+
mkdir -p TYKKY_V_TEST
8+
9+
cd TYKKY_V_TEST
10+
echo "csvkit" > requirements.txt
11+
echo "pip install lxml" > extra.txt
12+
13+
t_run "pip-containerize new --slim --prefix tykky_test requirements.txt" "Creating slim container works"
14+
t_run "singularity exec tykky_test/container.sif cat /etc/os-release | grep 'Debian'" "Slim container is actually using debian"
15+
t_run "pip-containerize update --post-install extra.txt tykky_test" "Updating a slim container works"
16+
t_run "pip-containerize new --slim --pyver 3.13.2-slim-bullseye --prefix tykky_test2 requirements.txt | grep 'Python 3.13.2'" "--pyver flag does not break"
17+
t_run "tykky_test2/bin/python --version | grep 'Python 3.13.2" "Correct python version used"

0 commit comments

Comments
 (0)