add support for Environment Modules 4#2365
Conversation
| if self.REQ_VERSION is None: | ||
| self.log.debug("No version requirement defined.") | ||
| if self.REQ_VERSION is None and self.MAX_VERSION is None: | ||
| self.log.debug("No version requirement defined.") |
There was a problem hiding this comment.
No need for the extra indent here?
| if StrictVersion(self.version) < StrictVersion(self.REQ_VERSION): | ||
| raise EasyBuildError("EasyBuild requires v%s >= v%s (no rc), found v%s", | ||
| self.__class__.__name__, self.REQ_VERSION, self.version) | ||
| if self.REQ_VERSION is None: # MAX_VERSION is not None |
There was a problem hiding this comment.
Why not check directly whether self.MAX_VERSION is different from None?
elif self. MAX_VERSION is not None:| self.__class__.__name__, self.version, self.MAX_VERSION) | ||
| else: | ||
| self.log.debug('Version %s matches requirement <= %s' % (self.version, self.MAX_VERSION)) | ||
| elif self.MAX_VERSION is None: # REQ_VERSION is not None |
There was a problem hiding this comment.
You should change this to an if, to make sure that if both self.REQ_VERSION and self.MAX_VERSION are specified, that both are checked?
if self. REQ_VERSION is not None:There was a problem hiding this comment.
You're right, my logic is broken. Will fix.
| if self.REQ_VERSION is None: # MAX_VERSION is not None | ||
| self.log.debug("No required minimum version defined.") | ||
| if StrictVersion(self.version) > StrictVersion(self.MAX_VERSION): | ||
| raise EasyBuildError("EasyBuild requires v%s <= v%s (no rc), found v%s", |
There was a problem hiding this comment.
You should probably drop the no rc part here, since using a release candidate of the highest allowed version is older than that version, so it's OK to use it.
| raise EasyBuildError("EasyBuild requires v%s <= v%s (no rc), found v%s", | ||
| self.__class__.__name__, self.version, self.MAX_VERSION) | ||
| else: | ||
| self.log.debug('Version %s matches requirement <= %s' % (self.version, self.MAX_VERSION)) |
There was a problem hiding this comment.
Style nitpicking: Please use , rather than %:
self.log.debug('Version %s matches requirement <= %s', self.version, self.MAX_VERSION)| raise EasyBuildError("EasyBuild requires v%s >= v%s (no rc), found v%s", | ||
| self.__class__.__name__, self.REQ_VERSION, self.version) | ||
| else: | ||
| self.log.debug('Version %s matches requirement >= %s' % (self.version, self.REQ_VERSION)) |
There was a problem hiding this comment.
Use , rather than %:
self.log.debug('Version %s matches requirement >= %s', self.version, self.REQ_VERSION)| if StrictVersion(self.REQ_VERSION) > StrictVersion(self.MAX_VERSION): | ||
| raise EasyBuildError("v%s, REQ_VERSION must be <= MAX_VERSION", self.__class__) | ||
| else: | ||
| self.log.debug('Version %s matches requirements >= %s, <= %s' % (self.version, self.REQ_VERSION, self.MAX_VERSION)) |
There was a problem hiding this comment.
I would drop this whole block, and use two if conditions above.
| """Interface to (C) environment modules (modulecmd).""" | ||
| COMMAND = "modulecmd" | ||
| REQ_VERSION = '3.2.10' | ||
| MAX_VERSION = '3.2.10' |
There was a problem hiding this comment.
Make this a bit more liberal, in case people have local made local modifications and bumped this version.
MAX_VERSION = '3.99' # fictional version, just to indicate that version 4.0.0 and up are not compatible| """Update after new modules were added.""" | ||
| pass | ||
|
|
||
| class EnvironmentModules4(EnvironmentModulesC): |
There was a problem hiding this comment.
Maybe EnvironmentModulesTcl4 is a better name?
| COMMAND_SHELL = ['tclsh'] | ||
| VERSION_OPTION = '' | ||
| REQ_VERSION = None | ||
| MAX_VERSION = '1.923' |
There was a problem hiding this comment.
I would leave this unspecified, there's little point to it?
If somebody uses EnvironmentModulesTcl with Modules v4.0, it will fail anyway because eb can't determine the version?
…ed the hastily-named EnvironmentModules4 class until there is a better implementation. Style corrections.
… into env-modules-4
…EnvironmentModules 4.0+
…tead of string concatenation. Add a second blank line after EnvironmentModules class to match style of other classes.
|
|
||
| class EnvironmentModules(EnvironmentModulesTcl): | ||
| """Interface to environment modules 4.0+""" | ||
| COMMAND = os.path.join(os.environ['MODULESHOME'], 'libexec', 'modulecmd.tcl') |
There was a problem hiding this comment.
This should be done more carefully, if $MODULESHOME is not defined, this will lead to a nasty crash/traceback.
My suggestion is to use a fallback value, like this:
COMMAND = os.path.join(os.getenv('MODULESHOME', 'MODULESHOME_NOT_DEFINED'), 'libexec', 'modulecmd.tcl')There was a problem hiding this comment.
DO we need both MODULESHOME and MODULESHOME_NOT_DEFINED? If using os.getenv and MODULESHOME is undefined, None will be returned and the traceback won't occur. In that case, eb would look for None/libexec/modulecmd.tcl and throw an exception.
There was a problem hiding this comment.
@ebagrenrut Yes, we need the fallback value, since os.path.join won't be happy with the None value:
>>> os.path.join(None, 'libexec', 'modulecmd.tcl')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 70, in join
elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'
also test against Modules v4
…ad of os.environment when getting value of MODULESHOME. The latter results in a traceback if MODULESHOME is undefined.
…work into env-modules-4 Modules 4 tests from @boegel
…value in case MODULESHOME is undefined
…odule purge. It causes an extraneous argument error with Modules 4+
don't pass empty argument to 'module purge'
…(>=4.0) like EnvironmentModulesTcl (<=1.293)
…(>=4.0) like EnvironmentModulesTcl (<=1.293)
…s 4+ behaves similarly to ModulesC, so also append GCCcore/6.2.0 if we are an instance of EnvironmentModules
… (+ break up long comment)
update test_load, Modules v4.0 does not reload already loaded modules
|
@ebagrenrut The last failing test is because the bootstrap script is not aware of the new That's not hard to fix, but when that is fixed there's another problem: the test for the bootstrap script will still fail because it will try to install the latest EasyBuild release (v3.5.0), which doesn't know about In other words, a chicken-or-egg problem. So, I think we should just bypass the testing of the bootstrap script for now under |
|
@ebagrenrut Change in Travis config file to bypass testing of bootstrap script done in ebagrenrut#4. |
disable testing of bootstrap script when Modules v4 is used as modules tool
|
This looks good to go now, thanks for you help with this @ebagrenrut and @xdelaruelle! I'll follow up with another PR to re-enable testing of the bootstrap script with Modules v4, which can only be merged once EasyBuild v3.5.1 is released... |
Add a new class
EnvironmentModules4. Introduces aMAX_VERSIONtoModulesToolthat can be used to set a maximum version for a particular module tool. LimitsEnvironmentModulesCto a maximum version of3.2.10(the last release of the C implementation of Environment Modules). LimitsEnvironmentModulesTclto a maximum version of1.923(the last version of modules-tcl).