Skip to content

{vis}[foss/2023] IMOD v4.12.62 w/ CUDA 12.1.1#20555

Closed
ThomasHoffmann77 wants to merge 5 commits intoeasybuilders:developfrom
ThomasHoffmann77:20240517170220_new_pr_IMOD41262
Closed

{vis}[foss/2023] IMOD v4.12.62 w/ CUDA 12.1.1#20555
ThomasHoffmann77 wants to merge 5 commits intoeasybuilders:developfrom
ThomasHoffmann77:20240517170220_new_pr_IMOD41262

Conversation

@ThomasHoffmann77
Copy link
Copy Markdown
Contributor

(created using eb --new-pr)

Comment on lines +19 to +26
# download manually from mercurial repository and create source tarball:
# hg clone --debug http://bio3d.colorado.edu/imod/nightlyBuilds/IMOD
# get lunch
# cd IMOD
# hg update -r IMOD_4-12-62
# rm .hg* -rf
# cd ..
# find IMOD -print|sort| tar -czf IMOD-`cat IMOD/.version`.tar.gz -T -
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use download_instructions here, see for example #19884

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boegel how to use EasyBuild's sources archive?
https://bio3d.colorado.edu/imod/COPYRIGHT.txt: "... All portions of IMOD, except as noted below, are open source under the General Public License (GPL) version 2.0. ..."

@boegel
Copy link
Copy Markdown
Member

boegel commented May 22, 2024

Test report by @boegel
SUCCESS
Build succeeded for 1 out of 1 (1 easyconfigs in total)
node4006.donphan.os - Linux RHEL 8.8, x86_64, Intel(R) Xeon(R) Gold 6240 CPU @ 2.60GHz (cascadelake), 1 x NVIDIA NVIDIA A2, 545.23.08, Python 3.6.8
See https://gist.github.com/boegel/7af93b650a3b83644c139ff79c4fb9d8 for a full test report.

@ThomasHoffmann77 ThomasHoffmann77 requested a review from boegel May 31, 2024 08:17
set IMOD_JAVADIR in modXXXfooter
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 9, 2025

Updated software IMOD-4.12.62-foss-2023a-CUDA-12.1.1.eb

Diff against IMOD-4.11.5-fosscuda-2020b.eb

easybuild/easyconfigs/i/IMOD/IMOD-4.11.5-fosscuda-2020b.eb

diff --git a/easybuild/easyconfigs/i/IMOD/IMOD-4.11.5-fosscuda-2020b.eb b/easybuild/easyconfigs/i/IMOD/IMOD-4.12.62-foss-2023a-CUDA-12.1.1.eb
index 1f1c6e82c8..bf7aeee083 100644
--- a/easybuild/easyconfigs/i/IMOD/IMOD-4.11.5-fosscuda-2020b.eb
+++ b/easybuild/easyconfigs/i/IMOD/IMOD-4.12.62-foss-2023a-CUDA-12.1.1.eb
@@ -1,8 +1,8 @@
-# Thomas Hoffmann, EMBL Heidelberg, structures-it@embl.de, 2021/04
 easyblock = 'ConfigureMake'
 
 name = 'IMOD'
-version = '4.11.5'
+version = '4.12.62'
+versionsuffix = '-CUDA-%(cudaver)s'
 
 homepage = 'https://bio3d.colorado.edu/imod/'
 description = """IMOD is a set of image processing, modeling and display
@@ -13,94 +13,120 @@ data from any orientation, and modeling and display of the image files. IMOD
 was developed primarily by David Mastronarde, Rick Gaudette, Sue Held, Jim
 Kremer, Quanren Xiong, and John Heumann at the University of Colorado."""
 
-toolchain = {'name': 'fosscuda', 'version': '2020b'}
-toolchainopts = {'pic': True, 'openmp': True}
-# default CUDA compute capabilities to use (override via --cuda-compute-capabilities)
-cuda_compute_capabilities = ['3.5', '5.0', '6.0', '7.0', '7.5', '8.0', '8.6']
-
-# download manually from mercurial repository and create source tarball:
-# hg clone --debug http://bio3d.colorado.edu/imod/nightlyBuilds/IMOD
-# get lunch 
-# cd IMOD
-# hg update -r IMOD_4-11-5
-# cd ..
-# tar czf IMOD-4.11.5.tar.gz IMOD
+toolchain = {'name': 'foss', 'version': '2023a'}
+toolchainopts = {'pic': True}  # openmp leads to segfault with xftoxg tool
+
+download_instructions = f"""{name} requires manual download from  mercurial repository:
+ hg clone --debug http://bio3d.colorado.edu/imod/nightlyBuilds/IMOD
+ cd IMOD
+ hg update -r IMOD_%s
+ rm .hg* -rf
+ cd ..
+ find IMOD -print|sort| tar -czf IMOD-`cat IMOD/.version`.tar.gz -T -
+""" % version.replace('.', '-')
+
 sources = [SOURCE_TAR_GZ]
-# can't include a valid checksum, since tarball has to be created manually
-patches = ['IMOD-%(version)s_fix-csvtohtml-py3.patch']
+patches = [
+    'IMOD-4.11.12_hdf1.12.patch',
+    'IMOD-4.12.17_tiltalign_include.patch',
+    # replace hardcoded CUDA compute capabilitites in machines/rhlinux. set as CUDACC:
+    'IMOD-4.12.58_cudacc.patch',
+]
 checksums = [
-    # can't include a valid checksum for source tarball, since it has to be created manually
-    None,  # IMOD-4.11.5.tar.gz
-    '8ba0c3cbe30d755ab3fb918688982e818795b9f7f41218bd6bf231c85bea4971',  # IMOD-4.11.5_fix-csvtohtml-py3.patch
+    # IMOD-4.12.62.tar.gz: 
+    None,  # can't include a valid checksum for source tarball, since it has to be created manually
+    # IMOD-4.11.12_hdf1.12.patch:
+    '19e5bff97b997c600f157dd56eddae96a7f34fef528e7f40e76ea8e19144810e',
+    # IMOD-4.12.17_tiltalign_include.patch: 
+    '998c01a4f78b0d48dbffc530fcb12faaa892b1d322bce4f1643df20799845ab7',
+    # IMOD-4.12.58_cudacc.patch:
+    '9563b1ac9ab1569689d7db4380301f330290d9695988f8b31e7ea08d2601ee25',
 ]
 
+builddependencies = [('groff', '1.22.4')]
+
 dependencies = [
-    ('LibTIFF', '4.1.0'),
-    ('Qt5', '5.14.2'),
+    ('LibTIFF', '4.5.0'),
+    ('Qt5', '5.15.10'),
     ('Java', '11', '', SYSTEM),
-    ('HDF5', '1.10.7'),
-    ('Python', '3.8.6'),
+    ('HDF5', '1.14.0'),
+    ('Python', '3.11.3'),
+    ('libGLU', '9.0.3'),
+    ('tcsh', '6.24.10'),
+    ('CUDA', '12.1.1', '', SYSTEM),
+    ('UCX-CUDA', '1.14.1', versionsuffix),
 ]
 
 # parallel build sometimes fails
 parallel = 1
 
-# replace hardcoded CUDA compute capabilitites in machines/rhlinux. 
-local_cuda_replace = 'echo %(cuda_cc_space_sep)s|sed "s/\\.//g"|'
-local_cuda_replace += '   awk \'{'
-local_cuda_replace += '          printf "-arch sm_"$1; '
-local_cuda_replace += '          for (i=1;i<=NF; i++){printf(" -gencode=arch=compute_%s,code=sm_%s",$i,$i) } '
-local_cuda_replace += '   }\''
-local_cudaarch_sed = 'sed -i "s/-arch sm_35/`' + local_cuda_replace + '`/g" machines/rhlinux &&'
-
 # modify all qmake pro files in order to pass CFLAGS
-local_qmake_pass_cflags = "find -name *.pro -exec sed -i -e '$aQMAKE_CXXFLAGS += $$(CFLAGS)' {} \\; &&"
+_qmake_pass_cflags = "find -name *.pro -exec sed -i -e '$aQMAKE_CXXFLAGS += $$(CFLAGS)' {} \\; && "
 
 # exports required for configure and build
-local_exports = 'export QTDIR=$EBROOTQT5 &&'
-local_exports += 'export HDF5_DIR=$EBROOTHDF5 &&'
-local_exports += 'export QMAKESPEC=$EBROOTQT5/mkspecs/`qmake -query QMAKE_SPEC` &&'
-local_exports += 'export CUDA_DIR=$CUDA_HOME &&'
+_exports = 'export QTDIR=$EBROOTQT5 && '
+_exports += "export CUDACC='%(cuda_cc_cmake)s' && "
+_exports += 'export HDF5_DIR=$EBROOTHDF5 && '
+_exports += 'export QMAKESPEC=$EBROOTQT5/mkspecs/`qmake -query QMAKE_SPEC` && '
+_exports += 'export CUDA_DIR=$CUDA_HOME && '
 #  readw_or_imod.f and others with gfortran10: 
 #     Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/INTEGER(2))
 #     => set -fallow-argument-mismatch. Runs through without this option with GCC 8.3.0.
-local_exports += 'export CFLAGS="$CFLAGS -fallow-argument-mismatch" &&'  # required for gfortran10
+_exports += 'export CFLAGS="$CFLAGS -fallow-argument-mismatch" && '  # required for gfortran10
+
+# rename pysrc/pip.py to pysrc/PIP.py
+_renamePip = """sed -i 's/from pip/from PIP/g' pysrc/* &&"""
+_renamePip += """mv pysrc/pip.py pysrc/PIP.py &&"""
+_renamePip += """sed -i 's/pip.py/PIP.py/g' pysrc/Makefile &&"""
+
+_useTcsh = 'sed -i "s|#!/bin/csh -f|#!/usr/bin/env tcsh|g;s|#! /bin/csh -f|#!/usr/bin/env tcsh|g" '
+_useTcsh += ' %(builddir)s/IMOD/{manpages/convert,setup,setup2,machines/rhlinux,packMacApps} &&'
 
-preconfigopts = local_exports
-preconfigopts += local_cudaarch_sed
-preconfigopts += local_qmake_pass_cflags
+preconfigopts = _exports
+preconfigopts += _renamePip
+preconfigopts += _qmake_pass_cflags
+preconfigopts += _useTcsh
 
 # IMOD's configure script is named setup and does not know the parameter --prefix, but -i. 
 # CFLAGs are passed with -flags.
 configure_cmd = './setup '
+configure_cmd += '-c gnu '  # htf it finds icc?
 configure_cmd += '-flags "$CFLAGS" '    # inject CFLAGS
 configure_cmd += '-i %(installdir)s '  # set installdir
-configure_cmd += ' #'  # avoid passing unknown arg --prefix
+configure_without_installdir = True
 
-prebuildopts = local_exports
+prebuildopts = _exports
 
 # create some missing directories required for installation process:
-preinstallopts = 'mkdir %(installdir)s/{man/cat1,bin,autodoc,SystemTemplate,lib/imodplug,com,html,Plugins} -p &&'
+preinstallopts = 'mkdir %(installdir)s/{man/cat1,bin,autodoc,SystemTemplate,lib/imodplug,com,html,Plugins} -p && '
 
 # patch hardcoded /usr/bin/python to use Python included as dependency
 preinstallopts += "find pysrc -name '*.py' | xargs sed -i 's@^#!/usr/bin/python@#!/usr/bin/env python@g' && "
+preinstallopts += "export PYTHONPATH=%(builddir)s/IMOD/pysrc:$PYTHONPATH && "
 preinstallopts += "ls manpages/{csvtohtml,adocdefaults} | xargs sed -i 's@^#!.*/python -u@#!/usr/bin/env python@g' && "
 preinstallopts += "xargs sed -i 's@^#!.*/python -u@#!/usr/bin/env python@g' html/makeqhp && "
 
+modextrapaths = {'PYTHONPATH': 'pylib'}
+
 modextravars = {
     'IMOD_DIR': "%(installdir)s",
     'IMOD_PLUGIN_DIR': '%(installdir)s/lib/imodplug',
-    'IMOD_JAVADIR': '$JAVA_HOME',
     'FOR_DISABLE_STACK_TRACE': '1',
 }
+
+modluafooter = """
+setenv("IMOD_JAVADIR", os.getenv("JAVA_HOME"))
+"""
+
+modtclfooter = """
+setenv IMOD_JAVADIR $::env(JAVA_HOME)
+"""
+
+
 modloadmsg = 'Please set the environment variable $IMOD_CALIB_DIR if appropriate.'
-# Observed problems with alias on a tcl based module system. Use bin/subm python script instead.
-# modaliases = {
-#     'subm': 'submfg $* &'
-# }
 sanity_check_paths = {
     'files': ['VERSION', 'bin/subm'],
     'dirs': ['bin', 'lib', 'com', 'autodoc', 'pylib', 'Plugins', 'man', 'SystemTemplate'],
 }
-
+sanity_check_commands = [('xftoxg', '-h')]
 moduleclass = 'vis'
Diff against IMOD-4.11.5-foss-2020b.eb

easybuild/easyconfigs/i/IMOD/IMOD-4.11.5-foss-2020b.eb

diff --git a/easybuild/easyconfigs/i/IMOD/IMOD-4.11.5-foss-2020b.eb b/easybuild/easyconfigs/i/IMOD/IMOD-4.12.62-foss-2023a-CUDA-12.1.1.eb
index d3a1580f52..bf7aeee083 100644
--- a/easybuild/easyconfigs/i/IMOD/IMOD-4.11.5-foss-2020b.eb
+++ b/easybuild/easyconfigs/i/IMOD/IMOD-4.12.62-foss-2023a-CUDA-12.1.1.eb
@@ -1,8 +1,8 @@
-# Thomas Hoffmann, EMBL Heidelberg, structures-it@embl.de, 2021/04
 easyblock = 'ConfigureMake'
 
 name = 'IMOD'
-version = '4.11.5'
+version = '4.12.62'
+versionsuffix = '-CUDA-%(cudaver)s'
 
 homepage = 'https://bio3d.colorado.edu/imod/'
 description = """IMOD is a set of image processing, modeling and display
@@ -13,81 +13,120 @@ data from any orientation, and modeling and display of the image files. IMOD
 was developed primarily by David Mastronarde, Rick Gaudette, Sue Held, Jim
 Kremer, Quanren Xiong, and John Heumann at the University of Colorado."""
 
-toolchain = {'name': 'foss', 'version': '2020b'}
-toolchainopts = {'pic': True, 'openmp': True}
+toolchain = {'name': 'foss', 'version': '2023a'}
+toolchainopts = {'pic': True}  # openmp leads to segfault with xftoxg tool
+
+download_instructions = f"""{name} requires manual download from  mercurial repository:
+ hg clone --debug http://bio3d.colorado.edu/imod/nightlyBuilds/IMOD
+ cd IMOD
+ hg update -r IMOD_%s
+ rm .hg* -rf
+ cd ..
+ find IMOD -print|sort| tar -czf IMOD-`cat IMOD/.version`.tar.gz -T -
+""" % version.replace('.', '-')
 
-# download manually from mercurial repository and create source tarball:
-# hg clone --debug http://bio3d.colorado.edu/imod/nightlyBuilds/IMOD
-# get lunch 
-# cd IMOD
-# hg update -r IMOD_4-11-5
-# cd ..
-# tar czf IMOD-4.11.5.tar.gz IMOD
 sources = [SOURCE_TAR_GZ]
-patches = ['IMOD-%(version)s_fix-csvtohtml-py3.patch']
+patches = [
+    'IMOD-4.11.12_hdf1.12.patch',
+    'IMOD-4.12.17_tiltalign_include.patch',
+    # replace hardcoded CUDA compute capabilitites in machines/rhlinux. set as CUDACC:
+    'IMOD-4.12.58_cudacc.patch',
+]
 checksums = [
-    # can't include a valid checksum for source tarball, since it has to be created manually
-    None,  # IMOD-4.11.5.tar.gz
-    '8ba0c3cbe30d755ab3fb918688982e818795b9f7f41218bd6bf231c85bea4971',  # IMOD-4.11.5_fix-csvtohtml-py3.patch
+    # IMOD-4.12.62.tar.gz: 
+    None,  # can't include a valid checksum for source tarball, since it has to be created manually
+    # IMOD-4.11.12_hdf1.12.patch:
+    '19e5bff97b997c600f157dd56eddae96a7f34fef528e7f40e76ea8e19144810e',
+    # IMOD-4.12.17_tiltalign_include.patch: 
+    '998c01a4f78b0d48dbffc530fcb12faaa892b1d322bce4f1643df20799845ab7',
+    # IMOD-4.12.58_cudacc.patch:
+    '9563b1ac9ab1569689d7db4380301f330290d9695988f8b31e7ea08d2601ee25',
 ]
 
+builddependencies = [('groff', '1.22.4')]
+
 dependencies = [
-    ('LibTIFF', '4.1.0'),
-    ('Qt5', '5.14.2'),
+    ('LibTIFF', '4.5.0'),
+    ('Qt5', '5.15.10'),
     ('Java', '11', '', SYSTEM),
-    ('HDF5', '1.10.7'),
-    ('Python', '3.8.6'),
+    ('HDF5', '1.14.0'),
+    ('Python', '3.11.3'),
+    ('libGLU', '9.0.3'),
+    ('tcsh', '6.24.10'),
+    ('CUDA', '12.1.1', '', SYSTEM),
+    ('UCX-CUDA', '1.14.1', versionsuffix),
 ]
 
 # parallel build sometimes fails
 parallel = 1
 
 # modify all qmake pro files in order to pass CFLAGS
-local_qmake_pass_cflags = "find -name *.pro -exec sed -i -e '$aQMAKE_CXXFLAGS += $$(CFLAGS)' {} \\; &&"
+_qmake_pass_cflags = "find -name *.pro -exec sed -i -e '$aQMAKE_CXXFLAGS += $$(CFLAGS)' {} \\; && "
 
 # exports required for configure and build
-local_exports = 'export QTDIR=$EBROOTQT5 &&'
-local_exports += 'export HDF5_DIR=$EBROOTHDF5 &&'
-local_exports += 'export QMAKESPEC=$EBROOTQT5/mkspecs/`qmake -query QMAKE_SPEC` &&'
+_exports = 'export QTDIR=$EBROOTQT5 && '
+_exports += "export CUDACC='%(cuda_cc_cmake)s' && "
+_exports += 'export HDF5_DIR=$EBROOTHDF5 && '
+_exports += 'export QMAKESPEC=$EBROOTQT5/mkspecs/`qmake -query QMAKE_SPEC` && '
+_exports += 'export CUDA_DIR=$CUDA_HOME && '
 #  readw_or_imod.f and others with gfortran10: 
 #     Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/INTEGER(2))
 #     => set -fallow-argument-mismatch. Runs through without this option with GCC 8.3.0.
-local_exports += 'export CFLAGS="$CFLAGS -fallow-argument-mismatch" &&'  # required for gfortran10
+_exports += 'export CFLAGS="$CFLAGS -fallow-argument-mismatch" && '  # required for gfortran10
 
-preconfigopts = local_exports
-preconfigopts += local_qmake_pass_cflags
+# rename pysrc/pip.py to pysrc/PIP.py
+_renamePip = """sed -i 's/from pip/from PIP/g' pysrc/* &&"""
+_renamePip += """mv pysrc/pip.py pysrc/PIP.py &&"""
+_renamePip += """sed -i 's/pip.py/PIP.py/g' pysrc/Makefile &&"""
+
+_useTcsh = 'sed -i "s|#!/bin/csh -f|#!/usr/bin/env tcsh|g;s|#! /bin/csh -f|#!/usr/bin/env tcsh|g" '
+_useTcsh += ' %(builddir)s/IMOD/{manpages/convert,setup,setup2,machines/rhlinux,packMacApps} &&'
+
+preconfigopts = _exports
+preconfigopts += _renamePip
+preconfigopts += _qmake_pass_cflags
+preconfigopts += _useTcsh
 
 # IMOD's configure script is named setup and does not know the parameter --prefix, but -i. 
 # CFLAGs are passed with -flags.
 configure_cmd = './setup '
+configure_cmd += '-c gnu '  # htf it finds icc?
 configure_cmd += '-flags "$CFLAGS" '    # inject CFLAGS
 configure_cmd += '-i %(installdir)s '  # set installdir
-configure_cmd += ' #'  # avoid passing unknown arg --prefix
+configure_without_installdir = True
 
-prebuildopts = local_exports
+prebuildopts = _exports
 
 # create some missing directories required for installation process:
 preinstallopts = 'mkdir %(installdir)s/{man/cat1,bin,autodoc,SystemTemplate,lib/imodplug,com,html,Plugins} -p && '
 
 # patch hardcoded /usr/bin/python to use Python included as dependency
 preinstallopts += "find pysrc -name '*.py' | xargs sed -i 's@^#!/usr/bin/python@#!/usr/bin/env python@g' && "
+preinstallopts += "export PYTHONPATH=%(builddir)s/IMOD/pysrc:$PYTHONPATH && "
 preinstallopts += "ls manpages/{csvtohtml,adocdefaults} | xargs sed -i 's@^#!.*/python -u@#!/usr/bin/env python@g' && "
 preinstallopts += "xargs sed -i 's@^#!.*/python -u@#!/usr/bin/env python@g' html/makeqhp && "
 
+modextrapaths = {'PYTHONPATH': 'pylib'}
+
 modextravars = {
     'IMOD_DIR': "%(installdir)s",
     'IMOD_PLUGIN_DIR': '%(installdir)s/lib/imodplug',
-    'IMOD_JAVADIR': '$JAVA_HOME',
     'FOR_DISABLE_STACK_TRACE': '1',
 }
+
+modluafooter = """
+setenv("IMOD_JAVADIR", os.getenv("JAVA_HOME"))
+"""
+
+modtclfooter = """
+setenv IMOD_JAVADIR $::env(JAVA_HOME)
+"""
+
+
 modloadmsg = 'Please set the environment variable $IMOD_CALIB_DIR if appropriate.'
-# Observed problems with alias on a tcl based module system. Use bin/subm python script instead.
-# modaliases = {
-#     'subm': 'submfg $* &'
-# }
 sanity_check_paths = {
     'files': ['VERSION', 'bin/subm'],
     'dirs': ['bin', 'lib', 'com', 'autodoc', 'pylib', 'Plugins', 'man', 'SystemTemplate'],
 }
-
+sanity_check_commands = [('xftoxg', '-h')]
 moduleclass = 'vis'
Diff against IMOD-4.7.15_RHEL6-64_CUDA6.0.eb

easybuild/easyconfigs/i/IMOD/IMOD-4.7.15_RHEL6-64_CUDA6.0.eb

diff --git a/easybuild/easyconfigs/i/IMOD/IMOD-4.7.15_RHEL6-64_CUDA6.0.eb b/easybuild/easyconfigs/i/IMOD/IMOD-4.12.62-foss-2023a-CUDA-12.1.1.eb
index a1c29d2be5..bf7aeee083 100644
--- a/easybuild/easyconfigs/i/IMOD/IMOD-4.7.15_RHEL6-64_CUDA6.0.eb
+++ b/easybuild/easyconfigs/i/IMOD/IMOD-4.12.62-foss-2023a-CUDA-12.1.1.eb
@@ -1,13 +1,10 @@
-# This file is an EasyBuild reciPY as per https://github.com/easybuilders/easybuild
-# authors:
-# * Pablo Escobar Lopez (sciCORE - University of Basel - SIB Swiss Institute of Bioinformatics)
-# * Benjamin Roberts (Landcare Research NZ Ltd)
+easyblock = 'ConfigureMake'
 
 name = 'IMOD'
-version = '4.7.15'
-versionsuffix = '_RHEL6-64_CUDA6.0'
+version = '4.12.62'
+versionsuffix = '-CUDA-%(cudaver)s'
 
-homepage = 'http://bio3d.colorado.edu/imod/'
+homepage = 'https://bio3d.colorado.edu/imod/'
 description = """IMOD is a set of image processing, modeling and display
 programs used for tomographic reconstruction and for 3D reconstruction of EM
 serial sections and optical sections. The package contains tools for assembling
@@ -16,14 +13,120 @@ data from any orientation, and modeling and display of the image files. IMOD
 was developed primarily by David Mastronarde, Rick Gaudette, Sue Held, Jim
 Kremer, Quanren Xiong, and John Heumann at the University of Colorado."""
 
-toolchain = SYSTEM
+toolchain = {'name': 'foss', 'version': '2023a'}
+toolchainopts = {'pic': True}  # openmp leads to segfault with xftoxg tool
 
-source_urls = ['http://bio3d.colorado.edu/imod/AMD64-RHEL5/']
-sources = ['%(namelower)s_%(version)s%(versionsuffix)s.csh']
+download_instructions = f"""{name} requires manual download from  mercurial repository:
+ hg clone --debug http://bio3d.colorado.edu/imod/nightlyBuilds/IMOD
+ cd IMOD
+ hg update -r IMOD_%s
+ rm .hg* -rf
+ cd ..
+ find IMOD -print|sort| tar -czf IMOD-`cat IMOD/.version`.tar.gz -T -
+""" % version.replace('.', '-')
+
+sources = [SOURCE_TAR_GZ]
+patches = [
+    'IMOD-4.11.12_hdf1.12.patch',
+    'IMOD-4.12.17_tiltalign_include.patch',
+    # replace hardcoded CUDA compute capabilitites in machines/rhlinux. set as CUDACC:
+    'IMOD-4.12.58_cudacc.patch',
+]
+checksums = [
+    # IMOD-4.12.62.tar.gz: 
+    None,  # can't include a valid checksum for source tarball, since it has to be created manually
+    # IMOD-4.11.12_hdf1.12.patch:
+    '19e5bff97b997c600f157dd56eddae96a7f34fef528e7f40e76ea8e19144810e',
+    # IMOD-4.12.17_tiltalign_include.patch: 
+    '998c01a4f78b0d48dbffc530fcb12faaa892b1d322bce4f1643df20799845ab7',
+    # IMOD-4.12.58_cudacc.patch:
+    '9563b1ac9ab1569689d7db4380301f330290d9695988f8b31e7ea08d2601ee25',
+]
+
+builddependencies = [('groff', '1.22.4')]
 
 dependencies = [
-    ('CUDA', '6.0.37'),
-    ('Java', '1.7.0_80'),
+    ('LibTIFF', '4.5.0'),
+    ('Qt5', '5.15.10'),
+    ('Java', '11', '', SYSTEM),
+    ('HDF5', '1.14.0'),
+    ('Python', '3.11.3'),
+    ('libGLU', '9.0.3'),
+    ('tcsh', '6.24.10'),
+    ('CUDA', '12.1.1', '', SYSTEM),
+    ('UCX-CUDA', '1.14.1', versionsuffix),
 ]
 
+# parallel build sometimes fails
+parallel = 1
+
+# modify all qmake pro files in order to pass CFLAGS
+_qmake_pass_cflags = "find -name *.pro -exec sed -i -e '$aQMAKE_CXXFLAGS += $$(CFLAGS)' {} \\; && "
+
+# exports required for configure and build
+_exports = 'export QTDIR=$EBROOTQT5 && '
+_exports += "export CUDACC='%(cuda_cc_cmake)s' && "
+_exports += 'export HDF5_DIR=$EBROOTHDF5 && '
+_exports += 'export QMAKESPEC=$EBROOTQT5/mkspecs/`qmake -query QMAKE_SPEC` && '
+_exports += 'export CUDA_DIR=$CUDA_HOME && '
+#  readw_or_imod.f and others with gfortran10: 
+#     Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/INTEGER(2))
+#     => set -fallow-argument-mismatch. Runs through without this option with GCC 8.3.0.
+_exports += 'export CFLAGS="$CFLAGS -fallow-argument-mismatch" && '  # required for gfortran10
+
+# rename pysrc/pip.py to pysrc/PIP.py
+_renamePip = """sed -i 's/from pip/from PIP/g' pysrc/* &&"""
+_renamePip += """mv pysrc/pip.py pysrc/PIP.py &&"""
+_renamePip += """sed -i 's/pip.py/PIP.py/g' pysrc/Makefile &&"""
+
+_useTcsh = 'sed -i "s|#!/bin/csh -f|#!/usr/bin/env tcsh|g;s|#! /bin/csh -f|#!/usr/bin/env tcsh|g" '
+_useTcsh += ' %(builddir)s/IMOD/{manpages/convert,setup,setup2,machines/rhlinux,packMacApps} &&'
+
+preconfigopts = _exports
+preconfigopts += _renamePip
+preconfigopts += _qmake_pass_cflags
+preconfigopts += _useTcsh
+
+# IMOD's configure script is named setup and does not know the parameter --prefix, but -i. 
+# CFLAGs are passed with -flags.
+configure_cmd = './setup '
+configure_cmd += '-c gnu '  # htf it finds icc?
+configure_cmd += '-flags "$CFLAGS" '    # inject CFLAGS
+configure_cmd += '-i %(installdir)s '  # set installdir
+configure_without_installdir = True
+
+prebuildopts = _exports
+
+# create some missing directories required for installation process:
+preinstallopts = 'mkdir %(installdir)s/{man/cat1,bin,autodoc,SystemTemplate,lib/imodplug,com,html,Plugins} -p && '
+
+# patch hardcoded /usr/bin/python to use Python included as dependency
+preinstallopts += "find pysrc -name '*.py' | xargs sed -i 's@^#!/usr/bin/python@#!/usr/bin/env python@g' && "
+preinstallopts += "export PYTHONPATH=%(builddir)s/IMOD/pysrc:$PYTHONPATH && "
+preinstallopts += "ls manpages/{csvtohtml,adocdefaults} | xargs sed -i 's@^#!.*/python -u@#!/usr/bin/env python@g' && "
+preinstallopts += "xargs sed -i 's@^#!.*/python -u@#!/usr/bin/env python@g' html/makeqhp && "
+
+modextrapaths = {'PYTHONPATH': 'pylib'}
+
+modextravars = {
+    'IMOD_DIR': "%(installdir)s",
+    'IMOD_PLUGIN_DIR': '%(installdir)s/lib/imodplug',
+    'FOR_DISABLE_STACK_TRACE': '1',
+}
+
+modluafooter = """
+setenv("IMOD_JAVADIR", os.getenv("JAVA_HOME"))
+"""
+
+modtclfooter = """
+setenv IMOD_JAVADIR $::env(JAVA_HOME)
+"""
+
+
+modloadmsg = 'Please set the environment variable $IMOD_CALIB_DIR if appropriate.'
+sanity_check_paths = {
+    'files': ['VERSION', 'bin/subm'],
+    'dirs': ['bin', 'lib', 'com', 'autodoc', 'pylib', 'Plugins', 'man', 'SystemTemplate'],
+}
+sanity_check_commands = [('xftoxg', '-h')]
 moduleclass = 'vis'

@jfgrimm
Copy link
Copy Markdown
Member

jfgrimm commented Jun 17, 2025

closing in favour of #21753

@jfgrimm jfgrimm closed this Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants