# IT4Innovations
# LK 2023

easyblock = 'EB_PSI'

name = 'PSI4'
version = '1.8.1'

homepage = 'https://www.psicode.org/'
description = """PSI4 is an open-source suite of ab initio quantum chemistry programs designed for
efficient, high-accuracy simulations of a variety of molecular properties. We can routinely perform
computations with more than 2500 basis functions running serially or in parallel.
"""

toolchain = {'name': 'foss', 'version': '2022b'}
toolchainopts = {'usempi': True}

source_urls = ['https://github.com/psi4/psi4/archive']
sources = ['v%(version)s.tar.gz']
patches = [
    'PSI4-%(version)s_fix_cmake_release.patch',
    'PSI4-%(version)s_fix_snsmp2_version.patch',
]
checksums = [
    'f1431a68fd67ae8c31fdb3a8c135061d148246b9687c80decdc1b7ad917fe80b',  # v1.8.1.tar.gz
    '4b9e7a4335cceae568f44bb3207b4c516ffa15afdee5d04fd855326c4a930710',  # PSI4-1.8.1_fix_cmake_release.patch
    '3000a33e65352ea42b83f52cba10dd96b872ce5b429272a787d5cbfd4c1a5186',  # PSI4-1.8.1_fix_snsmp2_version.patch
]

dependencies = [
    ('Python', '3.10.8'),
    ('libxc', '6.1.0'),
    ('CheMPS2', '1.8.12'),
    ('networkx', '3.1'),
    ('psutil', '5.9.5'),
    ('pytest', '7.2.2'),
    ('Boost', '1.81.0'),
]

builddependencies = [
    ('CMake', '3.24.3'),
    ('Eigen', '3.4.0'),
]

configopts = '-DENABLE_MPI=ON -DENABLE_PLUGINS=ON -DENABLE_XHOST=OFF '
#  Install python module to the standard location instead of lib
configopts += '-DPYMOD_INSTALL_LIBDIR=/python%(pyshortver)s/site-packages '
#  Add bundled (downloaded) packages
# -DENABLE_simint=ON does not work with intel/2018, so have to make with GCCcore
configopts += '-DENABLE_dkh=ON -DENABLE_gdma=ON -DENABLE_resp=ON -DENABLE_snsmp2=ON '
# allow PSI4 to download and build a forked version of PCMSolver otherwise tests fail
configopts += '-DENABLE_PCMSolver=ON '

# runtest uses ctest, and some of the tests have to be manually compared
# to the reference output (those tests are marked failed)
# After installing PSI4, you can test the package using psi4 --test command. (This uses pytest framework)
# runtest = '-L smoke'
runtest = False

exts_defaultclass = 'PythonPackage'
exts_filter = ("python -c 'import %(ext_name)s'", '')
exts_default_options = {
    'source_urls': [PYPI_SOURCE],
    'download_dep_fail': True,
    'use_pip': True,
}

exts_list = [
    ('typing_extensions', '4.5.0', {
        'checksums': ['5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb'],
    }),
    ('pydantic', '1.10.5', {
        'checksums': ['9e337ac83686645a46db0e825acceea8e02fca4062483f40e9ae178e8bd1103a'],
    }),
    ('Pint', '0.20.1', {
        'checksums': ['387cf04078dc7dfe4a708033baad54ab61d82ab06c4ee3d4922b1e45d5626067'],
    }),
    ('msgpack-python', '0.5.6', {
        'modulename': 'msgpack',
        'checksums': ['378cc8a6d3545b532dfd149da715abae4fda2a3adb6d74e525d0d5e51f46909b'],
    }),
    ('py-cpuinfo', '9.0.0', {
        'modulename': 'cpuinfo',
        'checksums': ['3cdbbf3fac90dc6f118bfd64384f309edeadd902d7c8fb17f02ffa1fc3f49690'],
    })
]

modextrapaths = {'PYTHONPATH': 'lib/python%(pyshortver)s/site-packages'}

sanity_check_commands = ["python -c 'import psi4'"]

moduleclass = 'chem'
