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

Add custom delimiter support for update_paths, hack in special case for TCLLIBPATH #4487

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Micket
Copy link
Contributor

@Micket Micket commented Mar 24, 2024

TCLLIBPATH (and nothing else as far as I know) requires spaces instead of : as the path delimiter.

Currently, the easyconfigs that set TCLLIBPATH are broken (if you load more than one)
See easybuilders/easybuild-easyconfigs#20197 (comment)
https://github.com/search?q=repo%3Aeasybuilders%2Feasybuild-easyconfigs%20TCLLIBPATH&type=code
BTL, Graphviz, bwidget.

I opted to just hack in the special case for TCLLIBPATH, but i suppose it could be brought up even further, somehow making this an option for the easyconfigs? I don't really see how one would do this though, where we would add such a field?

modextrapaths_spaces = {
    'TCLLIBPATH': 'lib/tcl8.6',
}

meh...

Disclaimer: completely untested.

Edit: and of course i should be adding a test, haven't had time.

@@ -247,7 +247,9 @@ def append_paths(self, key, paths, allow_abs=False, expand_relpaths=True):
paths = self._filter_paths(key, paths)
if paths is None:
return ''
return self.update_paths(key, paths, prepend=False, allow_abs=allow_abs, expand_relpaths=expand_relpaths)
delim = ' ' if key == 'TCLLIBPATH' else ':'
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to avoid conditionals on specific envars inside framework. It would be better to pass the delimiter as an extra option through modextrapaths and the code here grabs any special delimiters or defaults to :.

modextrapaths  = {
    'TCLLIBPATH': 'lib/tcl8.6',
    'TCLLIBPATH': ('lib/tcl8.6', ' '),
    'TCLLIBPATH': ['lib/tcl8.6'],
    'TCLLIBPATH': (['lib/tcl8.6'], ' '),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hesitated with this approach since I felt that it would definitely be to ugly to expect module_generator.append_paths(key, paths) to be passing in paths as a tuple or something that.

Instead, if not hacky approach like this, I would add the delim kwarg to append_paths and prepend_paths as well, and whatever login extracts the delimiter would need to happen in the easyblock instead, here:

for (key, value) in self.cfg['modextrapaths'].items():
if isinstance(value, string_type):
value = [value]
elif not isinstance(value, (tuple, list)):
raise EasyBuildError("modextrapaths dict value %s (type: %s) is not a list or tuple",
value, type(value))
lines.append(self.module_generator.prepend_paths(key, value, allow_abs=self.cfg['allow_prepend_abs_path']))

Note that currently, we allow (given the code above) for paths to be tuples as well as lists:

modextrapaths = {
    'FOOPATH': ('multiple', 'paths'),  # allowed today
}

with a tuple as well. So, that would certainly interfere with the options here. I don't think any easyconfigs use this, so, we could say that tuples are only for use with specifying a delimiter.

@Micket
Copy link
Contributor Author

Micket commented Apr 10, 2024

For reference, since this touches the same methods as EBPYTHONPREFIX to PYTHONPATH change, I will hold off doing any actual work here until that is merged for 5.0.x

@Micket Micket marked this pull request as draft April 11, 2024 16:49
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.

None yet

2 participants