configurationengine/build-scripts/install_cone.py
author terytkon
Thu, 11 Mar 2010 17:04:37 +0200
changeset 0 2e8eeb919028
child 3 e7e0ae78773e
permissions -rw-r--r--
Adding EPL version of configurationengine.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     1
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     3
# All rights reserved.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     4
# This component and the accompanying materials are made available
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     6
# which accompanies this distribution, and is available
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     8
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     9
# Initial Contributors:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    11
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    12
# Contributors:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    13
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    14
# Description: 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    15
#   Script for building and installing ConE into a specified directory.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    16
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    17
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
import sys, os, shutil, subprocess, optparse
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
import logging
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
log = logging.getLogger()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
import utils
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
utils.setup_logging('install_cone.log')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
SOURCE_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '../source'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
assert os.path.isdir(SOURCE_ROOT)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
SCRIPTS_SOURCE_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '../source/scripts'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
assert os.path.isdir(SCRIPTS_SOURCE_ROOT)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
PLUGIN_SOURCE_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '../source/plugins'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
assert os.path.isdir(PLUGIN_SOURCE_ROOT)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
sys.path.append(PLUGIN_SOURCE_ROOT)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
import plugin_utils
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
# Temporary directory where ConE eggs are built into
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
TEMP_CONE_EGG_DIR = os.path.join(ROOT_PATH, 'install-temp/cone-eggs')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
# Temporary directory where dependency lib eggs are copied
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
TEMP_LIB_EGG_DIR = os.path.join(ROOT_PATH, 'install-temp/dep-eggs')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
class BuildFailedError(RuntimeError):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
    pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
def find_cone_egg_sources(plugin_package):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
    """
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
    Return a list of paths to the source directories to install.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
    """
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
    paths = [SOURCE_ROOT,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
             SCRIPTS_SOURCE_ROOT]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
    plugin_paths = plugin_utils.find_plugin_sources_by_package(plugin_package)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
    paths.extend(plugin_paths)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
    log.debug("ConE egg source paths:\n%s" % '\n'.join(paths))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
    return paths
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
def build_cone_eggs(source_paths):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
    log.info("Cleaning temporary ConE egg dir...")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
    utils.recreate_dir(TEMP_CONE_EGG_DIR)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
    log.info("Building ConE eggs...")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
    for source_path in source_paths:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
        ok = utils.build_egg(source_path, TEMP_CONE_EGG_DIR)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
        if not ok:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
            raise BuildFailedError()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
def retrieve_dep_eggs(plugin_package):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
    log.info("Cleaning temporary lib egg dir...")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
    utils.recreate_dir(TEMP_LIB_EGG_DIR)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
    log.info("Retrieving dependency eggs...")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
    def copy_eggs(source_dir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
        log.debug("Copying eggs from '%s'..." % source_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
        for name in os.listdir(source_dir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
            if name.endswith('.egg'):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
                utils.copy_file(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
                    source_path = os.path.join(source_dir, name),
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
                    target_path = TEMP_LIB_EGG_DIR)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
   
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
    dep_dirs_by_package = [(None, os.path.join(ROOT_PATH, '../dep-eggs'))]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
    dep_dirs_by_package.extend(plugin_utils.find_plugin_package_subpaths('dep-eggs', plugin_package))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
    for package_name, dep_dir in dep_dirs_by_package:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    85
        copy_eggs(dep_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    86
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    87
def init_target_dir(target_dir, python_version):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    88
    BASE_DIR = os.path.normpath(os.path.join(target_dir, 'cone', python_version))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    89
    LIB_DIR     = os.path.join(BASE_DIR, 'lib')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    90
    SCRIPT_DIR  = os.path.join(BASE_DIR, 'scripts')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    91
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    92
    utils.recreate_dir(BASE_DIR)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    93
    utils.recreate_dir(LIB_DIR)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    94
    utils.recreate_dir(SCRIPT_DIR)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    95
    return LIB_DIR, SCRIPT_DIR
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    96
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    97
def install_cone_eggs(target_dir, python_version):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    98
    """
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    99
    Install ConE eggs into the given target directory.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   100
    """
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   101
    log.info("Installing ConE eggs...")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   102
    LIB_DIR, SCRIPT_DIR = init_target_dir(target_dir, python_version)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   103
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   104
    # Collect the eggs to install
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   105
    eggs = ['setuptools'] # Setuptools are needed also
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   106
    for name in os.listdir(TEMP_CONE_EGG_DIR):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   107
        if name.endswith('.egg'):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   108
            eggs.append(TEMP_CONE_EGG_DIR + '/' + name)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   109
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   110
    # Run easy_install to install the eggs
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   111
    for egg in eggs:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   112
        log.debug(egg)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   113
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   114
        if sys.platform == "win32":
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   115
            platform_args = ["--always-copy"]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   116
        else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   117
            platform_args = ["--no-deps"]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   118
                    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   119
        command = ['easy_install',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   120
                   '--allow-hosts None',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   121
                   '--find-links install-temp/dep-eggs',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   122
                   '--install-dir "%s"' % LIB_DIR,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   123
                   '--script-dir "%s"' % SCRIPT_DIR,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   124
                   '--site-dirs "%s"' % LIB_DIR]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   125
        command.extend(platform_args)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   126
        command.append('"' + egg + '"')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   127
        command = ' '.join(command)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   128
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   129
        log.debug(command)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   130
        ok = utils.run_command(command, env_overrides={'PYTHONPATH': LIB_DIR})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   131
        if not ok:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   132
            raise BuildFailedError()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   133
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   134
def develop_install_cone_sources(source_paths, target_dir, python_version):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   135
    log.info("Installing ConE sources in develop mode...")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   136
    LIB_DIR, SCRIPT_DIR = init_target_dir(target_dir, python_version)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   137
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   138
    orig_workdir = os.getcwd()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   139
    try:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   140
        for source_path in source_paths:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   141
            os.chdir(source_path)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   142
            command = ['python setup.py develop',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   143
                   '--allow-hosts None',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   144
                   '--find-links "%s"' % os.path.normpath(os.path.join(ROOT_PATH, 'install-temp/dep-eggs')),
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   145
                   '--install-dir "%s"' % LIB_DIR,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   146
                   '--script-dir "%s"' % SCRIPT_DIR,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   147
                   '--site-dirs "%s"' % LIB_DIR,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   148
                   '--always-copy']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   149
            command = ' '.join(command)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   150
            log.debug(command)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   151
            ok = utils.run_command(command, env_overrides={'PYTHONPATH': LIB_DIR})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   152
            if not ok:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   153
                raise BuildFailedError()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   154
    finally:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   155
        os.chdir(orig_workdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   156
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   157
def perform_build(target_dir, plugin_package, install_type, python_version):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   158
    log.info("Target directory: %s" % target_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   159
    log.info("Plug-in package:  %r" % plugin_package)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   160
    log.info("Python version:   %s" % python_version)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   161
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   162
    # Retrieve dependencies to the correct location
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   163
    retrieve_dep_eggs(plugin_package)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   164
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   165
    # Find paths to the sources to install
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   166
    source_paths = find_cone_egg_sources(plugin_package)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   167
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   168
    log.info("Creating install directory...")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   169
    if not os.path.exists(target_dir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   170
        os.makedirs(target_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   171
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   172
    if install_type == 'install':
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   173
        build_cone_eggs(source_paths)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   174
        install_cone_eggs(target_dir, python_version)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   175
    else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   176
        develop_install_cone_sources(source_paths, target_dir, python_version)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   177
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   178
    # Copy RELEASE.txt
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   179
    utils.copy_file(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   180
        source_path = os.path.join(SOURCE_ROOT, '..', 'RELEASE.TXT'),
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   181
        target_path = os.path.join(target_dir, 'cone', 'RELEASE.TXT'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   182
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   183
    # Copy cone.cmd or cone.sh, depending on the platform
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   184
    if sys.platform == "win32":
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   185
        filename = "cone.cmd"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   186
    else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   187
        filename = "cone.sh"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   188
    log.info("Copying %s" % filename)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   189
    utils.copy_file(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   190
        source_path = os.path.join(SOURCE_ROOT, filename),
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   191
        target_path = target_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   192
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   193
def main():
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   194
    parser = optparse.OptionParser()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   195
    parser.add_option("-t", "--target-dir",
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   196
                      help="The directory where ConE is to be installed.")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   197
    parser.add_option("-p", "--plugin-package",\
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   198
                      help="The plug-in package to include in the installation.",\
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   199
                      default=None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   200
    parser.add_option("-i", "--install-type",\
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   201
                      help="The installation type, can be 'install' (the default) or 'develop'.",\
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   202
                      default='install')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   203
    (options, args) = parser.parse_args()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   204
    if options.target_dir is None:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   205
        parser.error("Target directory must be given")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   206
    if options.install_type not in ('install', 'develop'):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   207
        parser.error("Invalid install type ('%s')" % options.install_type)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   208
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   209
    if not utils.run_command("python --help"):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   210
        log.critical("Could not run 'python'. Please make sure that you "\
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   211
                     "have Python installed and in your path.")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   212
        return 1
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   213
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   214
    if not utils.run_command("easy_install --help"):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   215
        log.critical("Could not run 'easy_install'. Please make sure that you "\
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   216
                     "have setuptools installed and the Python scripts directory in your path.")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   217
        return 1
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   218
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   219
    python_version = utils.get_python_version()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   220
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   221
    try:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   222
        perform_build(options.target_dir, options.plugin_package, options.install_type, python_version)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   223
    except BuildFailedError:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   224
        return 1
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   225
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   226
    return 0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   227
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   228
if __name__ == "__main__":
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   229
    sys.exit(main())