Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions easybuild/easyblocks/b/bzip2.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,27 @@ def configure_step(self):
"""Set extra options for 'make' command (CC, CFLAGS)."""

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

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

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

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

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

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

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

def sanity_check_step(self):
"""Custom sanity check for bzip2."""
libs = ['lib/libbz2.a']
if self.cfg['with_shared_libs']:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a sanity check for the unversioned symlinks as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already done, we're already checking for lib/libbz2.so

shlib_ext = get_shared_lib_ext()
libs.extend(['lib/libbz2.%s.%s' % (shlib_ext, self.version), 'lib/libbz2.%s' % shlib_ext])
libs.extend([f'lib/libbz2.{shlib_ext}.{self.version}', f'lib/libbz2.{shlib_ext}'])

custom_paths = {
'files': ['bin/b%s' % x for x in ['unzip2', 'zcat', 'zdiff', 'zgrep', 'zip2', 'zip2recover', 'zmore']] +
'files': [f'bin/b{x}' for x in ['unzip2', 'zcat', 'zdiff', 'zgrep', 'zip2', 'zip2recover', 'zmore']] +
['include/bzlib.h'] + libs,
'dirs': [],
}
Expand Down