Add scl_enable_onlogin option to class python
SCL installation is actually quite confusing since we need to run "scl enable" before using python. To avoid human error it is useful to set scl permanatly on each user login.
Example:
# Permanently Enable a Software Collection
# see http://developerblog.redhat.com/2014/03/19/permanently-enable-a-software-collection/
# WARNING: this will not work for cron, virtualenv etc.
file { "/etc/profile.d/enable${python::python_version}.sh":
mode => '0755',
content => "#!/bin/bash\nsource /opt/rh/${python::python_version}/enable\nexport X_SCLS=\"`scl enable ${python::python_version} 'echo \$X_SCLS'`\"",
}
This may be managed by an additional paramter like python::scl_enable_onlogin (defalut=Flase).
@ghoneycutt can you look for this enhancement :)
This approach looks sane to me. The content should be in a template file though. This allows it to be validated, makes it easier to read, and gets around quoting and escaping complexities. I don't think you need the export line in the script either.
All recipies regarding this issue use export X_SCLS:
- https://plus.google.com/115875830338788300419/posts/5bTJMBoXsai
- http://developerblog.redhat.com/2014/03/19/permanently-enable-a-software-collection/
- http://wiki.contribs.org/Software_Collections:Python
It is possible that it is just a copy-paste-cargo-cult, but still.
You can also symlink the SCL enable script into /etc/profile.d and it should just work. We're doing exactly that in our SCL Ruby module, and it's been working fine.
What about when you need to use yum and that makes it point to the wrong python?
Yum specifically invokes #!/usr/bin/python in its shebang. You ought not have any trouble running yum with an SCL Python enabled. It's easy to confirm:
[vagrant@c2-smerrill ~]$ which python
/usr/bin/python
[vagrant@c2-smerrill ~]$ python --version
Python 2.7.5
[vagrant@c2-smerrill ~]$ scl enable python33 -- bash
[vagrant@c2-smerrill ~]$ which python
/opt/rh/python33/root/usr/bin/python
[vagrant@c2-smerrill ~]$ python --version
Python 3.3.2
[vagrant@c2-smerrill ~]$ yum --help
Loaded plugins: fastestmirror, priorities
Usage: yum [options] COMMAND
...
[vagrant@c2-smerrill ~]$ head /usr/bin/yum
#!/usr/bin/python
import sys
try:
import yum
...