If you do not find any solution, add the feature request [1] for
variant with no fixed value list.
It seems feasible to add an option to the variant modulefile command
to accept any values. Then it is up to modulefile author to check if
the specified value for variant is correct or not.
Regards,
Xavier
[1] https://github.com/cea-hpc/modules/issues/new/choose
Le ven. 16 juil. 2021 à 08:24, Michael Strelnikov
<mic...@gm...> a écrit :
>
> Thanks. But the folders could be anywhere. I can't know them in advance.
>
> On Fri, 16 Jul 2021 at 16:18, Xavier Delaruelle <xav...@gm...> wrote:
>>
>> Hi Michael,
>>
>> Variant predefined values may be computed on the fly in the
>> modulefile. So maybe if your projects shares predefined roots or if
>> you know where to find them, you could set the code in the modulefile
>> to create the list of valid project root values.
>>
>> $ mkdir /tmp/projects/{dir1,dir2,dir3} -p
>> $ cat modulefiles/test
>> #%Module
>> set dir_list [glob -path /tmp/projects/ -tails *]
>> variant root {*}$dir_list
>>
>> $ module show test root=dir1
>> -------------------------------------------------------------------
>> /path/to/modulefiles/test:
>>
>> variant root dir3 dir2 dir1
>> -------------------------------------------------------------------
>>
>> Regards,
>> Xavier
>>
>> Le ven. 16 juil. 2021 à 07:29, Michael Strelnikov
>> <mic...@gm...> a écrit :
>> >
>> > Hi,
>> >
>> > I'm looking into the new features of modules and thinking how I can use the "variants".
>> >
>> > My original thought was to use it like "module load project [path to the root of project]". If I supply the path, it will take use it to set up variables and other tools. If I don't supply it, correct directory will be used.
>> > But then I understood that the variants must have predefined values. So, my method will not work.
>> > Are there other options I can use to achieve my goal?
>> >
>> > Thanks.
>> > Michael
>> > _______________________________________________
>> > Modules-interest mailing list
>> > Mod...@li...
>> > https://lists.sourceforge.net/lists/listinfo/modules-interest
>>
>>
>> _______________________________________________
>> Modules-interest mailing list
>> Mod...@li...
>> https://lists.sourceforge.net/lists/listinfo/modules-interest
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
|