libyogrt: add lsf scheduler support, create yogrt.conf file (#19960)

Tell the libyogrt installer to create a yogrt.conf file, specifying whatever 
scheduler was specified in the scheduler=XXX parameter.
This commit is contained in:
Robert Brunner 2021-01-19 03:01:48 -06:00 committed by GitHub
parent 86e9d93859
commit 91f65b9772
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import os
class Libyogrt(AutotoolsPackage):
@ -33,12 +34,15 @@ class Libyogrt(AutotoolsPackage):
variant('scheduler', default='system',
description="Select scheduler integration",
values=['system', 'slurm'], multi=False)
values=['system', 'slurm', 'lsf'], multi=False)
depends_on('slurm', when='scheduler=slurm')
depends_on('lsf', when='scheduler=lsf')
conflicts('scheduler=lsf', when='@:1.22')
variant('static', default='False',
description="build static library")
depends_on('slurm', when='scheduler=slurm')
def url_for_version(self, version):
if version < Version(1.21):
return "https://github.com/LLNL/libyogrt/archive/%s.tar.gz" % version
@ -49,10 +53,37 @@ def configure_args(self):
args = []
sched = self.spec.variants['scheduler'].value
if sched != "system":
if sched == "lsf":
# The LSF library depends on a couple of other libraries,
# and running the build inside of spack does not find
# them, and the user has to add them when they want
# to use -lyogrt. If we explicitly tell it what libraries
# to use, the user does not need to specify them
args.append('--with-lsf')
args.append('LIBS=-llsf -lrt -lnsl')
elif sched != "system":
args.append('--with-%s=%s' % (sched, self.spec[sched].prefix))
if '+static' in self.spec:
args.append('--enable-static=yes')
return args
@run_after('install')
def create_yogrt_conf(self):
etcpath = os.path.join(prefix, "etc")
# create subdirectory to hold yogrt.conf file
if not os.path.isdir(etcpath):
mode = 0o755
os.mkdir(etcpath, mode)
# if no scheduler is specified, create yogrt conf file
# with backend=none
sched = self.spec.variants['scheduler'].value
if sched == "system":
sched = "none"
# create conf file to inform libyogrt about job scheduler
with open(os.path.join(etcpath, "yogrt.conf"), "w+") as f:
f.write("backend=%s\n" % sched)