Skip to content

added regex to fix WM_PROJECT_VERSION correctly#1489

Merged
boegel merged 5 commits intoeasybuilders:developfrom
ComputeCanada:openfoam_version_bashrc
Sep 19, 2018
Merged

added regex to fix WM_PROJECT_VERSION correctly#1489
boegel merged 5 commits intoeasybuilders:developfrom
ComputeCanada:openfoam_version_bashrc

Conversation

@mboisson
Copy link
Copy Markdown
Contributor

This fixes WM_PROJECT_VERSION in OpenFOAM's bashrc files to use whatever is used by the easyconfig. It allows to use custom version numbers since OpenFOAM is so bad at versioning their software. .

Comment thread easybuild/easyblocks/o/openfoam.py Outdated
self.log.debug("Patching out hardcoded $WM_* env vars in %s", script)
# disable any third party stuff, we use EB controlled builds
regex_subs = [(r"^(setenv|export) WM_THIRD_PARTY_USE_.*[ =].*$", r"# \g<0>")]
regex_subs += [(r"^(setenv|export) WM_PROJECT_VERSION=.*$", r"export WM_PROJECT_VERSION=%s #\g<0>" % self.version)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (127 > 120 characters)

Comment thread easybuild/easyblocks/o/openfoam.py Outdated

# replacement dictionary of key-values
replacement_dict = {"WM_PROJECT_VERSION": self.version}
for key,val in replacement_dict.items():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing whitespace after ','

@akesandgren
Copy link
Copy Markdown
Contributor

@mboisson move the PR to develop instead of master please.

@boegel boegel changed the base branch from master to develop August 30, 2018 07:50
@boegel
Copy link
Copy Markdown
Member

boegel commented Aug 30, 2018

@akesandgren You can change the target branch (as maintainer or PR author) via the Edit button (I've done that just now).

@boegel boegel added this to the 3.7.0 milestone Aug 30, 2018
@boegel
Copy link
Copy Markdown
Member

boegel commented Aug 30, 2018

@mboisson This looks good to me, but it will need to be tested thoroughly on all existing OpenFOAM(-Extend) easyconfigs (I can look into that).

@mboisson
Copy link
Copy Markdown
Contributor Author

oops, my bad for master instead of develop @akesandgren

@boegel
Copy link
Copy Markdown
Member

boegel commented Sep 1, 2018

@mboisson One problematic case is an old version of OpenFOAM-Extend:

$ grep "export WM_PROJECT_VERSION" $EASYBUILD_PREFIX/software/OpenFOAM-*/*/etc/bashrc
...
/prefix/software/OpenFOAM-Extend/1.6-goolf-1.4.10-20130711/OpenFOAM-1.6-ext/etc/bashrc:export WM_PROJECT_VERSION=1.6-ext

You can dance around this and not touch WM_PROJECT_VERSION for OpenFOAM-Extend versions < 2.0 .

@mboisson
Copy link
Copy Markdown
Contributor Author

mboisson commented Sep 5, 2018

Ok, added a test case for OpenFOAM Extend < 2.0

Comment thread easybuild/easyblocks/o/openfoam.py Outdated
# replacement dictionary of key-values
replacement_dict = {"WM_PROJECT_VERSION": self.version}
for key, val in replacement_dict.items():
regex_subs += [(r"^(setenv|export) %s=.*$" % key, r"export %s=%s #\g<0>" % (key, val))]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mboisson Since replacement_dict only has a single entry, this can be collapsed to:

if 'extend' not in self.name.lower() or LooseVersion(self.version) >= LooseVersion('2.0'):
    key = 'WM_PROJECT_VERSION'
    regex_subs.append((r"^(setenv|export) %s=.*$" % key, r"export %s=%s #\g<0>" % (key, self.version)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this makes the line too long, split it on the .:

regex_subs.append((r"^(setenv|export) %s=.*$" % key,
                   r"export %s=%s #\g<0>" % (key, self.version)))

@boegel
Copy link
Copy Markdown
Member

boegel commented Sep 19, 2018

Tested with existing OpenFOAM easyconfigs, (still) works like a charm, thanks @mboisson!

@boegel boegel merged commit 0603a80 into easybuilders:develop Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants