From 459612e52077c14aa6945a7f5000548ec42f4407 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Mon, 20 Jan 2020 14:21:44 +0100
Subject: [PATCH] Added pip packages to runtime too.

---
 Jenkinsfile  |  2 +-
 ogscm/cli.py | 29 ++++++++++++-----------------
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index f9076a2..cdd83a5 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -5,7 +5,7 @@ pipeline {
   agent { label 'singularity' }
   parameters {
     string(name: 'ogs', defaultValue: 'ufz/ogs@master',
-           description: 'Build OGS in container (Github user/repo@branch)')
+           description: 'Build OGS in container (Github user/repo@branch OR user/repo@@commit_hash)')
     string(name: 'format', defaultValue: 'docker',
            description: 'Container format, e.g.: docker singularity')
     string(name: 'openmpi_versions', defaultValue: 'off',
diff --git a/ogscm/cli.py b/ogscm/cli.py
index 079561b..96ff23a 100644
--- a/ogscm/cli.py
+++ b/ogscm/cli.py
@@ -59,8 +59,6 @@ def main():  # pragma: no cover
         ompi = build[3]
         cmake_args = build[4].strip().split(' ')
 
-        scif_installed = False
-
         # args checking
         if len(c) > 1 and args.file != '':
             print(
@@ -137,6 +135,14 @@ def main():  # pragma: no cover
                             args.compiler_version)
                     ])
 
+        # Prepare runtime stage
+        Stage1 = hpccm.Stage()
+        Stage1.baseimage(image=args.base_image)
+
+        # Install scif in all stages
+        Stage0 += pip(packages=['scif'], pip='pip3')
+        Stage1 += pip(packages=['scif'], pip='pip3')
+
         if ompi != 'off':
             mpicc = object
             if False:  # eve:
@@ -234,9 +240,6 @@ def main():  # pragma: no cover
                 })
 
             if args.mpi_benchmarks:
-                Stage0 += pip(packages=['scif'], pip='pip3')
-                scif_installed = True
-
                 osu_app = scif(name='osu', file="_out/osu.scif")
                 osu_app += osu_benchmarks(toolchain=toolchain,
                                           prefix='/scif/apps/osu')
@@ -248,6 +251,9 @@ def main():  # pragma: no cover
                     'mpicc -o /usr/local/bin/mpi-ring /usr/local/mpi-examples/ring.c',
                     'mpicc -o /usr/local/bin/mpi-bw /usr/local/mpi-examples/bw.c',
                 ])
+                Stage1 += copy(_from='build',
+                               src='/usr/local/bin/mpi_*',
+                               dest='/usr/local/bin/')
 
         if ogs_version != 'off' or args.jenkins:
             Stage0 += ogs_base()
@@ -323,6 +329,7 @@ def main():  # pragma: no cover
 
         if args.pip:
             Stage0 += pip(packages=args.pip, pip='pip3')
+            Stage1 += pip(packages=args.pip, pip='pip3')
 
         if ogs_version != 'off':
             mount_args = ''
@@ -336,9 +343,6 @@ def main():  # pragma: no cover
             if args.insitu:
                 cmake_args.append('-DOGS_INSITU=ON')
 
-            if not scif_installed:
-                Stage0 += pip(packages=['scif'], pip='pip3')  # SCI-F
-                scif_installed = True
             Stage0 += raw(docker=f"ARG OGS_COMMIT_HASH={info.commit_hash}")
 
             scif_file = f"{info.out_dir}/ogs.scif"
@@ -369,15 +373,6 @@ def main():  # pragma: no cover
         stages_string = str(Stage0)
 
         if args.runtime_only:
-            Stage1 = hpccm.Stage()
-            Stage1.baseimage(image=args.base_image)
-            if scif_installed:
-                # Install scif in runtime too
-                Stage1 += pip(packages=['scif'], pip='pip3')
-            if openmpi and args.mpi_benchmarks:
-                Stage1 += copy(_from='build',
-                               src='/usr/local/bin/mpi_*',
-                               dest='/usr/local/bin/')
             Stage1 += Stage0.runtime()
             if args.compiler == 'gcc' and args.compiler_version != None:
                 Stage1 += packages(apt=['libstdc++6'])
-- 
GitLab