Dear Loris,

one way to achieve what you want is to use the modxxxfooter parameters in the 
eb-file (untested):

modluafooter = 'setenv("MCR_CACHE_ROOT", pathJoin("/scratch", 
pathJoin(os.getenv("USER"), "mcr_cache")))'
modtclfooter = 'setenv("MCR_CACHE_ROOT", pathJoin("/scratch", 
pathJoin(os.getenv("USER"), "mcr_cache")))'

Not sure if this is advisable, in particular if you use $TMPDIR as this may 
change from the time the module is loaded to the time Matlab is running. 

Wouldn't it be better to set MCR_CACHE_ROOT within Matlab based on TMPDIR?

Best wishes
Stefan

--
Scientific Computing

Carl von Ossietzky University Oldenburg
School of Mathematics and Natural Sciences
26111 Oldenburg, Germany

Office: W03 1-139
Phone: +49-441-798 3147
E-Mail: stefan.har...@uni-oldenburg.de
www: http://www.uni-oldenburg.de/fk5/wr

-----Ursprüngliche Nachricht-----
Von: easybuild-requ...@lists.ugent.be [mailto:easybuild-requ...@lists.ugent.be] 
Im Auftrag von Loris Bennett
Gesendet: Dienstag, 12. März 2019 11:42
An: easybuild <easybuild@lists.ugent.be>
Betreff: Re: [easybuild] Accessing environment variables in easyconfig

Hi Åke,

I want to add the environment variables to a MATLAB easyconfig which are needed 
to run compiled MATLAB programms

I tried

  modextravars = {'LM_LICENSE_FILE': '%s@%s' % (license_server_port, 
license_server),
                  'MATLABROOT': '.',
                  'MCR_HOME': 'MATLABROOT',
                  'MCR_CACHE_ROOT': '/scratch/$USER/mcr_cache',
                  }

But when I load the module as a normal user, the variable is not
expanded:

  $ echo $MCR_CACHE_ROOT
  /scratch/$USER/mcr_cache

Ultimately, I may well just define a general temporary directory such as

  TMPDIR=/scratch/tmp/$USER

somewhere in /etc/profile.d, but even then I'd need to have the module expand 
$TMPDIR properly.

Cheers,

Loris


I want to add an
Åke Sandgren <ake.sandg...@hpc2n.umu.se> writes:

> That sounds very wrong.
>
> Installing user should not be exposed to the software that is being 
> installed.
>
> What's your use-case?
>
> On 3/12/19 9:52 AM, Loris Bennett wrote:
>> Hi,
>> 
>> I need to get $USER within an easyconfig.  I found the documentation 
>> for the Python module easybuild.tools.environment, but this doesn't 
>> seem to be what I need.
>> 
>> Can any one point me to the documentation about how to access 
>> environment variables in an easyconfig?
>> 
>> Cheers,
>> 
>> Loris
>> 
--
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin         Email loris.benn...@fu-berlin.de

Reply via email to