From e4bd6f1f7138c8ac689f93997401225020c9a8da Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 18 Sep 2020 15:27:26 -0400 Subject: [PATCH] build_hdf5: cmake or autoconf --- scripts/build_hdf5.py | 90 ++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 56 deletions(-) diff --git a/scripts/build_hdf5.py b/scripts/build_hdf5.py index bc66afc3..a5067806 100644 --- a/scripts/build_hdf5.py +++ b/scripts/build_hdf5.py @@ -67,6 +67,10 @@ def hdf5(dirs: T.Dict[str, Path], env: T.Mapping[str, str]): To avoid this, we git clone the release instead. """ + name = "hdf5" + install_dir = dirs["prefix"] / name + source_dir = dirs["workdir"] / name + if os.name == "nt": if "ifort" in env["FC"]: msg = """ @@ -74,58 +78,40 @@ def hdf5(dirs: T.Dict[str, Path], env: T.Mapping[str, str]): https://www.hdfgroup.org/downloads/hdf5/ look for filename like hdf5-1.12.0-Std-win10_64-vs14-Intel.zip """ - elif "gfortran" in env["FC"]: - msg = """ -For MSYS2 on Windows, just use MSYS2 HDF5. -Install from the MSYS2 terminal like: -pacman -S mingw-w64-x86_64-hdf5 -reference: https://packages.msys2.org/package/mingw-w64-x86_64-hdf5 - """ - else: - msg = """ -For Windows, use HDF5 binaries from HDF Group. -https://www.hdfgroup.org/downloads/hdf5/ -Instead of this, it is generally best to use MSYS2 or Windows Subsystem for Linux - """ - raise NotImplementedError(msg) - - hdf5_name = "hdf5" - install_dir = dirs["prefix"] / hdf5_name - source_dir = dirs["workdir"] / hdf5_name + raise NotImplementedError(msg) + + cmd0 = [ + "cmake", + f"-S{source_dir}", + f"-B{source_dir/BUILDDIR}", + f"-DCMAKE_INSTALL_PREFIX={install_dir}", + "-DBUILD_SHARED_LIBS:BOOL=false", + "-DCMAKE_BUILD_TYPE=Release", + "-DHDF5_BUILD_FORTRAN:BOOL=true", + "-DHDF5_BUILD_CPP_LIB:BOOL=false", + "-DHDF5_BUILD_TOOLS:BOOL=false", + "-DBUILD_TESTING:BOOL=false", + "-DHDF5_BUILD_EXAMPLES:BOOL=false", + ] + cmd1 = ["cmake", "--build", BUILDDIR, "--parallel"] + cmd2 = ["cmake", "--install", BUILDDIR, "--parallel"] + else: + cmd0 = [ + "./configure", + f"--prefix={install_dir}", + "--enable-fortran", + "--enable-build-mode=production", + ] + cmd1 = ["make", "-j"] + cmd2 = ["make", "-j", "install"] git_url = "https://bitbucket.hdfgroup.org/scm/hdffv/hdf5.git" git_download(source_dir, git_url, HDF5_TAG) - cmd = [ - "./configure", - f"--prefix={install_dir}", - "--enable-fortran", - "--enable-build-mode=production", - ] - - # cmd = [ - # "cmake", - # f"-S{source_dir}", - # f"-B{source_dir/BUILDDIR}", - # f"-DCMAKE_INSTALL_PREFIX={install_dir}", - # "-DBUILD_SHARED_LIBS:BOOL=false", - # "-DCMAKE_BUILD_TYPE=Release", - # "-DHDF5_BUILD_FORTRAN:BOOL=true", - # "-DHDF5_BUILD_CPP_LIB:BOOL=false", - # "-DHDF5_BUILD_TOOLS:BOOL=false", - # "-DBUILD_TESTING:BOOL=false", - # "-DHDF5_BUILD_EXAMPLES:BOOL=false", - # ] - subprocess.check_call(nice + cmd, cwd=source_dir, env=env) - - cmd = ["make", "-j"] - # cmd = ["cmake", "--build", BUILDDIR, "--parallel"] - subprocess.check_call(nice + cmd, cwd=source_dir) - - cmd = ["make", "-j", "install"] - # cmd = ["cmake", "--install", BUILDDIR, "--parallel"] - subprocess.check_call(nice + cmd, cwd=source_dir) + subprocess.check_call(nice + cmd0, cwd=source_dir, env=env) + subprocess.check_call(nice + cmd1, cwd=source_dir) + subprocess.check_call(nice + cmd2, cwd=source_dir) def git_download(path: Path, repo: str, tag: str): @@ -158,15 +144,7 @@ def git_download(path: Path, repo: str, tag: str): # shallow clone if tag: subprocess.check_call( - [ - GITEXE, - "clone", - repo, - "--branch", - tag, - "--single-branch", - str(path), - ] + [GITEXE, "clone", repo, "--branch", tag, "--single-branch", str(path)] ) else: subprocess.check_call([GITEXE, "clone", repo, "--depth", "1", str(path)])