Add python.configure_pythonz()
convenience function
not sure how i managed to get by without this until now..?
This commit is contained in:
parent
70c5d661a3
commit
f87f1e875c
|
@ -26,7 +26,7 @@ Fabric Library for Python
|
|||
|
||||
from contextlib import contextmanager
|
||||
|
||||
from rattail_fabric2 import apt, exists, make_deploy, mkdir
|
||||
from rattail_fabric2 import apt, append, exists, make_deploy, mkdir
|
||||
|
||||
|
||||
deploy = make_deploy(__file__)
|
||||
|
@ -92,6 +92,21 @@ def install_pythonz(c):
|
|||
c.sudo('/usr/local/src/pythonz/pythonz-install')
|
||||
|
||||
|
||||
def configure_pythonz(c, user):
|
||||
"""
|
||||
Configure the given user's ``.bashrc`` to allow use of pythonz.
|
||||
"""
|
||||
# TODO: should normalize this get_home_dir() logic?
|
||||
home = c.run('getent passwd {} | cut -d: -f6'.format(user)).stdout.strip()
|
||||
home = home.rstrip('/')
|
||||
|
||||
script = '{}/.bashrc'.format(home)
|
||||
append(c, script, 'export PYTHONZ_ROOT=/usr/local/pythonz',
|
||||
use_sudo=True)
|
||||
append(c, script, '[[ -s /usr/local/pythonz/etc/bashrc ]] && source /usr/local/pythonz/etc/bashrc',
|
||||
use_sudo=True)
|
||||
|
||||
|
||||
def install_python(c, version, globally=False, verbose=False):
|
||||
"""
|
||||
Install a specific version of python, via pythonz.
|
||||
|
|
Loading…
Reference in a new issue