def runtime(self, _from='0'): """Install the runtime from a full build in a previous stage""" instructions = [] instructions.append(comment('PGI compiler')) if self.__ospackages: instructions.append(packages(ospackages=self.__ospackages)) instructions.append( copy(_from=_from, src=os.path.join(self.__basepath, self.__version, 'REDIST', '*.so'), dest=os.path.join(self.__basepath, self.__version, 'lib', ''))) instructions.append( shell(commands=[ 'ln -s {0} {1}'.format( os.path.join(self.__basepath, self.__version, 'lib', 'libpgnuma.so'), os.path.join(self.__basepath, self.__version, 'lib', 'libnuma.so')) ])) instructions.append( environment( variables={ 'LD_LIBRARY_PATH': '{}:$LD_LIBRARY_PATH'.format( os.path.join(self.__basepath, self.__version, 'lib')) })) return instructions
def __str__(self): """String representation of the building block""" ospackages = list(self.__ospackages) # Installer needs perl ospackages.append('perl') instructions = [] instructions.append( comment('PGI compiler version {}'.format(self.__version))) if self.__tarball: # Use tarball from local build context instructions.append( copy(src=self.__tarball, dest=os.path.join(self.__wd, self.__tarball))) else: # Downloading, so need wget ospackages.append('wget') if ospackages: instructions.append(packages(ospackages=ospackages)) instructions.append(shell(commands=self.__commands)) instructions.append( environment( variables={ 'PATH': '{}:$PATH'.format( os.path.join(self.__basepath, self.__version, 'bin')), 'LD_LIBRARY_PATH': '{}:$LD_LIBRARY_PATH'.format( os.path.join(self.__basepath, self.__version, 'lib')) })) return '\n'.join(str(x) for x in instructions)
def test_baseimage_first(self): """Base image is always first""" s = Stage() s += shell(commands=['abc']) s.name = 'bar' s.baseimage('foo') self.assertEqual(str(s), 'FROM foo AS bar\n\nRUN abc')
def __str__(self): """String representation of the building block""" instructions = [] instructions.append(comment('CMake version {}'.format(self.__version))) instructions.append(packages(ospackages=self.__ospackages)) instructions.append(shell(commands=self.__commands)) return '\n'.join(str(x) for x in instructions)
def test_single(self): """Single command specified""" cmd = ['z'] s = shell(commands=cmd) self.assertEqual(s.toString(container_type.DOCKER), 'RUN z') self.assertEqual(s.toString(container_type.SINGULARITY), '%post\n z')
def __str__(self): """String representation of the building block""" instructions = [] instructions.append(comment('MKL version {}'.format(self.version))) if self.__ospackages: instructions.append(packages(ospackages=self.__ospackages)) if not self.__eula: raise RuntimeError( 'Intel EULA was not accepted. To accept, see the documentation for this building block' ) instructions.append( packages( apt_keys=[ 'https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB' ], apt_repositories=[ 'deb https://apt.repos.intel.com/mkl all main' ], ospackages=['intel-mkl-64bit-{}'.format(self.version)], yum_keys=[ 'https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB' ], yum_repositories=[ 'https://yum.repos.intel.com/mkl/setup/intel-mkl.repo' ])) # Set the environment if self.__mklvars: # Source the mklvars environment script when starting the # container, but the variables not be available for any # subsequent build steps. instructions.append( shell(commands=[ 'echo "source /opt/intel/mkl/bin/mklvars.sh intel64" >> {}' .format(self.__bashrc) ])) else: # Set the environment so that it will be available to # subsequent build steps and when starting the container, # but this may miss some things relative to the mklvars # environment script. instructions.append( environment( variables={ 'CPATH': '/opt/intel/mkl/include:$CPATH', 'LD_LIBRARY_PATH': '/opt/intel/mkl/lib/intel64:/opt/intel/lib/intel64:$LD_LIBRARY_PATH', 'LIBRARY_PATH': '/opt/intel/mkl/lib/intel64:/opt/intel/lib/intel64:$LIBRARY_PATH', 'MKLROOT': '/opt/intel/mkl' })) return '\n'.join(str(x) for x in instructions)
def test_multiple(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds) self.assertEqual(s.toString(container_type.DOCKER), 'RUN a && \\\n b && \\\n c') self.assertEqual(s.toString(container_type.SINGULARITY), '%post\n a\n b\n c')
def __str__(self): """String representation of the primitive""" if self.directory: if hpccm.config.g_ctype == container_type.DOCKER: return 'WORKDIR {}'.format(self.directory) elif hpccm.config.g_ctype == container_type.SINGULARITY: s = shell(commands=[ 'mkdir -p {}'.format(self.directory), 'cd {}'.format( self.directory) ]) return str(s) else: raise RuntimeError('Unknown container type') else: logging.error('No directory specified') return ''
def __str__(self): """String representation of the primitive""" if hpccm.config.g_ctype == container_type.DOCKER: image = 'FROM {}'.format(self.image) if self.__as: image = image + ' AS {}'.format(self.__as) return image elif hpccm.config.g_ctype == container_type.SINGULARITY: # Singularity does not inherit the environment from the # Docker base image automatically. Do it manually. docker_env = shell(commands=['. /.singularity.d/env/10-docker.sh']) return 'BootStrap: docker\nFrom: {0}\n{1}'.format( self.image, str(docker_env)) else: raise RuntimeError('Unknown container type')
def __str__(self): """String representation of the building block""" instructions = [] if self.__directory: instructions.append(comment('FFTW')) else: instructions.append( comment('FFTW version {}'.format(self.__version))) instructions.append(packages(ospackages=self.__ospackages)) if self.__directory: # Use source from local build context instructions.append( copy(src=self.__directory, dest=os.path.join(self.__wd, self.__directory))) instructions.append(shell(commands=self.__commands)) instructions.append( environment(variables=self.__environment_variables)) return '\n'.join(str(x) for x in instructions)
def __str__(self): """String representation of the building block""" instructions = [] comments = ['NetCDF version {}'.format(self.__version)] if self.__cxx: comments.append('NetCDF C++ version {}'.format(self.__version_cxx)) if self.__fortran: comments.append('NetCDF Fortran version {}'.format( self.__version_fortran)) instructions.append(comment(', '.join(comments))) if self.__ospackages: instructions.append(packages(ospackages=self.__ospackages)) instructions.append(shell(commands=self.__commands)) instructions.append( environment(variables=self.__environment_variables)) return '\n'.join(str(x) for x in instructions)
def __str__(self): """String representation of the building block""" return str(shell(commands=self.__commands))
def test_multiple_singularity(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds) self.assertEqual(str(s), '%post\n a\n b\n c')
def test_multiple_docker(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds) self.assertEqual(str(s), 'RUN a && \\\n b && \\\n c')
def test_single_singularity(self): """Single command specified""" cmd = ['z'] s = shell(commands=cmd) self.assertEqual(str(s), '%post\n z')
def test_single_docker(self): """Single command specified""" cmd = ['z'] s = shell(commands=cmd) self.assertEqual(str(s), 'RUN z')
def test_invalid_ctype(self): """Invalid container type specified""" s = shell(commands=['a']) with self.assertRaises(RuntimeError): str(s)
def test_empty(self): """No commands specified""" s = shell() self.assertEqual(str(s), '')
def test_invalid_ctype(self): """Invalid container type specified""" s = shell(commands=['a']) self.assertEqual(s.toString(None), '')
def test_empty(self): """No commands specified""" s = shell() self.assertEqual(s.toString(container_type.DOCKER), '')