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

Allow config.guess code from configuremake.py to be used in rpackage.py #1938

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion easybuild/easyblocks/generic/configuremake.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ def obtain_config_guess(self, download_source_path=None, search_source_paths=Non
return config_guess_path

def check_config_guess(self):
"""Check timestamp & SHA256 checksum of config.guess script."""
"""
Check timestamp & SHA256 checksum of config.guess script.

Returns True if ok (or there is no config.guess for this package) and False if it's too old
or doesn't match the checksum.
"""
# log version, timestamp & SHA256 checksum of config.guess that was found (if any)
if self.config_guess:
# config.guess includes a "timestamp='...'" indicating the version
Expand All @@ -170,10 +175,14 @@ def check_config_guess(self):
if config_guess_version != CONFIG_GUESS_VERSION:
tup = (self.config_guess, config_guess_version, CONFIG_GUESS_VERSION)
print_warning("config.guess version at %s does not match expected version: %s vs %s" % tup)
return False

if config_guess_checksum != CONFIG_GUESS_SHA256:
tup = (self.config_guess, config_guess_checksum, CONFIG_GUESS_SHA256)
print_warning("SHA256 checksum of config.guess at %s does not match expected checksum: %s vs %s" % tup)
return False

return True

def fetch_step(self, *args, **kwargs):
"""Custom fetch step for ConfigureMake so we use an updated config.guess."""
Expand Down
20 changes: 17 additions & 3 deletions easybuild/easyblocks/generic/rpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
from easybuild.framework.easyconfig import CUSTOM
from easybuild.framework.extensioneasyblock import ExtensionEasyBlock
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import mkdir
from easybuild.tools.filetools import mkdir, copy_file
from easybuild.tools.run import run_cmd, parse_log_for_error
from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.tools.build_log import print_warning


def make_R_install_option(opt, values, cmdline=False):
Expand Down Expand Up @@ -74,6 +76,7 @@ def extra_options(extra_vars=None):
extra_vars.update({
'exts_subdir': ['', "Subdirectory where R extensions should be installed info", CUSTOM],
'unpack_sources': [False, "Unpack sources before installation", CUSTOM],
'update_config_guess': [False, "Update the config.guess file(s) in this package", CUSTOM],
})
return extra_vars

Expand Down Expand Up @@ -134,7 +137,7 @@ def make_cmdline_cmd(self, prefix=None):

if self.cfg['unpack_sources']:
loc = self.start_dir
elif self.patches:
elif self.patches or self.cfg['update_config_guess']:
loc = self.ext_dir
else:
loc = self.ext_src
Expand Down Expand Up @@ -215,11 +218,22 @@ def run(self):
lib_install_prefix = os.path.join(self.installdir, self.cfg['exts_subdir'])
mkdir(lib_install_prefix, parents=True)

if self.patches:
if self.patches or self.cfg['update_config_guess']:
super(RPackage, self).run(unpack_src=True)
else:
super(RPackage, self).run()

if self.cfg['update_config_guess']:
confmake = ConfigureMake(self.cfg)
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO the better option would be to make obtain_config_guess a static or better free function. It mostly is already anyway.

for root, _, files in os.walk(self.builddir):
for name in files:
if name == 'config.guess':
confmake.config_guess = os.path.join(root, name)
if not confmake.check_config_guess():
Copy link
Contributor

Choose a reason for hiding this comment

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

The ConfigureMake EB does this unconditionally (probably based on the assumption that it is highly unlikely that the config.guess matches). So I'd do the same here.

As an alternative: Add a quiet option to the check_config_guess to avoid the warnings. IMO there is nothing to warn about here. For the ConfigureMake EB the updating of the config.guess is the natural thing to do. So the output generated by obtain_config_guess is enough

updated = confmake.obtain_config_guess()
print_warning("Using updated config.guess for %s", confmake.config_guess)
copy_file(updated, confmake.config_guess)

if self.src:
self.ext_src = self.src
self.log.debug("Installing R package %s version %s." % (self.name, self.version))
Expand Down