Set environment variables for virtualenv & pip modules to use custom python interpreter

421 views
Skip to first unread message

Vye

unread,
May 19, 2014, 5:33:51 PM5/19/14
to salt-...@googlegroups.com
Is there a way to modify environment variables such as PATH and
LD_LIBRARY_PATH for modules pip and virtualenv? I believe the
functionality I'm looking for is supplied by modules.environ but I'm
using 2014.1 which it is not included in.

I want to create a virtualenv from an optional Python installed in
/opt/rh/python27 (RHEL).

/srv/www/app/venv:
virtualenv.managed:
- python: PATH=/opt/rh/python27/root/usr/bin${PATH:+:${PATH}}
LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
python2.7
- use_wheel: True
- requirements: /srv/www/app/requirements.txt

produces the following error:
ID: /srv/www/app/venv
Function: virtualenv.managed
Result: False
Comment: An exception occurred in this state: Traceback (most
recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py",
line 1371, in call
**cdata['kwargs'])
File
"/usr/lib/python2.6/site-packages/salt/states/virtualenv_mod.py", line
166, in managed
user=user
File
"/usr/lib/python2.6/site-packages/salt/modules/virtualenv_mod.py",
line 203, in create
'executable.'.format(python)
CommandExecutionError: Requested python
(PATH=/opt/rh/python27/root/usr/bin${PATH:+:${PATH}}
LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
python2.7) does not appear executable.

I could avoid setting PATH by using the absolute path but
LD_LIBRARY_PATH still needs to be set so Python can find the
libraries. What's the best way to accomplish this?

--
-Vye

Colton Myers

unread,
May 23, 2014, 5:15:06 PM5/23/14
to salt-...@googlegroups.com
You could try syncing `salt/modules/environ.py` to your minions as a custom module by taking it from the develop branch and sticking it in the `/srv/salt/_modules` and running `salt '*' saltutil.sync_all`.  That doesn't always work if it relies on utils that are not available in the version of salt that you're using, but it's worth a shot.  Otherwise, I'm not really sure how to set these variables for the salt process.

--
Colton Myers



--
-Vye

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages