Ejemplo n.º 1
0
def test_invalid_recipe_order_and_bootstrap(names, bootstrap):
    with pytest.raises(BuildInterruptingException) as e_info:
        get_recipe_order_and_bootstrap(ctx, names, bootstrap)
    assert e_info.value.message == (
        "Didn't find any valid dependency graphs. "
        "This means that some of your requirements pull in conflicting dependencies."
    )
Ejemplo n.º 2
0
def test_invalid_recipe_order_and_bootstrap(names, bootstrap):
    with pytest.raises(BuildInterruptingException) as e_info:
        get_recipe_order_and_bootstrap(ctx, names, bootstrap)
    assert e_info.value.message == (
        "Didn't find any valid dependency graphs. "
        "This means that some of your requirements pull in conflicting dependencies."
    )
Ejemplo n.º 3
0
def build_dist_from_args(ctx, dist, args_list):
    '''Parses out any bootstrap related arguments, and uses them to build
    a dist.'''
    parser = argparse.ArgumentParser(description='Create a newAndroid project')
    parser.add_argument('--bootstrap',
                        help=('The name of the bootstrap type, \'pygame\' '
                              'or \'sdl2\', or leave empty to let a '
                              'bootstrap be chosen automatically from your '
                              'requirements.'),
                        default=None)
    args, unknown = parser.parse_known_args(args_list)

    bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
    build_order, python_modules, bs \
        = get_recipe_order_and_bootstrap(ctx, dist.recipes, bs)

    info('The selected bootstrap is {}'.format(bs.name))
    info_main('# Creating dist with {} bootstrap'.format(bs.name))
    bs.distribution = dist
    info_notify('Dist will have name {} and recipes ({})'.format(
        dist.name, ', '.join(dist.recipes)))

    ctx.dist_name = bs.distribution.name
    ctx.prepare_bootstrap(bs)
    ctx.prepare_dist(ctx.dist_name)

    build_recipes(build_order, python_modules, ctx)

    ctx.bootstrap.run_distribute()

    info_main('# Your distribution was created successfully, exiting.')
    info('Dist can be found at (for now) {}'.format(
        join(ctx.dist_dir, ctx.dist_name)))

    return unknown
Ejemplo n.º 4
0
def main():
    target_python = TargetPython.python3
    recipes = modified_recipes()
    logger.info('recipes modified: {}'.format(recipes))
    recipes -= CORE_RECIPES
    logger.info('recipes to build: {}'.format(recipes))
    context = Context()

    # removing the deleted recipes for the given target (if any)
    for recipe_name in recipes.copy():
        try:
            Recipe.get_recipe(recipe_name, context)
        except ValueError:
            # recipe doesn't exist, so probably we remove it
            recipes.remove(recipe_name)
            logger.warning(
                'removed {} from recipes because deleted'.format(recipe_name))

    # forces the default target
    recipes_and_target = recipes | set([target_python.name])
    try:
        build_order, python_modules, bs = get_recipe_order_and_bootstrap(
            context, recipes_and_target, None)
    except BuildInterruptingException:
        # fallback to python2 if default target is not compatible
        logger.info('incompatible with {}'.format(target_python.name))
        target_python = TargetPython.python2
        logger.info('falling back to {}'.format(target_python.name))
    # removing the known broken recipe for the given target
    broken_recipes = BROKEN_RECIPES[target_python]
    recipes -= broken_recipes
    logger.info('recipes to build (no broken): {}'.format(recipes))
    build(target_python, recipes)
Ejemplo n.º 5
0
def build_dist_from_args(ctx, dist, args):
    '''Parses out any bootstrap related arguments, and uses them to build
    a dist.'''
    bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
    build_order, python_modules, bs \
        = get_recipe_order_and_bootstrap(ctx, dist.recipes, bs)
    ctx.recipe_build_order = build_order
    ctx.python_modules = python_modules

    if python_modules and hasattr(sys, 'real_prefix'):
        error('virtualenv is needed to install pure-Python modules, but')
        error('virtualenv does not support nesting, and you are running')
        error('python-for-android in one. Please run p4a outside of a')
        error('virtualenv instead.')
        exit(1)

    info('The selected bootstrap is {}'.format(bs.name))
    info_main('# Creating dist with {} bootstrap'.format(bs.name))
    bs.distribution = dist
    info_notify('Dist will have name {} and recipes ({})'.format(
        dist.name, ', '.join(dist.recipes)))

    ctx.dist_name = bs.distribution.name
    ctx.prepare_bootstrap(bs)
    ctx.prepare_dist(ctx.dist_name)

    build_recipes(build_order, python_modules, ctx)

    ctx.bootstrap.run_distribute()

    info_main('# Your distribution was created successfully, exiting.')
    info('Dist can be found at (for now) {}'
         .format(join(ctx.dist_dir, ctx.dist_name)))
Ejemplo n.º 6
0
def build_dist_from_args(ctx, dist, args):
    '''Parses out any bootstrap related arguments, and uses them to build
    a dist.'''
    bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
    build_order, python_modules, bs \
        = get_recipe_order_and_bootstrap(ctx, dist.recipes, bs)
    ctx.recipe_build_order = build_order

    info('The selected bootstrap is {}'.format(bs.name))
    info_main('# Creating dist with {} bootstrap'.format(bs.name))
    bs.distribution = dist
    info_notify('Dist will have name {} and recipes ({})'.format(
        dist.name, ', '.join(dist.recipes)))

    ctx.dist_name = bs.distribution.name
    ctx.prepare_bootstrap(bs)
    ctx.prepare_dist(ctx.dist_name)

    build_recipes(build_order, python_modules, ctx)

    ctx.bootstrap.run_distribute()

    info_main('# Your distribution was created successfully, exiting.')
    info('Dist can be found at (for now) {}'
         .format(join(ctx.dist_dir, ctx.dist_name)))
Ejemplo n.º 7
0
def build_dist_from_args(ctx, dist, args):
    """Parses out any bootstrap related arguments, and uses them to build
    a dist."""
    bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
    build_order, python_modules, bs \
        = get_recipe_order_and_bootstrap(ctx, dist.recipes, bs)
    ctx.recipe_build_order = build_order
    ctx.python_modules = python_modules

    info('The selected bootstrap is {}'.format(bs.name))
    info_main('# Creating dist with {} bootstrap'.format(bs.name))
    bs.distribution = dist
    info_notify('Dist will have name {} and recipes ({})'.format(
        dist.name, ', '.join(dist.recipes)))
    info('Dist will also contain modules ({}) installed from pip'.format(
        ', '.join(ctx.python_modules)))

    ctx.dist_name = bs.distribution.name
    ctx.prepare_bootstrap(bs)
    if dist.needs_build:
        ctx.prepare_dist(ctx.dist_name)

    build_recipes(build_order, python_modules, ctx)

    ctx.bootstrap.run_distribute()

    info_main('# Your distribution was created successfully, exiting.')
    info('Dist can be found at (for now) {}'.format(
        join(ctx.dist_dir, ctx.dist_name)))
Ejemplo n.º 8
0
def build_dist_from_args(ctx, dist, args):
    '''Parses out any bootstrap related arguments, and uses them to build
    a dist.'''
    bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
    build_order, python_modules, bs \
        = get_recipe_order_and_bootstrap(ctx, dist.recipes, bs)
    ctx.recipe_build_order = build_order
    ctx.python_modules = python_modules

    if python_modules and hasattr(sys, 'real_prefix'):
        error('virtualenv is needed to install pure-Python modules, but')
        error('virtualenv does not support nesting, and you are running')
        error('python-for-android in one. Please run p4a outside of a')
        error('virtualenv instead.')
        exit(1)

    info('The selected bootstrap is {}'.format(bs.name))
    info_main('# Creating dist with {} bootstrap'.format(bs.name))
    bs.distribution = dist
    info_notify('Dist will have name {} and recipes ({})'.format(
        dist.name, ', '.join(dist.recipes)))
    info('Dist will also contain modules ({}) installed from pip'.format(
        ', '.join(ctx.python_modules)))

    ctx.dist_name = bs.distribution.name
    ctx.prepare_bootstrap(bs)
    ctx.prepare_dist(ctx.dist_name)

    build_recipes(build_order, python_modules, ctx)

    ctx.bootstrap.run_distribute()

    info_main('# Your distribution was created successfully, exiting.')
    info('Dist can be found at (for now) {}'
         .format(join(ctx.dist_dir, ctx.dist_name)))
 def setUp(self):
     """
     Setups recipe and context.
     """
     self.context = Context()
     self.arch = ArchARMv7_a(self.context)
     self.recipe = Recipe.get_recipe('reportlab', self.context)
     self.recipe.ctx = self.context
     self.bootstrap = None
     recipe_build_order, python_modules, bootstrap = \
         get_recipe_order_and_bootstrap(
             self.context, [self.recipe.name], self.bootstrap)
     self.context.recipe_build_order = recipe_build_order
     self.context.python_modules = python_modules
     self.context.setup_dirs(tempfile.gettempdir())
     self.bootstrap = bootstrap
     self.recipe_dir = self.recipe.get_build_dir(self.arch.arch)
     ensure_dir(self.recipe_dir)
Ejemplo n.º 10
0
def main():
    target_python = TargetPython.python3
    recipes = modified_recipes()
    print('recipes modified:', recipes)
    recipes -= CORE_RECIPES
    print('recipes to build:', recipes)
    context = Context()
    build_order, python_modules, bs = get_recipe_order_and_bootstrap(
        context, recipes, None)
    # fallback to python2 if default target is not compatible
    if target_python.name not in build_order:
        print('incompatible with {}'.format(target_python.name))
        target_python = TargetPython.python2
        print('falling back to {}'.format(target_python.name))
    # removing the known broken recipe for the given target
    broken_recipes = BROKEN_RECIPES[target_python]
    recipes -= broken_recipes
    print('recipes to build (no broken):', recipes)
    build(target_python, recipes)
def main():
    target_python = TargetPython.python3crystax
    recipes = modified_recipes()
    print('recipes modified:', recipes)
    recipes -= CORE_RECIPES
    print('recipes to build:', recipes)
    context = Context()
    build_order, python_modules, bs = get_recipe_order_and_bootstrap(
        context, recipes, None)
    # fallback to python2 if default target is not compatible
    if target_python.name not in build_order:
        print('incompatible with {}'.format(target_python.name))
        target_python = TargetPython.python2
        print('falling back to {}'.format(target_python.name))
    # removing the known broken recipe for the given target
    broken_recipes = BROKEN_RECIPES[target_python]
    recipes -= broken_recipes
    print('recipes to build (no broken):', recipes)
    build(target_python, recipes)
Ejemplo n.º 12
0
def build_dist_from_args(ctx, dist, args):
    """Parses out any bootstrap related arguments, and uses them to build
    a dist."""
    bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
    blacklist = getattr(args, "blacklist_requirements", "").split(",")
    if len(blacklist) == 1 and blacklist[0] == "":
        blacklist = []
    build_order, python_modules, bs = (
        get_recipe_order_and_bootstrap(
            ctx, dist.recipes, bs,
            blacklist=blacklist
        ))
    assert set(build_order).intersection(set(python_modules)) == set()
    ctx.recipe_build_order = build_order
    ctx.python_modules = python_modules

    info('The selected bootstrap is {}'.format(bs.name))
    info_main('# Creating dist with {} bootstrap'.format(bs.name))
    bs.distribution = dist
    info_notify('Dist will have name {} and requirements ({})'.format(
        dist.name, ', '.join(dist.recipes)))
    info('Dist contains the following requirements as recipes: {}'.format(
        ctx.recipe_build_order))
    info('Dist will also contain modules ({}) installed from pip'.format(
        ', '.join(ctx.python_modules)))

    ctx.distribution = dist
    ctx.prepare_bootstrap(bs)
    if dist.needs_build:
        ctx.prepare_dist()

    build_recipes(build_order, python_modules, ctx,
                  getattr(args, "private", None),
                  ignore_project_setup_py=getattr(
                      args, "ignore_setup_py", False
                  ),
                 )

    ctx.bootstrap.run_distribute()

    info_main('# Your distribution was created successfully, exiting.')
    info('Dist can be found at (for now) {}'
         .format(join(ctx.dist_dir, ctx.distribution.dist_dir)))
def main():
    target_python = TargetPython.python3
    recipes = modified_recipes()
    logger.info('recipes modified: {}'.format(recipes))
    recipes -= CORE_RECIPES
    logger.info('recipes to build: {}'.format(recipes))
    context = Context()
    # forces the default target
    recipes_and_target = recipes | set([target_python.name])
    try:
        build_order, python_modules, bs = get_recipe_order_and_bootstrap(
            context, recipes_and_target, None)
    except BuildInterruptingException:
        # fallback to python2 if default target is not compatible
        logger.info('incompatible with {}'.format(target_python.name))
        target_python = TargetPython.python2
        logger.info('falling back to {}'.format(target_python.name))
    # removing the known broken recipe for the given target
    broken_recipes = BROKEN_RECIPES[target_python]
    recipes -= broken_recipes
    logger.info('recipes to build (no broken): {}'.format(recipes))
    build(target_python, recipes)
def main():
    target_python = TargetPython.python3
    recipes = modified_recipes()
    logger.info('recipes modified: {}'.format(recipes))
    recipes -= CORE_RECIPES
    logger.info('recipes to build: {}'.format(recipes))
    context = Context()
    # forces the default target
    recipes_and_target = recipes | set([target_python.name])
    try:
        build_order, python_modules, bs = get_recipe_order_and_bootstrap(
            context, recipes_and_target, None)
    except BuildInterruptingException:
        # fallback to python2 if default target is not compatible
        logger.info('incompatible with {}'.format(target_python.name))
        target_python = TargetPython.python2
        logger.info('falling back to {}'.format(target_python.name))
    # removing the known broken recipe for the given target
    broken_recipes = BROKEN_RECIPES[target_python]
    recipes -= broken_recipes
    logger.info('recipes to build (no broken): {}'.format(recipes))
    build(target_python, recipes)
Ejemplo n.º 15
0
def build_dist_from_args(ctx, dist, args_list):
    '''Parses out any bootstrap related arguments, and uses them to build
    a dist.'''
    parser = argparse.ArgumentParser(
        description='Create a newAndroid project')
    parser.add_argument(
        '--bootstrap',
        help=('The name of the bootstrap type, \'pygame\' '
              'or \'sdl2\', or leave empty to let a '
              'bootstrap be chosen automatically from your '
              'requirements.'),
        default=None)
    args, unknown = parser.parse_known_args(args_list)

    bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
    build_order, python_modules, bs \
        = get_recipe_order_and_bootstrap(ctx, dist.recipes, bs)

    info('The selected bootstrap is {}'.format(bs.name))
    info_main('# Creating dist with {} bootstrap'.format(bs.name))
    bs.distribution = dist
    info_notify('Dist will have name {} and recipes ({})'.format(
        dist.name, ', '.join(dist.recipes)))

    ctx.dist_name = bs.distribution.name
    ctx.prepare_bootstrap(bs)
    ctx.prepare_dist(ctx.dist_name)

    build_recipes(build_order, python_modules, ctx)

    ctx.bootstrap.run_distribute()

    info_main('# Your distribution was created successfully, exiting.')
    info('Dist can be found at (for now) {}'
         .format(join(ctx.dist_dir, ctx.dist_name)))

    return unknown
Ejemplo n.º 16
0
def test_blacklist():
    # First, get order without blacklist:
    build_order, python_modules, bs = get_recipe_order_and_bootstrap(
        ctx, ["python3", "kivy"], None)
    # Now, obtain again with blacklist:
    build_order_2, python_modules_2, bs_2 = get_recipe_order_and_bootstrap(
        ctx, ["python3", "kivy"], None, blacklist=["libffi"])
    assert "libffi" not in build_order_2
    assert set(build_order_2).union({"libffi"}) == set(build_order)

    # Check that we get a conflict when using webview and kivy combined:
    wbootstrap = Bootstrap.get_bootstrap('webview', ctx)
    with pytest.raises(BuildInterruptingException) as e_info:
        get_recipe_order_and_bootstrap(ctx, ["flask", "kivy"], wbootstrap)
    assert "conflict" in e_info.value.message.lower()

    # We should no longer get a conflict blacklisting sdl2:
    get_recipe_order_and_bootstrap(ctx, ["flask", "kivy"],
                                   wbootstrap,
                                   blacklist=["sdl2"])
Ejemplo n.º 17
0
def test_blacklist():
    # First, get order without blacklist:
    build_order, python_modules, bs = get_recipe_order_and_bootstrap(
        ctx, ["python3", "kivy"], None
    )
    # Now, obtain again with blacklist:
    build_order_2, python_modules_2, bs_2 = get_recipe_order_and_bootstrap(
        ctx, ["python3", "kivy"], None, blacklist=["libffi"]
    )
    assert "libffi" not in build_order_2
    assert set(build_order_2).union({"libffi"}) == set(build_order)

    # Check that we get a conflict when using webview and kivy combined:
    wbootstrap = Bootstrap.get_bootstrap('webview', ctx)
    with pytest.raises(BuildInterruptingException) as e_info:
        get_recipe_order_and_bootstrap(ctx, ["flask", "kivy"], wbootstrap)
    assert "conflict" in e_info.value.message.lower()

    # We should no longer get a conflict blacklisting sdl2 and pygame:
    get_recipe_order_and_bootstrap(
        ctx, ["flask", "kivy"], wbootstrap, blacklist=["sdl2", "pygame"]
    )
     (['kivy', 'python3crystax'], Bootstrap.get_bootstrap('sdl2', ctx))])
invalid_combinations = [[['python2', 'python3crystax'], None]]


@pytest.mark.parametrize('names,bootstrap', valid_combinations)
def test_valid_recipe_order_and_bootstrap(names, bootstrap):
    get_recipe_order_and_bootstrap(ctx, names, bootstrap)


@pytest.mark.parametrize('names,bootstrap', invalid_combinations)
def test_invalid_recipe_order_and_bootstrap(names, bootstrap):
    with pytest.raises(SystemExit):
        get_recipe_order_and_bootstrap(ctx, names, bootstrap)


def test_bootstrap_dependency_addition():
    build_order, python_modules, bs = get_recipe_order_and_bootstrap(
        ctx, ['kivy'], None)
    assert (('hostpython2' in build_order) or ('hostpython3' in build_order))


def test_bootstrap_dependency_addition2():
    build_order, python_modules, bs = get_recipe_order_and_bootstrap(
        ctx, ['kivy', 'python2'], None)
    assert 'hostpython2' in build_order


if __name__ == "__main__":
    get_recipe_order_and_bootstrap(ctx, ['python3'],
                                   Bootstrap.get_bootstrap('sdl2', ctx))
Ejemplo n.º 19
0
def test_invalid_recipe_order_and_bootstrap(names, bootstrap):
    with pytest.raises(BuildInterruptingException) as e_info:
        get_recipe_order_and_bootstrap(ctx, names, bootstrap)
    assert "conflict" in e_info.value.message.lower()
def test_bootstrap_dependency_addition2():
    build_order, python_modules, bs = get_recipe_order_and_bootstrap(
        ctx, ['kivy', 'python2'], None)
    assert 'hostpython2' in build_order
def test_invalid_recipe_order_and_bootstrap(names, bootstrap):
    with pytest.raises(SystemExit):
        get_recipe_order_and_bootstrap(ctx, names, bootstrap)
def test_valid_recipe_order_and_bootstrap(names, bootstrap):
    get_recipe_order_and_bootstrap(ctx, names, bootstrap)
Ejemplo n.º 23
0
def test_invalid_recipe_order_and_bootstrap(names, bootstrap):
    with pytest.raises(BuildInterruptingException) as e_info:
        get_recipe_order_and_bootstrap(ctx, names, bootstrap)
    assert "conflict" in e_info.value.message.lower()