Changeset - 68088a6e7102
[Not reviewed]
0 1 1
Lance Edgar - 5 years ago 2019-09-13 13:24:18
lance@edbob.org
Add generic `bootstrap_python()` logic
2 files changed with 44 insertions and 6 deletions:
0 comments (0 inline, 0 general) First comment
rattail_fabric2/deploy/python/premkvirtualenv
Show inline comments
 
new file 100755
 
#!/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
rattail_fabric2/python.py
Show inline comments
 
@@ -2,7 +2,7 @@
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2018 Lance Edgar
 
#  Copyright © 2010-2019 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -24,13 +24,35 @@
 
Fabric Library for Python
 
"""
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
from contextlib import contextmanager
 

	
 
import six
 
from rattail_fabric2 import apt, exists, make_deploy, 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)
 

	
 
from rattail_fabric2 import apt, exists, mkdir
 
    # 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):
 
@@ -151,7 +173,7 @@ def cdvirtualenv(c, name, subdirs=[], workon_home='/srv/envs'):
 
    """
 
    Context manager to prefix your command(s) with the ``cdvirtualenv`` command.
 
    """
 
    if isinstance(subdirs, six.string_types):
 
    if isinstance(subdirs, str):
 
        subdirs = [subdirs]
 
    path = '{}/{}'.format(workon_home, name)
 
    if subdirs:
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now