Improve support for installing pip etc. on python3

namely this is for the sake of newer Ubuntu which doesn't include python2 by
default, and this affects some other package names
This commit is contained in:
Lance Edgar 2020-09-08 18:01:53 -05:00
parent 84c345ce39
commit 3d5b7c1d6e

View file

@ -35,22 +35,24 @@ deploy = make_deploy(__file__)
def bootstrap_python(c, pip_from_apt=True, pip_eager=True,
virtualenvwrapper_from_apt=False,
upgrade_virtualenvwrapper=True,
workon_home='/srv/envs', user='rattail'):
workon_home='/srv/envs', user='rattail',
python3=False):
"""
Bootstrap a "complete" Python install.
"""
# build dependencies
apt.install(
c,
'python-dev',
'python3-dev',
'libffi-dev',
'libjpeg-dev',
'libssl-dev',
)
if not python3:
apt.install(c, 'python-dev')
# pip
install_pip(c, use_apt=pip_from_apt, eager=pip_eager)
install_pip(c, use_apt=pip_from_apt, python3=python3, eager=pip_eager)
# virtualenvwrapper
workon_home = workon_home.rstrip('/')
@ -102,12 +104,15 @@ def install_python(c, version, globally=False, verbose=False):
version, short_version))
def install_pip(c, use_apt=False, eager=True):
def install_pip(c, use_apt=False, python3=False, eager=True):
"""
Install/upgrade the Pip installer for Python.
"""
if use_apt:
apt.install(c, 'python-pip')
if python3:
apt.install(c, 'python3-pip')
else:
apt.install(c, 'python-pip')
else:
apt.install(c, 'build-essential', 'python-dev', 'libssl-dev', 'libffi-dev')
if c.run('which pip', warn=True).failed:
@ -157,6 +162,8 @@ def install_virtualenvwrapper(c, workon_home='/srv/envs', user='root',
mkdir(c, workon_home, owner=user, use_sudo=True)
if use_apt:
apt.install(c, 'virtualenvwrapper')
configure_virtualenvwrapper(c, user, workon_home,
wrapper='/usr/share/virtualenvwrapper/virtualenvwrapper.sh')
else:
pip(c, 'virtualenvwrapper', upgrade=upgrade)
configure_virtualenvwrapper(c, user, workon_home)