Skip to content

Commit e4bd6f1

Browse files
committed
build_hdf5: cmake or autoconf
1 parent d49d83f commit e4bd6f1

File tree

1 file changed

+34
-56
lines changed

1 file changed

+34
-56
lines changed

scripts/build_hdf5.py

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -67,65 +67,51 @@ def hdf5(dirs: T.Dict[str, Path], env: T.Mapping[str, str]):
6767
To avoid this, we git clone the release instead.
6868
"""
6969

70+
name = "hdf5"
71+
install_dir = dirs["prefix"] / name
72+
source_dir = dirs["workdir"] / name
73+
7074
if os.name == "nt":
7175
if "ifort" in env["FC"]:
7276
msg = """
7377
For Windows with Intel compiler, use HDF5 binaries from HDF Group.
7478
https://www.hdfgroup.org/downloads/hdf5/
7579
look for filename like hdf5-1.12.0-Std-win10_64-vs14-Intel.zip
7680
"""
77-
elif "gfortran" in env["FC"]:
78-
msg = """
79-
For MSYS2 on Windows, just use MSYS2 HDF5.
80-
Install from the MSYS2 terminal like:
81-
pacman -S mingw-w64-x86_64-hdf5
82-
reference: https://packages.msys2.org/package/mingw-w64-x86_64-hdf5
83-
"""
84-
else:
85-
msg = """
86-
For Windows, use HDF5 binaries from HDF Group.
87-
https://www.hdfgroup.org/downloads/hdf5/
88-
Instead of this, it is generally best to use MSYS2 or Windows Subsystem for Linux
89-
"""
90-
raise NotImplementedError(msg)
91-
92-
hdf5_name = "hdf5"
93-
install_dir = dirs["prefix"] / hdf5_name
94-
source_dir = dirs["workdir"] / hdf5_name
81+
raise NotImplementedError(msg)
82+
83+
cmd0 = [
84+
"cmake",
85+
f"-S{source_dir}",
86+
f"-B{source_dir/BUILDDIR}",
87+
f"-DCMAKE_INSTALL_PREFIX={install_dir}",
88+
"-DBUILD_SHARED_LIBS:BOOL=false",
89+
"-DCMAKE_BUILD_TYPE=Release",
90+
"-DHDF5_BUILD_FORTRAN:BOOL=true",
91+
"-DHDF5_BUILD_CPP_LIB:BOOL=false",
92+
"-DHDF5_BUILD_TOOLS:BOOL=false",
93+
"-DBUILD_TESTING:BOOL=false",
94+
"-DHDF5_BUILD_EXAMPLES:BOOL=false",
95+
]
96+
cmd1 = ["cmake", "--build", BUILDDIR, "--parallel"]
97+
cmd2 = ["cmake", "--install", BUILDDIR, "--parallel"]
98+
else:
99+
cmd0 = [
100+
"./configure",
101+
f"--prefix={install_dir}",
102+
"--enable-fortran",
103+
"--enable-build-mode=production",
104+
]
105+
cmd1 = ["make", "-j"]
106+
cmd2 = ["make", "-j", "install"]
95107

96108
git_url = "https://bitbucket.hdfgroup.org/scm/hdffv/hdf5.git"
97109

98110
git_download(source_dir, git_url, HDF5_TAG)
99111

100-
cmd = [
101-
"./configure",
102-
f"--prefix={install_dir}",
103-
"--enable-fortran",
104-
"--enable-build-mode=production",
105-
]
106-
107-
# cmd = [
108-
# "cmake",
109-
# f"-S{source_dir}",
110-
# f"-B{source_dir/BUILDDIR}",
111-
# f"-DCMAKE_INSTALL_PREFIX={install_dir}",
112-
# "-DBUILD_SHARED_LIBS:BOOL=false",
113-
# "-DCMAKE_BUILD_TYPE=Release",
114-
# "-DHDF5_BUILD_FORTRAN:BOOL=true",
115-
# "-DHDF5_BUILD_CPP_LIB:BOOL=false",
116-
# "-DHDF5_BUILD_TOOLS:BOOL=false",
117-
# "-DBUILD_TESTING:BOOL=false",
118-
# "-DHDF5_BUILD_EXAMPLES:BOOL=false",
119-
# ]
120-
subprocess.check_call(nice + cmd, cwd=source_dir, env=env)
121-
122-
cmd = ["make", "-j"]
123-
# cmd = ["cmake", "--build", BUILDDIR, "--parallel"]
124-
subprocess.check_call(nice + cmd, cwd=source_dir)
125-
126-
cmd = ["make", "-j", "install"]
127-
# cmd = ["cmake", "--install", BUILDDIR, "--parallel"]
128-
subprocess.check_call(nice + cmd, cwd=source_dir)
112+
subprocess.check_call(nice + cmd0, cwd=source_dir, env=env)
113+
subprocess.check_call(nice + cmd1, cwd=source_dir)
114+
subprocess.check_call(nice + cmd2, cwd=source_dir)
129115

130116

131117
def git_download(path: Path, repo: str, tag: str):
@@ -158,15 +144,7 @@ def git_download(path: Path, repo: str, tag: str):
158144
# shallow clone
159145
if tag:
160146
subprocess.check_call(
161-
[
162-
GITEXE,
163-
"clone",
164-
repo,
165-
"--branch",
166-
tag,
167-
"--single-branch",
168-
str(path),
169-
]
147+
[GITEXE, "clone", repo, "--branch", tag, "--single-branch", str(path)]
170148
)
171149
else:
172150
subprocess.check_call([GITEXE, "clone", repo, "--depth", "1", str(path)])

0 commit comments

Comments
 (0)