diff --git a/cmake/ase.cmake b/cmake/ase.cmake index baf480e..c8ced54 100644 --- a/cmake/ase.cmake +++ b/cmake/ase.cmake @@ -13,19 +13,22 @@ # limitations under the License. include_guard() -include(python/python) -#[[[ Determines if ASE is installed. -# -# At present FriendZone can not install -#]] -function(find_ase) - assert_python_module("ase") - message("Found ASE: ${ASE_FOUND}") -endfunction() +if("${BUILD_PYBIND11_PYBINDINGS}") + include(python/python) + + #[[[ Determines if ASE is installed. + # + # At present FriendZone can not install + #]] + function(find_ase) + assert_python_module("ase") + message("Found ASE: ${ASE_FOUND}") + endfunction() -if("${ENABLE_ASE}") - find_ase() + if("${ENABLE_ASE}") + find_ase() + endif() endif() add_library(ase INTERFACE) diff --git a/cmake/nwchem.cmake b/cmake/nwchem.cmake index 072d946..c5ab929 100644 --- a/cmake/nwchem.cmake +++ b/cmake/nwchem.cmake @@ -13,22 +13,25 @@ # limitations under the License. include_guard() -include(python/python) -#[[[ Determines if NWChem and the necessary Python interface are installed. -# -# At present FriendZone can not install -#]] -function(find_nwchem) - find_program(NWCHEM_FOUND nwchem REQUIRED) - assert_python_module("qcelemental") - assert_python_module("qcengine") - assert_python_module("networkx") - message("Found nwchem: ${NWCHEM_FOUND}") -endfunction() +if("${BUILD_PYBIND11_PYBINDINGS}") + include(python/python) + + #[[[ Determines if NWChem and the necessary Python interface are installed. + # + # At present FriendZone can not install + #]] + function(find_nwchem) + find_program(NWCHEM_FOUND nwchem REQUIRED) + assert_python_module("qcelemental") + assert_python_module("qcengine") + assert_python_module("networkx") + message("Found nwchem: ${NWCHEM_FOUND}") + endfunction() -if("${ENABLE_NWCHEM}") - find_nwchem() + if("${ENABLE_NWCHEM}") + find_nwchem() + endif() endif() add_library(nwchem INTERFACE) diff --git a/src/python/friendzone/nwx2ase/__init__.py b/src/python/friendzone/nwx2ase/__init__.py index e5032d7..7be0f96 100644 --- a/src/python/friendzone/nwx2ase/__init__.py +++ b/src/python/friendzone/nwx2ase/__init__.py @@ -13,7 +13,9 @@ # limitations under the License. from ..friends import is_friend_enabled -from .nwchem_via_ase import NWChemEnergyViaASE, NWChemGradientViaASE + +if is_friend_enabled("ase"): + from .nwchem_via_ase import NWChemEnergyViaASE, NWChemGradientViaASE def load_ase_modules(mm): diff --git a/tests/python/unit_tests/nwx2ase/test_chemical_system_conversions.py b/tests/python/unit_tests/nwx2ase/test_chemical_system_conversions.py index 5858666..63762c6 100644 --- a/tests/python/unit_tests/nwx2ase/test_chemical_system_conversions.py +++ b/tests/python/unit_tests/nwx2ase/test_chemical_system_conversions.py @@ -14,12 +14,15 @@ import unittest -from ase import Atoms -from friendzone.nwx2ase.chemical_system_conversions import ( - chemical_system2atoms, -) +from friendzone.friends import is_friend_enabled from molecules import make_h2, make_h2o +if is_friend_enabled("ase"): + from ase import Atoms + from friendzone.nwx2ase.chemical_system_conversions import ( + chemical_system2atoms, + ) + def compare_ase(self, lhs, rhs): for lhs_Z, rhs_Z in zip( @@ -63,3 +66,7 @@ def test_h2o(self): h2o_nwx = make_h2o() ase_mol = chemical_system2atoms(h2o_nwx) compare_ase(self, ase_mol, corr) + + def setUp(self): + if not is_friend_enabled("ase"): + self.skipTest("ASE is not enabled!") diff --git a/tests/python/unit_tests/nwx2ase/test_nwchem_via_ase.py b/tests/python/unit_tests/nwx2ase/test_nwchem_via_ase.py index 353f105..1b21461 100644 --- a/tests/python/unit_tests/nwx2ase/test_nwchem_via_ase.py +++ b/tests/python/unit_tests/nwx2ase/test_nwchem_via_ase.py @@ -65,7 +65,10 @@ def test_ccsd_t(self): self.assertAlmostEqual(np.array(egy), -1.122251361965036, places=4) def setUp(self): - if not friends.is_friend_enabled("nwchem"): + nwchem_enabled = friends.is_friend_enabled("nwchem") + ase_enabled = friends.is_friend_enabled("ase") + + if not nwchem_enabled or not ase_enabled: self.skipTest("NWChem backend is not enabled!") self.mm = ModuleManager()