Skip to content

Commit

Permalink
build_hdf5: cmake or autoconf
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Sep 18, 2020
1 parent d49d83f commit e4bd6f1
Showing 1 changed file with 34 additions and 56 deletions.
90 changes: 34 additions & 56 deletions scripts/build_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,65 +67,51 @@ 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 = """
For Windows with Intel compiler, use HDF5 binaries from HDF Group.
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):
Expand Down Expand Up @@ -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)])
Expand Down

0 comments on commit e4bd6f1

Please sign in to comment.