Skip to content

Commit

Permalink
Merge pull request #1861 from Caylo/eb_update_self
Browse files Browse the repository at this point in the history
update easybuild from command line
  • Loading branch information
boegel committed Aug 12, 2016
2 parents f17c997 + bdf0b91 commit 7de8499
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
10 changes: 9 additions & 1 deletion easybuild/main.py
Expand Up @@ -55,7 +55,7 @@
from easybuild.framework.easyconfig.tweak import obtain_ec_for, tweak
from easybuild.tools.config import find_last_log, get_repository, get_repositorypath, build_option
from easybuild.tools.filetools import adjust_permissions, cleanup, write_file
from easybuild.tools.github import check_github, install_github_token, new_pr, update_pr
from easybuild.tools.github import check_github, find_easybuild_easyconfig, install_github_token, new_pr, update_pr
from easybuild.tools.modules import modules_tool
from easybuild.tools.options import parse_external_modules_metadata, process_software_build_specs
from easybuild.tools.robot import check_conflicts, det_robot_path, dry_run, resolve_dependencies, search_easyconfigs
Expand Down Expand Up @@ -272,6 +272,14 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
search_easyconfigs(search_query, short=options.search_short, filename_only=options.search_filename,
terse=options.terse)

if options.install_latest_eb_release:
if orig_paths:
raise EasyBuildError("Installing the latest EasyBuild release can not be combined with installing "
"other easyconfigs")
else:
eb_file = find_easybuild_easyconfig()
orig_paths.append(eb_file)

# GitHub integration
cleanup_and_exit = handle_github_options(options, orig_paths)

Expand Down
1 change: 1 addition & 0 deletions easybuild/tools/config.py
Expand Up @@ -137,6 +137,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
'force',
'group_writable_installdir',
'hidden',
'install_latest_eb_release',
'minimal_toolchains',
'module_only',
'package',
Expand Down
29 changes: 28 additions & 1 deletion easybuild/tools/github.py
Expand Up @@ -42,7 +42,6 @@
import tempfile
import time
import urllib2

from distutils.version import LooseVersion
from vsc.utils import fancylogger
from vsc.utils.missing import nub
Expand Down Expand Up @@ -1227,3 +1226,31 @@ def validate_github_token(token, github_user):
_log.info("GitHub token can be used for authenticated GitHub access, validation passed")

return sanity_check and token_test


def find_easybuild_easyconfig():
"""
Fetches the latest EasyBuild version eb file from GitHub
"""
dev_repo = download_repo(GITHUB_EASYCONFIGS_REPO, branch='develop', account=GITHUB_EB_MAIN)
eb_parent_path = os.path.join(dev_repo, 'easybuild', 'easyconfigs', 'e', 'EasyBuild')
files = os.listdir(eb_parent_path)

# find most recent version
file_versions = []
for eb_file in files:
txt = read_file(os.path.join(eb_parent_path, eb_file))
for line in txt.split('\n'):
if re.search(r'^version\s*=', line):
scope = {}
exec(line, scope)
version = scope['version']
file_versions.append((LooseVersion(version), eb_file))

if file_versions:
fn = sorted(file_versions)[-1][1]
else:
raise EasyBuildError("Couldn't find any EasyBuild easyconfigs")

eb_file = os.path.join(eb_parent_path, fn)
return eb_file
1 change: 1 addition & 0 deletions easybuild/tools/options.py
Expand Up @@ -288,6 +288,7 @@ def override_options(self):
"(e.g. --hide-deps=zlib,ncurses)", 'strlist', 'extend', None),
'hide-toolchains': ("Comma separated list of toolchains that you want automatically hidden, "
"(e.g. --hide-toolchains=GCCcore)", 'strlist', 'extend', None),
'install-latest-eb-release': ("Install latest known version of easybuild", None, 'store_true', False),
'minimal-toolchains': ("Use minimal toolchain when resolving dependencies", None, 'store_true', False),
'module-only': ("Only generate module file(s); skip all steps except for %s" % ', '.join(MODULE_ONLY_STEPS),
None, 'store_true', False),
Expand Down
11 changes: 11 additions & 0 deletions test/framework/github.py
Expand Up @@ -242,6 +242,17 @@ def test_validate_github_token(self):

self.assertTrue(gh.validate_github_token(self.github_token, GITHUB_TEST_ACCOUNT))

def test_find_easybuild_easyconfig(self):
"""Test for find_easybuild_eb function"""
if self.github_token is None:
print "Skipping test_find_easybuild_easyconfig, no GitHub token available?"
return
path = gh.find_easybuild_easyconfig()
expected = os.path.join('e', 'EasyBuild', 'EasyBuild-[1-9]+\.[1-9]+\.[1-9]+\.eb')
regex = re.compile(expected)
self.assertTrue(re.search(regex, path))
self.assertTrue(os.path.exists(path))

def test_find_patches(self):
""" Test for find_software_name_for_patch """
testdir = os.path.dirname(os.path.abspath(__file__))
Expand Down

0 comments on commit 7de8499

Please sign in to comment.