Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_no_url(self):
"""missing url"""
with self.assertRaises(RuntimeError):
g = generic_autotools()
def test_build_environment_and_toolchain(self):
"""build environment and toolchain"""
tc = toolchain(CC='gcc', CXX='g++', FC='gfortran')
g = generic_autotools(
build_directory='/tmp/build',
build_environment={'FOO': 'BAR'},
directory='/var/tmp/tcl8.6.9/unix',
prefix='/usr/local/tcl',
toolchain=tc,
url='https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz')
self.assertEqual(str(g),
r'''# https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz
RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz && \
def test_runtime(self):
"""Runtime"""
g = generic_autotools(
directory='tcl8.6.9/unix',
prefix='/usr/local/tcl',
url='https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz')
r = g.runtime()
self.assertEqual(r,
r'''# https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz
COPY --from=0 /usr/local/tcl /usr/local/tcl''')
def test_pre_and_post(self):
"""Preconfigure and postinstall options"""
g = generic_autotools(
directory='tcl8.6.9/unix',
postinstall=['echo "post"'],
preconfigure=['echo "pre"'],
prefix='/usr/local/tcl',
url='https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz')
self.assertEqual(str(g),
r'''# https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz
RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://prdownloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz && \
self.__runtime_ospackages = [] # Filled in by __distro()
self.__version = kwargs.pop('version', '3.1.4')
# Set the Linux distribution specific parameters
self.__distro()
# Set the environment variables
self.environment_variables['CPATH'] = '{}:$CPATH'.format(
posixpath.join(self.__prefix, 'include'))
self.environment_variables['PATH'] = '{}:$PATH'.format(
posixpath.join(self.__prefix, 'bin'))
if not self.ldconfig:
self.environment_variables['LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(posixpath.join(self.__prefix, 'lib'))
# Setup build configuration
self.__bb = generic_autotools(
annotations={'version': self.__version},
base_annotation=self.__class__.__name__,
check=self.__check,
comment=False,
devel_environment=self.environment_variables,
prefix=self.__prefix,
runtime_environment=self.environment_variables,
url='{0}/v{1}/pmix-{1}.tar.gz'.format(self.__baseurl,
self.__version),
**kwargs)
# Container instructions
self += comment('PMIX version {}'.format(self.__version))
self += packages(ospackages=self.__ospackages)
self += self.__bb
F90='mpif90', FC='mpifort')
# Set the configuration options
self.__configure()
# Set the Linux distribution specific parameters
self.__distro()
# Set the environment variables
self.environment_variables['PATH'] = '{}:$PATH'.format(
posixpath.join(self.__prefix, 'bin'))
if not self.ldconfig:
self.environment_variables['LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(posixpath.join(self.__prefix, 'lib'))
# Setup build configuration
self.__bb = generic_autotools(
annotations={'version': self.__version},
base_annotation=self.__class__.__name__,
check=self.__check,
comment=False,
configure_opts=self.__configure_opts,
devel_environment=self.environment_variables,
# Run test suite (must be after install)
postinstall=['cd /var/tmp/mpich-{}'.format(self.__version),
'RUNTESTS_SHOWPROGRESS=1 make testing'] if self.__check else None,
prefix=self.__prefix,
runtime_environment=self.environment_variables,
toolchain=self.__toolchain,
url='{0}/{1}/mpich-{1}.tar.gz'.format(self.__baseurl,
self.__version),
**kwargs)
annotations={'version': self.__version_cxx},
base_annotation='{}-cxx4'.format(self.__class__.__name__),
check=self.__check,
comment=False,
directory='netcdf-cxx4-{}'.format(self.__version_cxx),
# Checks fail when using parallel make. Disable it.
parallel=1 if self.__check else '$(nproc)',
prefix=self.__prefix,
url='{0}/v{1}.tar.gz'.format(self.__baseurl_cxx,
self.__version_cxx),
**kwargs))
# Setup optional Fortran build configuration
if self.__fortran:
comments.append('NetCDF Fortran version {}'.format(self.__version_fortran))
self.__bb.append(generic_autotools(
annotations={'version': self.__version_fortran},
base_annotation='{}-fortran'.format(self.__class__.__name__),
check=self.__check,
comment=False,
directory='netcdf-fortran-{}'.format(self.__version_fortran),
# Checks fail when using parallel make. Disable it.
parallel=1 if self.__check else '$(nproc)',
prefix=self.__prefix,
url='{0}/v{1}.tar.gz'.format(self.__baseurl_fortran,
self.__version_fortran),
**kwargs))
# Container instructions
self += comment(', '.join(comments))
self += packages(ospackages=self.__ospackages)
self += [bb for bb in self.__bb]
self.__configure_opts = kwargs.pop('configure_opts', [])
self.__directory = kwargs.pop('directory', '')
self.__mpi = kwargs.pop('mpi', False)
self.__ospackages = kwargs.pop('ospackages', ['file', 'make', 'wget'])
self.__prefix = kwargs.pop('prefix', '/usr/local/fftw')
self.__version = kwargs.pop('version', '3.3.8')
# Set the configure options
self.__configure()
# Set the environment variables
if not self.ldconfig:
self.environment_variables['LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(posixpath.join(self.__prefix, 'lib'))
# Setup build configuration
self.__bb = generic_autotools(
annotations={'version': self.__version},
base_annotation=self.__class__.__name__,
check=self.__check,
configure_opts=self.__configure_opts,
comment=False,
devel_environment=self.environment_variables,
# PGI compiler needs a larger stack size
postconfigure=['ulimit -s unlimited'] if self.__check else None,
prefix=self.__prefix,
runtime_environment=self.environment_variables,
url='{0}/fftw-{1}.tar.gz'.format(self.__baseurl, self.__version),
**kwargs)
# Container instructions
self += comment('FFTW version {}'.format(self.__version))
self += packages(ospackages=self.__ospackages)
self.__baseurl = kwargs.pop('baseurl', 'https://download.schedmd.com/slurm')
self.__environment = kwargs.pop('environment', False)
self.__ospackages = kwargs.pop('ospackages', ['bzip2', 'file', 'make',
'perl', 'tar', 'wget'])
self.__prefix = kwargs.pop('prefix', '/usr/local/slurm-pmi2')
self.__version = kwargs.pop('version', '19.05.5')
# Setup the environment variables
self.environment_variables['CPATH'] = '{}:$CPATH'.format(
posixpath.join(self.__prefix, 'include', 'slurm'))
if not self.ldconfig:
self.environment_variables['LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(posixpath.join(self.__prefix, 'lib'))
# Setup build configuration
self.__bb = generic_autotools(
annotations={'version': self.__version},
base_annotation=self.__class__.__name__,
comment=False,
devel_environment=self.environment_variables,
environment=self.__environment,
install=False,
make=False,
postconfigure=['make -C contribs/pmi2 install'],
prefix=self.__prefix,
runtime_environment=self.environment_variables,
url='{0}/slurm-{1}.tar.bz2'.format(self.__baseurl, self.__version),
**kwargs)
# Container instructions
self += comment('SLURM PMI2 version {}'.format(self.__version))
self += packages(ospackages=self.__ospackages)
# Set the download specific parameters
self.__download()
# Setup the environment variables
self.environment_variables['CPATH'] = '{}:$CPATH'.format(
posixpath.join(self.__prefix, 'include'))
self.environment_variables['LIBRARY_PATH'] = '{}:$LIBRARY_PATH'.format(
posixpath.join(self.__prefix, 'lib'))
self.environment_variables['PATH'] = '{}:$PATH'.format(
posixpath.join(self.__prefix, 'bin'))
if not self.ldconfig:
self.environment_variables['LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(posixpath.join(self.__prefix, 'lib'))
# Setup build configuration
comments = ['NetCDF version {}'.format(self.__version)]
self.__bb = [generic_autotools(
annotations={'version': self.__version},
base_annotation=self.__class__.__name__,
check=self.__check,
comment=False,
devel_environment=self.environment_variables,
directory=self.__directory_c,
prefix=self.__prefix,
runtime_environment=self.environment_variables,
url=self.__url_c,
**kwargs)]
# Setup optional CXX build configuration
if self.__cxx:
comments.append('NetCDF C++ version {}'.format(self.__version_cxx))
self.__bb.append(generic_autotools(
annotations={'version': self.__version_cxx},