puppet-python icon indicating copy to clipboard operation
puppet-python copied to clipboard

Add scl_enable_onlogin option to class python

Open iakovgan opened this issue 8 years ago • 6 comments

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).

iakovgan avatar Aug 22 '15 08:08 iakovgan

@ghoneycutt can you look for this enhancement :)

shivapoudel avatar Aug 22 '15 10:08 shivapoudel

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.

ghoneycutt avatar Aug 22 '15 17:08 ghoneycutt

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.

iakovgan avatar Aug 24 '15 15:08 iakovgan

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.

skpy avatar Sep 23 '15 23:09 skpy

What about when you need to use yum and that makes it point to the wrong python?

philippeback avatar Nov 20 '15 20:11 philippeback

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
...

skpy avatar Nov 20 '15 21:11 skpy