Add generic bootstrap_python()
logic
This commit is contained in:
parent
aa3ef708ad
commit
68088a6e71
16
rattail_fabric2/deploy/python/premkvirtualenv
Executable file
16
rattail_fabric2/deploy/python/premkvirtualenv
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# This hook is run after a new virtualenv is created and before it is activated.
|
||||||
|
|
||||||
|
cat >$1/pip.conf <<EOF
|
||||||
|
[global]
|
||||||
|
log-file = $WORKON_HOME/$1/pip.log
|
||||||
|
exists-action = i
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat >$1/bin/postactivate <<EOF
|
||||||
|
export PIP_CONFIG_FILE=$WORKON_HOME/$1/pip.conf
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat >$1/bin/postdeactivate <<EOF
|
||||||
|
unset PIP_CONFIG_FILE
|
||||||
|
EOF
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2018 Lance Edgar
|
# Copyright © 2010-2019 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -24,13 +24,35 @@
|
||||||
Fabric Library for Python
|
Fabric Library for Python
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
import six
|
from rattail_fabric2 import apt, exists, make_deploy, mkdir
|
||||||
|
|
||||||
from rattail_fabric2 import apt, exists, mkdir
|
|
||||||
|
deploy = make_deploy(__file__)
|
||||||
|
|
||||||
|
|
||||||
|
def bootstrap_python(c, pip_from_apt=True, workon_home='/srv/envs', user='rattail'):
|
||||||
|
"""
|
||||||
|
Bootstrap a "complete" Python install.
|
||||||
|
"""
|
||||||
|
# build dependencies
|
||||||
|
apt.install(
|
||||||
|
c,
|
||||||
|
'python-dev',
|
||||||
|
'python3-dev',
|
||||||
|
'libffi-dev',
|
||||||
|
'libjpeg-dev',
|
||||||
|
'libssl-dev',
|
||||||
|
)
|
||||||
|
|
||||||
|
# pip
|
||||||
|
install_pip(c, use_apt=pip_from_apt)
|
||||||
|
|
||||||
|
# virtualenvwrapper
|
||||||
|
workon_home = workon_home.rstrip('/')
|
||||||
|
install_virtualenvwrapper(c, workon_home=workon_home, user=user, configure_me=False)
|
||||||
|
deploy(c, 'python/premkvirtualenv', '{}/premkvirtualenv'.format(workon_home), owner=user, use_sudo=True)
|
||||||
|
|
||||||
|
|
||||||
def install_pip(c, use_apt=False, eager=True):
|
def install_pip(c, use_apt=False, eager=True):
|
||||||
|
@ -151,7 +173,7 @@ def cdvirtualenv(c, name, subdirs=[], workon_home='/srv/envs'):
|
||||||
"""
|
"""
|
||||||
Context manager to prefix your command(s) with the ``cdvirtualenv`` command.
|
Context manager to prefix your command(s) with the ``cdvirtualenv`` command.
|
||||||
"""
|
"""
|
||||||
if isinstance(subdirs, six.string_types):
|
if isinstance(subdirs, str):
|
||||||
subdirs = [subdirs]
|
subdirs = [subdirs]
|
||||||
path = '{}/{}'.format(workon_home, name)
|
path = '{}/{}'.format(workon_home, name)
|
||||||
if subdirs:
|
if subdirs:
|
||||||
|
|
Loading…
Reference in a new issue