fix modpath_extensions_for method: take into account modules in Lua syntax#1766
Conversation
Updating the regex within the modules modpath_extensions_for function to find the module dependencies when using lua module files.
…l_modules for tests
…e to extract $MODULEPATH extensions
| r'^\s*prepend-path\s+MODULEPATH\s+"?([^"\s]+)"?', # prepend to $MODULEPATH in Tcl modules | ||
| r'^\s*prepend_path\(\"MODULEPATH\",\s*\"(\S+)\"', # prepend to $MODULEPATH in Lua modules | ||
| ]) | ||
| modpath_ext_regex = re.compile(modpath_ext_regex, re.M) |
There was a problem hiding this comment.
Doesn't it make sense to determine beforehand which kind of module are we reading, and apply the appropriate regex for each kind, instead of packing them all together?
There was a problem hiding this comment.
Maybe, but what extra would that give us?
If we detect a Tcl module (which is easy, via the required %#Module header), then we still need to try two regex's: module use and prepend-path MODULEPATH...
It's not like this is going to result in a noticeable speedup: module files are quite small, and regex search in Python is quite fast. It may even be faster to do what we do now than figure out first which type of module we're dealing with and then searching with a regex...
There was a problem hiding this comment.
It wasn't performance what bothered me, but keeping things clean and well structured. But admittedly this is splitting hairs in this particular case.
…ath_to_top_of_module_tree
|
Thanks for the review @wpoely86 and @damianam! I ran into another bug when testing this thoroughly with This has been fixed in here too now, and a dedicated unit test has been added. I've retested this with the setup mentioned above, works like a charm now: |
wrapper PR for #1474 by @t-brown
(replacement for #1763)