Skip to content

Commit

Permalink
better error if cmake not found
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Feb 7, 2021
1 parent a8dea93 commit 890dd81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = msise00
version = 1.9.0
version = 1.9.1
description = Python API for Fortran MSISE-00 neutral atmosphere model.
author = Michael Hirsch, Ph.D.
author_email = scivision@users.noreply.github.com
Expand Down
12 changes: 8 additions & 4 deletions src/msise00/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ def cmake(setup_file: Path):
"""
attempt to build using CMake
"""
exe = shutil.which("ctest")
if not exe:
raise FileNotFoundError("CMake not available")

subprocess.check_call([exe, "-S", str(setup_file), "-VV"])
subprocess.check_call(["ctest", "-S", str(setup_file), "-VV"])


def run(
Expand Down Expand Up @@ -127,6 +124,13 @@ def rungtd1d(time: datetime, altkm: float, glat: float, glon: float, indices: di
if os.name == "nt":
exe_name += ".exe"
if not importlib.resources.is_resource(__package__, exe_name):
# check for CMake here to avoid "generator didn't stop after throw() higher level raise"
if not shutil.which("ctest"):
raise FileNotFoundError("""
CMake not available. try installing CMake like:
pip install cmake""")

with importlib.resources.path(__package__, "setup.cmake") as setup_file:
cmake(setup_file)
if not importlib.resources.is_resource(__package__, exe_name):
Expand Down

0 comments on commit 890dd81

Please sign in to comment.