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

implement EasyBuild API version checks to avoid mixing major versions across the EasyBuild components #4520

Merged
merged 14 commits into from
Jun 5, 2024
8 changes: 8 additions & 0 deletions easybuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
from easybuild.tools.repository.repository import init_repository
from easybuild.tools.systemtools import check_easybuild_deps
from easybuild.tools.testing import create_test_report, overall_test_report, regtest, session_state
from easybuild.tools.version import EASYBLOCKS_VERSION, FRAMEWORK_VERSION, UNKNOWN_VERSION, different_major_versions


_log = None
Expand Down Expand Up @@ -618,6 +619,13 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None, pr
(build_specs, _log, logfile, robot_path, search_query, eb_tmpdir, try_to_generate,
from_pr_list, tweaked_ecs_paths) = cfg_settings

# compare running Framework and EasyBlocks versions
if EASYBLOCKS_VERSION == UNKNOWN_VERSION:
print_msg("Unable to determine EasyBlocks version, so we'll assume it is not different from Framework")
branfosj marked this conversation as resolved.
Show resolved Hide resolved
elif different_major_versions(FRAMEWORK_VERSION, EASYBLOCKS_VERSION):
raise EasyBuildError("Framework (%s) and EasyBlock (%s) major versions are different." % (FRAMEWORK_VERSION,
EASYBLOCKS_VERSION))

# load hook implementations (if any)
hooks = load_hooks(options.hooks)

Expand Down
16 changes: 15 additions & 1 deletion easybuild/tools/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
# This causes problems further up the dependency chain...
VERSION = LooseVersion('4.9.2.dev0')
UNKNOWN = 'UNKNOWN'
UNKNOWN_VERSION = '0.0.UNKNOWN.EASYBLOCKS'


def get_git_revision():
Expand Down Expand Up @@ -87,7 +88,7 @@ def get_git_revision():
try:
from easybuild.easyblocks import VERBOSE_VERSION as EASYBLOCKS_VERSION
except Exception:
EASYBLOCKS_VERSION = '0.0.UNKNOWN.EASYBLOCKS' # make sure it is smaller then anything
EASYBLOCKS_VERSION = UNKNOWN_VERSION # make sure it is smaller then anything


def this_is_easybuild():
Expand All @@ -103,3 +104,16 @@ def this_is_easybuild():
msg = msg.encode('ascii')

return msg


def different_major_versions(v1, v2):
"""Compare major versions"""
# Deal with version instances being either strings or LooseVersion
if not isinstance(v1, LooseVersion):
v1 = LooseVersion(v1)
if not isinstance(v2, LooseVersion):
v2 = LooseVersion(v2)

if v1.version[0] == v2.version[0]:
return False
return True
branfosj marked this conversation as resolved.
Show resolved Hide resolved
Loading