Skip to content

Commit 3c3bde2

Browse files
authored
Merge pull request #3948 from jfgrimm/20251002155038_new_pr_bzip2
fix custom easyblock for bzip2 to ensure all versioned symlinks are created
2 parents 1910739 + 997da04 commit 3c3bde2

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

easybuild/easyblocks/b/bzip2.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,27 @@ def configure_step(self):
5656
"""Set extra options for 'make' command (CC, CFLAGS)."""
5757

5858
if 'CC=' not in self.cfg['buildopts']:
59-
self.cfg.update('buildopts', 'CC="%s"' % os.getenv('CC'))
59+
self.cfg.update('buildopts', f'CC="{os.getenv("CC")}"')
6060
if 'CFLAGS=' not in self.cfg['buildopts']:
61-
self.cfg.update('buildopts', "CFLAGS='-Wall -Winline %s -g $(BIGFILES)'" % os.getenv('CFLAGS'))
61+
self.cfg.update('buildopts', f"CFLAGS='-Wall -Winline {os.getenv('CFLAGS')} -g $(BIGFILES)'")
6262

6363
def install_step(self):
6464
"""Install in non-standard path by passing PREFIX variable to make install."""
6565

66-
self.cfg.update('installopts', "PREFIX=%s" % self.installdir)
66+
self.cfg.update('installopts', f"PREFIX={self.installdir}")
6767
super().install_step()
6868

6969
# also build & install shared libraries, if desired
7070
if self.cfg['with_shared_libs']:
7171

72-
cmd = "%s make -f Makefile-libbz2_so %s" % (self.cfg['prebuildopts'], self.cfg['buildopts'])
72+
cmd = f"{self.cfg['prebuildopts']} make -f Makefile-libbz2_so {self.cfg['buildopts']}"
7373
run_shell_cmd(cmd)
7474

7575
# copy shared libraries to <install dir>/lib
7676
shlib_ext = get_shared_lib_ext()
7777
libdir = os.path.join(self.installdir, 'lib')
7878
try:
79-
for lib in glob.glob('libbz2.%s.*' % shlib_ext):
79+
for lib in glob.glob(f'libbz2.{shlib_ext}.*'):
8080
# only way to copy a symlink is to check for it,
8181
# cfr. http://stackoverflow.com/questions/4847615/copying-a-symbolic-link-in-python
8282
if os.path.islink(lib):
@@ -86,24 +86,28 @@ def install_step(self):
8686
except OSError as err:
8787
raise EasyBuildError("Copying shared libraries to installation dir %s failed: %s", libdir, err)
8888

89-
# create symlink libbz2.so >> libbz2.so.1.0.6
90-
try:
91-
cwd = os.getcwd()
92-
os.chdir(libdir)
93-
os.symlink('libbz2.%s.%s' % (shlib_ext, self.version), 'libbz2.%s' % shlib_ext)
94-
os.chdir(cwd)
95-
except OSError as err:
96-
raise EasyBuildError("Creating symlink for libbz2.so failed: %s", err)
89+
# create (un)versioned symlinks for libbz2.so.X.Y.Z
90+
split_ver = self.version.split('.')
91+
sym_exts = ['.' + '.'.join(split_ver[-3:x]) for x in range(1, 3)] # e.g. ['.1', '.1.0'] for version 1.0.8
92+
cwd = os.getcwd()
93+
for sym in [f'libbz2.{shlib_ext}{x}' for x in [''] + sym_exts]:
94+
if not os.path.exists(os.path.join(libdir, sym)):
95+
try:
96+
os.chdir(libdir)
97+
os.symlink(f'libbz2.{shlib_ext}.{self.version}', sym)
98+
os.chdir(cwd)
99+
except OSError as err:
100+
raise EasyBuildError("Creating symlink for libbz2.so failed: %s", err)
97101

98102
def sanity_check_step(self):
99103
"""Custom sanity check for bzip2."""
100104
libs = ['lib/libbz2.a']
101105
if self.cfg['with_shared_libs']:
102106
shlib_ext = get_shared_lib_ext()
103-
libs.extend(['lib/libbz2.%s.%s' % (shlib_ext, self.version), 'lib/libbz2.%s' % shlib_ext])
107+
libs.extend([f'lib/libbz2.{shlib_ext}.{self.version}', f'lib/libbz2.{shlib_ext}'])
104108

105109
custom_paths = {
106-
'files': ['bin/b%s' % x for x in ['unzip2', 'zcat', 'zdiff', 'zgrep', 'zip2', 'zip2recover', 'zmore']] +
110+
'files': [f'bin/b{x}' for x in ['unzip2', 'zcat', 'zdiff', 'zgrep', 'zip2', 'zip2recover', 'zmore']] +
107111
['include/bzlib.h'] + libs,
108112
'dirs': [],
109113
}

0 commit comments

Comments
 (0)