easybuild-easyblocks icon indicating copy to clipboard operation
easybuild-easyblocks copied to clipboard

Make `CmdCp` easier to use

Open Flamefire opened this issue 1 year ago • 3 comments

The name suggest running a command and copy files. However the commands need to be specified as a regex-map list which might be executed for every source instead of once. Often a workflow might be just ./custom_configure && ./custom_build.sh which is not easy to map to this. Instead allow non-tuples which are considered as commands to be run. When mixing tuples and non-tuples the plain commands are run last.

This was always a concern of mine that a workflow consisting of running only a command that involves some custom install procedure was less obvious than it might be. It came up recently where an EC uses MakeCp requiring parallel = False as it replaces the make cmd by a single command. In that case it is ./configure --options and ./coconut which isn't easily applicable using CmdCp

With this change it can be:

cmds_map = [
    "./configure --option1 --option2",
    "./coconut --flag 1 --flag 2",
]

I'd say this is easier to read and understand than:

cmds_map = [
   (".*", "./configure --option1 --option2 && ./coconut --flag 1 --flag 2"),
]

Also error reporting would be more focused, i.e. either "./configure failed" or "./coconut failed"

I can port a couple easyconfigs to the new syntax in a PR to the easyconfig repo for test reports and usage examples.

Flamefire avatar Jan 13 '25 08:01 Flamefire

A very long time ago, CmdCp had a cmd parameter: https://github.com/easybuilders/easybuild-easyblocks/commit/ffe30c3468afeed01b4069f3dc8d2e4b464c10b6 I think perhaps it would be better to reintroduce cmd for simple string commands but use cmds_map for the more complex case? @boegel may know as author of the above commit?

bartoldeman avatar Jan 13 '25 14:01 bartoldeman

The problem is the default for cmds_map. We could add a cmds parameter to work in the same way as here that, when set, removes the default for cmds_map but that makes the default disappear from the docstring. Can add it to the help though.

Another confusing bit is that %(source)s refers to the original unpatched source

Currently it is the file stem (name w/o extension) of the source, so not sure how it could refer to the "unpatched source". Maybe that has changed? Or I misunderstand the issue.

Flamefire avatar Jan 14 '25 10:01 Flamefire

@Flamefire I changed to target branch in this PR from 5.0.x to develop, you should synchronize your PR branch with current develop branch (which has received a massive update after the release of EasyBuild v5.0.0, see https://github.com/easybuilders/easybuild-easyblocks/pull/3670)

boegel avatar Mar 19 '25 11:03 boegel