Allow global registration of custom versions of python
This commit is contained in:
parent
3b3cb8ab82
commit
720010d889
|
@ -75,13 +75,23 @@ def install_pythonz(c):
|
||||||
c.sudo('/usr/local/src/pythonz/pythonz-install')
|
c.sudo('/usr/local/src/pythonz/pythonz-install')
|
||||||
|
|
||||||
|
|
||||||
def install_python(c, version, verbose=False):
|
def install_python(c, version, globally=False, verbose=False):
|
||||||
"""
|
"""
|
||||||
Install a specific version of python, via pythonz.
|
Install a specific version of python, via pythonz.
|
||||||
|
|
||||||
|
:param globally: Whether or not this python should be registered globally,
|
||||||
|
by placing a symlink to it in ``/usr/local/bin``. Note that this
|
||||||
|
symlink, if installed, will use the "short" version, e.g. if the
|
||||||
|
``version`` specified is ``'3.5.3'`` then the symlink will be named
|
||||||
|
``'python3.5'``.
|
||||||
"""
|
"""
|
||||||
if not exists(c, '/usr/local/pythonz/pythons/CPython-{}'.format(version)):
|
if not exists(c, '/usr/local/pythonz/pythons/CPython-{}'.format(version)):
|
||||||
verbose = '--verbose' if verbose else ''
|
verbose = '--verbose' if verbose else ''
|
||||||
c.sudo("bash -lc 'pythonz install {} {}'".format(verbose, version))
|
c.sudo("bash -lc 'pythonz install {} {}'".format(verbose, version))
|
||||||
|
if globally:
|
||||||
|
short_version = '.'.join(version.split('.')[:2])
|
||||||
|
c.sudo('ln -sf /usr/local/pythonz/pythons/CPython-{0}/bin/python{1} /usr/local/bin/python{1}'.format(
|
||||||
|
version, short_version))
|
||||||
|
|
||||||
|
|
||||||
def install_pip(c, use_apt=False, eager=True):
|
def install_pip(c, use_apt=False, eager=True):
|
||||||
|
|
Loading…
Reference in a new issue