Setting environnement variable in a port

Blair Zajac blair at orcaware.com
Tue Jul 26 09:26:26 PDT 2011


On Jul 26, 2011, at 6:26 AM, Sébastien Maret wrote:

> 
> Le 26 juil. 2011 à 15:21,  a écrit :
> 
>> On 2011-7-26 23:08 , Sébastien Maret wrote:
>>> 
>>> Le 26 juil. 2011 à 15:05, Joshua Root a écrit :
>>> 
>>>> On 2011-7-26 22:32 , Sébastien Maret wrote:
>>>>> I am working on a port that requires setting a few environnement
>>>>> variable at run time. How can this be done?
>>>> 
>>>> Depends on which variables and in which phase. You can directly set
>>>> configure.env, build.env etc., which should be a list of NAME=value,
>>>> plus the configure phase has a lot of options that set one specific
>>>> environment variable. Docs:
>>>> 
>>>> <http://guide.macports.org/chunked/reference.phases.html#reference.phases.configure>
>>> 
>>> Thanks for your answer.
>>> 
>>> I need to set variables at run time, not during the port phases. For example, the port must set the PYTHONPATH variable so that the Python modules installed by the port can be imported in a Python session.
>> 
>> My first instinct is that you're probably doing it wrong. Why can't you
>> install the module where python will find it automatically?
> 
> That would do the trick for PYTHONPATH, but not for the other, app-specific, variables that must be set for the program to run properly.

Another way is to drop a file in $prefix/etc/profile.d and than arrange to have the shell source it.

Blair



More information about the macports-dev mailing list