def setup_venv(code_path, requirements_file='requirements.txt'): """Initialise or update the virtual environment. It will also ensure build-essential is installed, though you may need to install required dev library using your own script. :param code_path: Base directory under which the venv dir should be made. :type code_path: str :param requirements_file: Name of the requirements file to use in the base directory. Defaults to ``requirements.txt``. :type requirements_file: str To run e.g.:: fab -H 192.168.1.1:2222 setup_venv """ setup_env() fastprint( blue('Setting up virtual env in: \n%s\nusing\n%s' % (code_path, requirements_file))) require_packages(['python-virtualenv', 'build-essential']) with cd(code_path): # Ensure we have a venv set up virtualenv('venv') run('venv/bin/pip install -r %s' % requirements_file) fastprint(green('Virtualenv setup completed.'))
def setup_venv(code_path, requirements_file='requirements.txt'): """Initialise or update the virtual environment. It will also ensure build-essential is installed, though you may need to install required dev library using your own script. :param code_path: Base directory under which the venv dir should be made. :type code_path: str :param requirements_file: Name of the requirements file to use in the base directory. Defaults to ``requirements.txt``. :type requirements_file: str To run e.g.:: fab -H 192.168.1.1:2222 setup_venv """ setup_env() fastprint(blue('Setting up virtual env in: \n%s\nusing\n%s' % ( code_path, requirements_file))) require_packages(['python-virtualenv', 'build-essential']) with cd(code_path): # Ensure we have a venv set up virtualenv('venv') run('venv/bin/pip install -r %s' % requirements_file) fastprint(green('Virtualenv setup completed.'))
def distribute(): """ Require `distribute`_ to be installed. .. _distribute: http://packages.python.org/distribute/ """ from fabtools.require.deb import packages as require_packages require_packages([ 'curl', 'python-dev', ]) if not is_distribute_installed(): install_distribute()
def setup_docker(force=False): """Setup docker on the target host. :param force: Whether to continue with installation even if docker already appears to be installed. Defaults to False. :type force: bool """ fastprint(yellow('Setting up docker on host: %s\n' % env.host)) if is_installed('lxc-docker'): fastprint(green( 'This system already appears to have docker installed on it\n')) else: version = run('uname -r') if '3.2' in version: # LTS 3.2 version is too old so we install a backported one # see http://docs.docker.io/en/latest/installation/ubuntulinux/ # #ubuntu-precise-12-04-lts-64-bit fastprint(red('Upgrading kernel to 3.8!\n')) response = prompt('Do you wish to continue? y/n :') if response != 'y': fastprint(red('Docker install aborted by user.\n')) return fastprint(blue('Ok upgrading kernel.')) require_packages([ 'linux-image-generic-lts-raring', 'linux-headers-generic-lts-raring']) fastprint(red('\nWe need to reboot the system now!\n')) response = prompt('Do you wish to continue? y/n :') if response is not None: reboot() else: require_package('linux-image-extra-%s' % version) require_ppa('ppa:dotcloud/lxc-docker') apt_get_update() require_packages([ 'software-properties-common', 'lxc-docker']) # Ensure ufw forwards traffic. # http://docs.docker.io/en/latest/installation/ubuntulinux/#ufw sed( '/etc/default/ufw', 'DEFAULT_FORWARD_POLICY="DROP"', 'DEFAULT_FORWARD_POLICY="ACCEPT"', use_sudo=False) setup_docker_image() setup_docker_user()
def setup_docker(force=False): """Setup docker on the target host. :param force: Whether to continue with installation even if docker already appears to be installed. Defaults to False. :type force: bool """ fastprint(yellow('Setting up docker on host: %s\n' % env.host)) if is_installed('lxc-docker'): fastprint( green( 'This system already appears to have docker installed on it\n') ) else: version = run('uname -r') if '3.2' in version: # LTS 3.2 version is too old so we install a backported one # see http://docs.docker.io/en/latest/installation/ubuntulinux/ # #ubuntu-precise-12-04-lts-64-bit fastprint(red('Upgrading kernel to 3.8!\n')) response = prompt('Do you wish to continue? y/n :') if response != 'y': fastprint(red('Docker install aborted by user.\n')) return fastprint(blue('Ok upgrading kernel.')) require_packages([ 'linux-image-generic-lts-raring', 'linux-headers-generic-lts-raring' ]) fastprint(red('\nWe need to reboot the system now!\n')) response = prompt('Do you wish to continue? y/n :') if response is not None: reboot() else: require_package('linux-image-extra-%s' % version) require_ppa('ppa:dotcloud/lxc-docker') apt_get_update() require_packages(['software-properties-common', 'lxc-docker']) # Ensure ufw forwards traffic. # http://docs.docker.io/en/latest/installation/ubuntulinux/#ufw sed('/etc/default/ufw', 'DEFAULT_FORWARD_POLICY="DROP"', 'DEFAULT_FORWARD_POLICY="ACCEPT"', use_sudo=False) setup_docker_image() setup_docker_user()
def build_pil(code_path): """Build pil with proper support for jpeg etc. :param code_path: Directory where the code lives. :type code_path: str .. note:: Any existing PIL will be uninstalled. .. versionadded: 0.16.0 """ require_packages(['libjpeg-dev', 'libfreetype6', 'libfreetype6-dev']) tcl = 'TCL_ROOT = None' jpg = 'JPEG_ROOT = None' zlib = 'ZLIB_ROOT = None' tiff = 'TIFF_ROOT = None' freetype = 'FREETYPE_ROOT = None' tcl_value = ( 'TCL_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') jpg_value = ( 'JPEG_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') zlib_value = ( 'ZLIB_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') tiff_value = ( 'TIFF_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') freetype_value = ( 'FREETYPE_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') venv = os.path.join(code_path, 'venv') with cd(venv): run('bin/pip uninstall pil') run('wget -c http://effbot.org/downloads/Imaging-1.1.7.tar.gz') run('tar xfz Imaging-1.1.7.tar.gz') with cd(os.path.join(venv, 'Imaging-1.1.7')): sed('setup.py', tcl, tcl_value) sed('setup.py', jpg, jpg_value) sed('setup.py', zlib, zlib_value) sed('setup.py', tiff, tiff_value) sed('setup.py', freetype, freetype_value) run('../bin/python setup.py install')
def install_from_source(version=DEFAULT_VERSION): """ Install Node JS from source. :: import fabtools # Install Node.js fabtools.nodejs.install_nodejs() .. note:: This function may not work for old versions of Node.js. """ from fabtools.require.deb import packages as require_packages from fabtools.require import file as require_file require_packages([ 'build-essential', 'python', 'libssl-dev', ]) filename = 'node-v%s.tar.gz' % version foldername = filename[0:-7] res = run('python -c "import multiprocessing ; print(multiprocessing.cpu_count())"') cpus = int(res) require_file(url='http://nodejs.org/dist/v%(version)s/%(filename)s' % { 'version': version, 'filename': filename, }) run('tar -xzf %s' % filename) with cd(foldername): run('./configure') run('make -j%d' % (cpus + 1)) run_as_root('make install') run('rm -rf %(filename)s %(foldername)s' % locals())
def build_pil(code_path): """Build pil with proper support for jpeg etc. :param code_path: Directory where the code lives. :type code_path: str .. note:: Any existing PIL will be uninstalled. .. versionadded: 0.16.0 """ require_packages(['libjpeg-dev', 'libfreetype6', 'libfreetype6-dev']) tcl = 'TCL_ROOT = None' jpg = 'JPEG_ROOT = None' zlib = 'ZLIB_ROOT = None' tiff = 'TIFF_ROOT = None' freetype = 'FREETYPE_ROOT = None' tcl_value = ('TCL_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') jpg_value = ('JPEG_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') zlib_value = ('ZLIB_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') tiff_value = ('TIFF_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') freetype_value = ( 'FREETYPE_ROOT = "/usr/lib/x86_64-linux-gnu/", "/usr/include"') venv = os.path.join(code_path, 'venv') with cd(venv): run('bin/pip uninstall pil') run('wget -c http://effbot.org/downloads/Imaging-1.1.7.tar.gz') run('tar xfz Imaging-1.1.7.tar.gz') with cd(os.path.join(venv, 'Imaging-1.1.7')): sed('setup.py', tcl, tcl_value) sed('setup.py', jpg, jpg_value) sed('setup.py', zlib, zlib_value) sed('setup.py', tiff, tiff_value) sed('setup.py', freetype, freetype_value) run('../bin/python setup.py install')