Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treat files/directories of unpacked sources equally in PackedBinary #2306

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
22 changes: 11 additions & 11 deletions easybuild/easyblocks/generic/packedbinary.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
@author: Jens Timmerman (Ghent University)
"""
import os
import shutil

from easybuild.framework.easyblock import EasyBlock
from easybuild.easyblocks.generic.binary import Binary
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import change_dir, copy


class PackedBinary(Binary, EasyBlock):
Expand All @@ -45,18 +45,18 @@ def extract_step(self):
EasyBlock.extract_step(self)

def install_step(self):
"""Copy all unpacked source directories to install directory, one-by-one."""
try:
os.chdir(self.builddir)
for src in os.listdir(self.builddir):
srcpath = os.path.join(self.builddir, src)
"""Copy all unpacked source files/directories to install directory, one-by-one."""
change_dir(self.builddir)
for src in os.listdir(self.builddir):
srcpath = os.path.join(self.builddir, src)
# we only handle the case of a single file and no install_cmd here
if os.path.isfile(srcpath) and self.cfg.get('install_cmd', None) is None:
copy(srcpath, self.installdir)
else:
if os.path.isdir(srcpath):
# copy files to install dir via Binary
self.cfg['start_dir'] = src
Binary.install_step(self)
elif os.path.isfile(srcpath):
shutil.copy2(srcpath, self.installdir)
self.cfg['start_dir'] = self.builddir
else:
raise EasyBuildError("Path %s is not a file nor a directory?", srcpath)
except OSError as err:
raise EasyBuildError("Failed to copy unpacked sources to install directory: %s", err)
Binary.install_step(self)
Comment on lines +52 to +62
Copy link
Contributor

Choose a reason for hiding this comment

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

@ocaisa this is a pre-existing thing, but the install_step in the Binary easyblock removes the installation directory before copying, shouldn't that be done here too? why not just let the Binary install_step handle this case too, since it already has the logic to handle if install_cmd is None?

Suggested change
# we only handle the case of a single file and no install_cmd here
if os.path.isfile(srcpath) and self.cfg.get('install_cmd', None) is None:
copy(srcpath, self.installdir)
else:
if os.path.isdir(srcpath):
# copy files to install dir via Binary
self.cfg['start_dir'] = src
Binary.install_step(self)
elif os.path.isfile(srcpath):
shutil.copy2(srcpath, self.installdir)
self.cfg['start_dir'] = self.builddir
else:
raise EasyBuildError("Path %s is not a file nor a directory?", srcpath)
except OSError as err:
raise EasyBuildError("Failed to copy unpacked sources to install directory: %s", err)
Binary.install_step(self)
if os.path.isdir(srcpath):
self.cfg['start_dir'] = src
elif os.path.isfile(srcpath):
self.cfg['start_dir'] = self.builddir
else:
raise EasyBuildError("Path %s is not a file nor a directory?", srcpath)
Binary.install_step(self)