示例#1
0
 def test_from(self):
     """Docker --from syntax"""
     c = copy(src='a', dest='b', _from='dev')
     self.assertEqual(c.toString(container_type.DOCKER),
                      'COPY --from=dev a b')
     self.assertEqual(c.toString(container_type.SINGULARITY),
                      '%files\n    a b')
示例#2
0
 def test_multiple(self):
     """Multiple source files specified"""
     c = copy(src=['a1', 'a2', 'a3'], dest='b')
     self.assertEqual(c.toString(container_type.DOCKER),
                      'COPY a1 \\\n    a2 \\\n    a3 \\\n    b/')
     self.assertEqual(c.toString(container_type.SINGULARITY),
                      '%files\n    a1 b\n    a2 b\n    a3 b')
示例#3
0
 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
示例#4
0
    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)
示例#5
0
 def runtime(self, _from='0'):
     """Install the runtime from a full build in a previous stage"""
     instructions = []
     instructions.append(comment('Charm++'))
     instructions.append(
         copy(_from=_from, src=self.__installdir, dest=self.__installdir))
     instructions.append(
         environment(variables=self.__environment_variables))
     return instructions
示例#6
0
 def runtime(self, _from='0'):
     """Install the runtime from a full build in a previous stage"""
     instructions = []
     instructions.append(comment('OpenMPI'))
     instructions.append(packages(ospackages=self.__runtime_ospackages))
     instructions.append(
         copy(_from=_from, src=self.prefix, dest=self.prefix))
     instructions.append(
         environment(variables=self.__environment_variables))
     return instructions
 def runtime(self, _from='0'):
     """Install the runtime from a full build in a previous stage"""
     instructions = []
     instructions.append(comment('MVAPICH2'))
     # TODO: move the definition of runtime ospackages
     instructions.append(packages(ospackages=self.__runtime_ospackages))
     instructions.append(
         copy(_from=_from, src=self.prefix, dest=self.prefix))
     # No need to workaround compiler wrapper issue for the runtime.
     # Copy the dictionary so not to modify the original.
     vars = dict(self.__environment_variables)
     del vars['PROFILE_POSTLIB']
     instructions.append(environment(variables=vars))
     return instructions
示例#8
0
    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)
示例#9
0
 def test_empty(self):
     """No source or destination specified"""
     c = copy()
     self.assertEqual(c.toString(container_type.DOCKER), '')
示例#10
0
 def test_from_singularity(self):
     """Docker --from syntax"""
     c = copy(src='a', dest='b', _from='dev')
     self.assertEqual(str(c), '%files\n    a b')
示例#11
0
 def test_from_docker(self):
     """Docker --from syntax"""
     c = copy(src='a', dest='b', _from='dev')
     self.assertEqual(str(c), 'COPY --from=dev a b')
示例#12
0
 def test_multiple_singularity(self):
     """Multiple source files specified"""
     c = copy(src=['a1', 'a2', 'a3'], dest='b')
     self.assertEqual(str(c), '%files\n    a1 b\n    a2 b\n    a3 b')
示例#13
0
 def test_multiple_docker(self):
     """Multiple source files specified"""
     c = copy(src=['a1', 'a2', 'a3'], dest='b')
     self.assertEqual(str(c), 'COPY a1 \\\n    a2 \\\n    a3 \\\n    b/')
示例#14
0
 def test_single_singularity(self):
     """Single source file specified"""
     c = copy(src='a', dest='b')
     self.assertEqual(str(c), '%files\n    a b')
示例#15
0
 def test_single_docker(self):
     """Single source file specified"""
     c = copy(src='a', dest='b')
     self.assertEqual(str(c), 'COPY a b')
示例#16
0
 def test_invalid_ctype(self):
     """Invalid container type specified"""
     c = copy(src='a', dest='b')
     with self.assertRaises(RuntimeError):
         str(c)
示例#17
0
 def test_empty(self):
     """No source or destination specified"""
     c = copy()
     self.assertEqual(str(c), '')
示例#18
0
 def test_invalid_ctype(self):
     """Invalid container type specified"""
     c = copy(src='a', dest='b')
     self.assertEqual(c.toString(None), '')
示例#19
0
 def test_single(self):
     """Single source file specified"""
     c = copy(src='a', dest='b')
     self.assertEqual(c.toString(container_type.DOCKER), 'COPY a b')
     self.assertEqual(c.toString(container_type.SINGULARITY),
                      '%files\n    a b')