Skip to content

Commit

Permalink
Merge pull request #2486 from smoors/20210622134158_new_pr_GBkUEglHDL
Browse files Browse the repository at this point in the history
update Xmipp easyblock for new version (v3.20.07)
  • Loading branch information
boegel authored Jun 23, 2021
2 parents a74484d + 26b8fb3 commit 493de70
Showing 1 changed file with 47 additions and 12 deletions.
59 changes: 47 additions & 12 deletions easybuild/easyblocks/x/xmipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,38 @@ def __init__(self, *args, **kwargs):
"""Initialize Xmipp-specific variables."""
super(EB_Xmipp, self).__init__(*args, **kwargs)
self.xmipp_modules = ['xmippCore', 'xmipp', 'xmippViz']
self.srcdir = os.path.join(self.builddir, 'src')
self.cfg['start_dir'] = self.builddir
if LooseVersion(self.version) >= LooseVersion('3.20.07'):
self.cfg['start_dir'] = os.path.join(self.builddir, 'xmipp-' + self.version)
self.srcdir = os.path.join(self.cfg['start_dir'], 'src')
self.cfgfile = os.path.join(self.cfg['start_dir'], 'xmipp.conf')
self.xmipp_exe = './xmipp'
else:
self.cfg['start_dir'] = self.builddir
self.srcdir = os.path.join(self.builddir, 'src')
self.cfgfile = os.path.join(self.builddir, 'xmipp.conf')
self.xmipp_exe = os.path.join(self.srcdir, 'xmipp', 'xmipp')
self.use_cuda = False
self.cfgfile = os.path.join(self.builddir, 'xmipp.conf')

def extract_step(self):
"""Extract Xmipp sources."""
# Xmipp assumes that everything is unpacked in a "src" dir
mkdir(self.srcdir)
self.cfg.update('unpack_options', '--directory %s' % os.path.basename(self.srcdir))
if LooseVersion(self.version) < LooseVersion('3.20.07'):
# Xmipp < 3.20.07 assumes that everything is unpacked in a "src" dir
# Xmipp >= 3.20.07 assumes that everything is unpacked in the "src" dir of Xmipp itself
mkdir(self.srcdir)
self.cfg.update('unpack_options', '--directory %s' % os.path.basename(self.srcdir))
super(EB_Xmipp, self).extract_step()
for module in self.xmipp_modules:
symlink('%s-%s' % (module, self.version), os.path.join(self.srcdir, module), use_abspath_source=False)
if LooseVersion(self.version) >= LooseVersion('3.20.07') and module == 'xmipp':
pass
else:
symlink('%s-%s' % (module, self.version), os.path.join(self.srcdir, module), use_abspath_source=False)

def patch_step(self):
"""Patch files from self.srcdir dir."""
super(EB_Xmipp, self).patch_step(beginpath=self.srcdir)
if LooseVersion(self.version) >= LooseVersion('3.20.07'):
super(EB_Xmipp, self).patch_step()
else:
super(EB_Xmipp, self).patch_step(beginpath=self.srcdir)

def setup_xmipp_env(self):
"""Setup environment before running SCons."""
Expand All @@ -88,7 +103,7 @@ def configure_step(self):
# Initialize the config file and then patch it with the correct values
cmd = ' '.join([
self.cfg['preconfigopts'],
os.path.join(self.srcdir, 'xmipp', 'xmipp'),
self.xmipp_exe,
'config',
self.cfg['configopts'],
])
Expand All @@ -106,6 +121,16 @@ def configure_step(self):
'MPI_LINKERFORPROGRAMS': os.environ.get('MPICXX', 'UNKNOWN'),
}

if LooseVersion(self.version) >= LooseVersion('3.20.07'):
# Define include dirs with INCDIRFLAGS (Xmipp does not use CPPPATH directly)
incdirflags = os.getenv('INCDIRFLAGS', '')
incdirflags += '-I../ -I ' + ' -I'.join(os.environ['CPATH'].split(':'))
opencv_root = get_software_root('OpenCV')
if opencv_root:
incdirflags += ' -I' + opencv_root + '/include/opencv4'
# env.setvar('INCDIRFLAGS', incdirflags)
params['INCDIRFLAGS'] = incdirflags

deps = [
# Name of dependency, name of env var to set, required or not
('HDF5', None, True),
Expand All @@ -122,8 +147,9 @@ def configure_step(self):
params.update({'CUDA_LIB': os.path.join(cuda_root, 'lib64')})
params.update({'NVCC': os.environ['CUDA_CXX']})
# Their default for NVCC is to use g++-5, fix that
nvcc_flags = '--x cu -D_FORCE_INLINES -Xcompiler -fPIC '
nvcc_flags = nvcc_flags + '-Wno-deprecated-gpu-targets -std=c++11'
nvcc_flags = '-v --x cu -D_FORCE_INLINES -Xcompiler -fPIC -Wno-deprecated-gpu-targets -std=c++11'
if LooseVersion(self.version) >= LooseVersion('3.20.07'):
nvcc_flags += ' --extended-lambda'
params.update({'NVCC_CXXFLAGS': nvcc_flags})
self.use_cuda = True

Expand All @@ -134,6 +160,11 @@ def configure_step(self):
if len(matches) == 1:
cufft = os.path.basename(matches[0])
symlink(cufft, os.path.join(self.srcdir, 'cuFFTAdvisor'), use_abspath_source=False)
if LooseVersion(self.version) >= LooseVersion('3.20.07'):
symlink(
os.path.join(self.srcdir, cufft),
os.path.join(self.srcdir, 'xmipp', 'external', 'cuFFTAdvisor')
)
else:
raise EasyBuildError("Failed to isolate path to cuFFTAdvisor-*: %s", matches)

Expand Down Expand Up @@ -220,7 +251,7 @@ def install_step(self):
# to replicate here.
cmd = ' '.join([
self.cfg['preinstallopts'],
os.path.join(self.srcdir, 'xmipp', 'xmipp'),
self.xmipp_exe,
'install',
self.installdir,
self.cfg['installopts'],
Expand All @@ -238,9 +269,13 @@ def sanity_check_step(self):

bins = ['xmipp_%s' % x for x in ['angular_rotate', 'classify_kerdensom', 'mpi_ml_refine3d']]
libs = ['XmippCore', 'XmippJNI', 'XmippParallel', 'Xmipp']
cuda_root = get_software_root('CUDA')
if cuda_root:
libs.append('cuFFTAdvisor')
custom_paths = {
'files': [os.path.join('bin', x) for x in bins] +
[os.path.join('bindings', 'python', 'xmippViz.py')] +
[os.path.join('bindings', 'java', 'lib', 'XmippJNI.jar')] +
[os.path.join('lib', 'lib%s.%s') % (x, shlib_ext) for x in libs],
'dirs': ['resources'],
}
Expand Down

0 comments on commit 493de70

Please sign in to comment.