当前位置: 首页>>代码示例>>Python>>正文


Python recipe.Recipe类代码示例

本文整理汇总了Python中pythonforandroid.recipe.Recipe的典型用法代码示例。如果您正苦于以下问题:Python Recipe类的具体用法?Python Recipe怎么用?Python Recipe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Recipe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: recipes

    def recipes(self, args):
        parser = argparse.ArgumentParser(
                description="List all the available recipes")
        parser.add_argument(
                "--compact", action="store_true", default=False,
                help="Produce a compact list suitable for scripting")

        args = parser.parse_args(args)

        ctx = self.ctx
        if args.compact:
            print(" ".join(set(Recipe.list_recipes(ctx))))
        else:
            for name in sorted(Recipe.list_recipes(ctx)):
                recipe = Recipe.get_recipe(name, ctx)
                version = str(recipe.version)
                print('{Fore.BLUE}{Style.BRIGHT}{recipe.name:<12} '
                      '{Style.RESET_ALL}{Fore.LIGHTBLUE_EX}'
                      '{version:<8}{Style.RESET_ALL}'.format(
                        recipe=recipe, Fore=Out_Fore, Style=Out_Style,
                        version=version))
                print('    {Fore.GREEN}depends: {recipe.depends}'
                      '{Fore.RESET}'.format(recipe=recipe, Fore=Out_Fore))
                if recipe.conflicts:
                    print('    {Fore.RED}conflicts: {recipe.conflicts}'
                          '{Fore.RESET}'
                          .format(recipe=recipe, Fore=Out_Fore))
                if recipe.opt_depends:
                    print('    {Fore.YELLOW}optional depends: '
                          '{recipe.opt_depends}{Fore.RESET}'
                          .format(recipe=recipe, Fore=Out_Fore))
开发者ID:ed00m,项目名称:python-for-android,代码行数:31,代码来源:toolchain.py

示例2: set_libs_flags

    def set_libs_flags(self, env, arch):
        '''Takes care to properly link libraries with python depending on our
        requirements and the attribute :attr:`opt_depends`.
        '''
        def add_flags(include_flags, link_dirs, link_libs):
            env['CPPFLAGS'] = env.get('CPPFLAGS', '') + include_flags
            env['LDFLAGS'] = env.get('LDFLAGS', '') + link_dirs
            env['LIBS'] = env.get('LIBS', '') + link_libs

        if 'sqlite3' in self.ctx.recipe_build_order:
            info('Activating flags for sqlite3')
            recipe = Recipe.get_recipe('sqlite3', self.ctx)
            add_flags(' -I' + recipe.get_build_dir(arch.arch),
                      ' -L' + recipe.get_lib_dir(arch), ' -lsqlite3')

        if 'libffi' in self.ctx.recipe_build_order:
            info('Activating flags for libffi')
            recipe = Recipe.get_recipe('libffi', self.ctx)
            # In order to force the correct linkage for our libffi library, we
            # set the following variable to point where is our libffi.pc file,
            # because the python build system uses pkg-config to configure it.
            env['PKG_CONFIG_PATH'] = recipe.get_build_dir(arch.arch)
            add_flags(' -I' + ' -I'.join(recipe.get_include_dirs(arch)),
                      ' -L' + join(recipe.get_build_dir(arch.arch), '.libs'),
                      ' -lffi')

        if 'openssl' in self.ctx.recipe_build_order:
            info('Activating flags for openssl')
            recipe = Recipe.get_recipe('openssl', self.ctx)
            add_flags(recipe.include_flags(arch),
                      recipe.link_dirs_flags(arch), recipe.link_libs_flags())
        return env
开发者ID:kronenpj,项目名称:python-for-android,代码行数:32,代码来源:python.py

示例3: get_bootstrap_from_recipes

 def get_bootstrap_from_recipes(cls, recipes, ctx):
     '''Returns a bootstrap whose recipe requirements do not conflict with
     the given recipes.'''
     info('Trying to find a bootstrap that matches the given recipes.')
     bootstraps = [cls.get_bootstrap(name, ctx)
                   for name in cls.list_bootstraps()]
     acceptable_bootstraps = []
     for bs in bootstraps:
         if not bs.can_be_chosen_automatically:
             continue
         possible_dependency_lists = expand_dependencies(bs.recipe_depends)
         for possible_dependencies in possible_dependency_lists:
             ok = True
             for recipe in possible_dependencies:
                 recipe = Recipe.get_recipe(recipe, ctx)
                 if any([conflict in recipes for conflict in recipe.conflicts]):
                     ok = False
                     break
             for recipe in recipes:
                 recipe = Recipe.get_recipe(recipe, ctx)
                 if any([conflict in possible_dependencies
                         for conflict in recipe.conflicts]):
                     ok = False
                     break
             if ok:
                 acceptable_bootstraps.append(bs)
     info('Found {} acceptable bootstraps: {}'.format(
         len(acceptable_bootstraps),
         [bs.name for bs in acceptable_bootstraps]))
     if acceptable_bootstraps:
         info('Using the first of these: {}'
              .format(acceptable_bootstraps[0].name))
         return acceptable_bootstraps[0]
     return None
开发者ID:TarvosEpilepsy,项目名称:python-for-android,代码行数:34,代码来源:bootstrap.py

示例4: recipes

 def recipes(self, args):
     ctx = self.ctx
     if args.compact:
         print(" ".join(set(Recipe.list_recipes(ctx))))
     else:
         for name in sorted(Recipe.list_recipes(ctx)):
             try:
                 recipe = Recipe.get_recipe(name, ctx)
             except IOError:
                 warning('Recipe "{}" could not be loaded'.format(name))
             except SyntaxError:
                 import traceback
                 traceback.print_exc()
                 warning(('Recipe "{}" could not be loaded due to a '
                          'syntax error').format(name))
             version = str(recipe.version)
             print('{Fore.BLUE}{Style.BRIGHT}{recipe.name:<12} '
                   '{Style.RESET_ALL}{Fore.LIGHTBLUE_EX}'
                   '{version:<8}{Style.RESET_ALL}'.format(
                     recipe=recipe, Fore=Out_Fore, Style=Out_Style,
                     version=version))
             print('    {Fore.GREEN}depends: {recipe.depends}'
                   '{Fore.RESET}'.format(recipe=recipe, Fore=Out_Fore))
             if recipe.conflicts:
                 print('    {Fore.RED}conflicts: {recipe.conflicts}'
                       '{Fore.RESET}'
                       .format(recipe=recipe, Fore=Out_Fore))
             if recipe.opt_depends:
                 print('    {Fore.YELLOW}optional depends: '
                       '{recipe.opt_depends}{Fore.RESET}'
                       .format(recipe=recipe, Fore=Out_Fore))
开发者ID:yileye,项目名称:python-for-android,代码行数:31,代码来源:toolchain.py

示例5: set_libs_flags

    def set_libs_flags(self, env, arch):
        '''Takes care to properly link libraries with python depending on our
        requirements and the attribute :attr:`opt_depends`.
        '''
        if 'libffi' in self.ctx.recipe_build_order:
            info('Activating flags for libffi')
            recipe = Recipe.get_recipe('libffi', self.ctx)
            include = ' -I' + ' -I'.join(recipe.get_include_dirs(arch))
            ldflag = ' -L' + join(recipe.get_build_dir(arch.arch),
                                  recipe.get_host(arch), '.libs') + ' -lffi'
            env['CPPFLAGS'] = env.get('CPPFLAGS', '') + include
            env['LDFLAGS'] = env.get('LDFLAGS', '') + ldflag

        if 'openssl' in self.ctx.recipe_build_order:
            recipe = Recipe.get_recipe('openssl', self.ctx)
            openssl_build_dir = recipe.get_build_dir(arch.arch)
            setuplocal = join('Modules', 'Setup.local')
            shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal)
            shprint(sh.sed, '-i.backup', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal)
            env['OPENSSL_VERSION'] = recipe.version

        if 'sqlite3' in self.ctx.recipe_build_order:
            # Include sqlite3 in python2 build
            recipe = Recipe.get_recipe('sqlite3', self.ctx)
            include = ' -I' + recipe.get_build_dir(arch.arch)
            lib = ' -L' + recipe.get_lib_dir(arch) + ' -lsqlite3'
            # Insert or append to env
            flag = 'CPPFLAGS'
            env[flag] = env[flag] + include if flag in env else include
            flag = 'LDFLAGS'
            env[flag] = env[flag] + lib if flag in env else lib
            
        return env
开发者ID:Splawik,项目名称:pytigon,代码行数:33,代码来源:__init__.py

示例6: test_get_recipe

 def test_get_recipe(self):
     """
     Makes sure `get_recipe()` returns a `Recipe` object when possible.
     """
     ctx = Context()
     recipe_name = 'python3'
     recipe = Recipe.get_recipe(recipe_name, ctx)
     self.assertTrue(isinstance(recipe, Recipe))
     self.assertEqual(recipe.name, recipe_name)
     recipe_name = 'does_not_exist'
     with self.assertRaises(ValueError) as e:
         Recipe.get_recipe(recipe_name, ctx)
     self.assertEqual(
         e.exception.args[0], 'Recipe does not exist: {}'.format(recipe_name))
开发者ID:PKRoma,项目名称:python-for-android,代码行数:14,代码来源:test_recipe.py

示例7: build_recipes

def build_recipes(build_order, python_modules, ctx):
    # Put recipes in correct build order
    bs = ctx.bootstrap
    info_notify("Recipe build order is {}".format(build_order))
    if python_modules:
        python_modules = sorted(set(python_modules))
        info_notify(
            ('The requirements ({}) were not found as recipes, they will be '
             'installed with pip.').format(', '.join(python_modules)))

    recipes = [Recipe.get_recipe(name, ctx) for name in build_order]

    # download is arch independent
    info_main('# Downloading recipes ')
    for recipe in recipes:
        recipe.download_if_necessary()

    for arch in ctx.archs:
        info_main('# Building all recipes for arch {}'.format(arch.arch))

        info_main('# Unpacking recipes')
        for recipe in recipes:
            ensure_dir(recipe.get_build_container_dir(arch.arch))
            recipe.prepare_build_dir(arch.arch)

        info_main('# Prebuilding recipes')
        # 2) prebuild packages
        for recipe in recipes:
            info_main('Prebuilding {} for {}'.format(recipe.name, arch.arch))
            recipe.prebuild_arch(arch)
            recipe.apply_patches(arch)

        # 3) build packages
        info_main('# Building recipes')
        for recipe in recipes:
            info_main('Building {} for {}'.format(recipe.name, arch.arch))
            if recipe.should_build(arch):
                recipe.build_arch(arch)
            else:
                info('{} said it is already built, skipping'
                     .format(recipe.name))

        # 4) biglink everything
        # AND: Should make this optional
        info_main('# Biglinking object files')
        if not ctx.python_recipe or not ctx.python_recipe.from_crystax:
            biglink(ctx, arch)
        else:
            info('NDK is crystax, skipping biglink (will this work?)')

        # 5) postbuild packages
        info_main('# Postbuilding recipes')
        for recipe in recipes:
            info_main('Postbuilding {} for {}'.format(recipe.name, arch.arch))
            recipe.postbuild_arch(arch)

    info_main('# Installing pure Python modules')
    run_pymodules_install(ctx, python_modules)

    return
开发者ID:autosportlabs,项目名称:python-for-android,代码行数:60,代码来源:build.py

示例8: has_package

    def has_package(self, name, arch=None):
        # If this is a file path, it'll need special handling:
        if (name.find("/") >= 0 or name.find("\\") >= 0) and \
                name.find("://") < 0:  # (:// would indicate an url)
            if not os.path.exists(name):
                # Non-existing dir, cannot look this up.
                return False
            try:
                name = get_package_name(os.path.abspath(name))
            except ValueError:
                # Failed to look up any meaningful name.
                return False

        # Try to look up recipe by name:
        try:
            recipe = Recipe.get_recipe(name, self)
        except ValueError:
            pass
        else:
            name = getattr(recipe, 'site_packages_name', None) or name
        name = name.replace('.', '/')
        site_packages_dir = self.get_site_packages_dir(arch)
        return (exists(join(site_packages_dir, name)) or
                exists(join(site_packages_dir, name + '.py')) or
                exists(join(site_packages_dir, name + '.pyc')) or
                exists(join(site_packages_dir, name + '.pyo')) or
                exists(join(site_packages_dir, name + '.so')) or
                glob.glob(join(site_packages_dir, name + '-*.egg')))
开发者ID:PKRoma,项目名称:python-for-android,代码行数:28,代码来源:build.py

示例9: build_arch

    def build_arch(self, arch):
        super(LibxsltRecipe, self).build_arch(arch)
        env = self.get_recipe_env(arch)
        build_dir = self.get_build_dir(arch.arch)
        with current_directory(build_dir):
            # If the build is done with /bin/sh things blow up,
            # try really hard to use bash
            libxml2_recipe = Recipe.get_recipe('libxml2', self.ctx)
            libxml2_build_dir = libxml2_recipe.get_build_dir(arch.arch)
            build_arch = shprint(sh.gcc, '-dumpmachine').stdout.decode(
                'utf-8').split('\n')[0]

            if not exists('configure'):
                shprint(sh.Command('./autogen.sh'), _env=env)
            shprint(sh.Command('autoreconf'), '-vif', _env=env)
            shprint(sh.Command('./configure'),
                    '--build=' + build_arch,
                    '--host=' + arch.command_prefix,
                    '--target=' + arch.command_prefix,
                    '--without-plugins',
                    '--without-debug',
                    '--without-python',
                    '--without-crypto',
                    '--with-libxml-src=' + libxml2_build_dir,
                    '--disable-shared',
                    _env=env)
            shprint(sh.make, "V=1", _env=env)

            shutil.copyfile('libxslt/.libs/libxslt.a',
                            join(self.ctx.libs_dir, 'libxslt.a'))
            shutil.copyfile('libexslt/.libs/libexslt.a',
                            join(self.ctx.libs_dir, 'libexslt.a'))
开发者ID:PKRoma,项目名称:python-for-android,代码行数:32,代码来源:__init__.py

示例10: set_libs_flags

 def set_libs_flags(self, env, arch):
     env = super(Python3Recipe, self).set_libs_flags(env, arch)
     if 'openssl' in self.ctx.recipe_build_order:
         recipe = Recipe.get_recipe('openssl', self.ctx)
         self.configure_args += \
             ('--with-openssl=' + recipe.get_build_dir(arch.arch),)
     return env
开发者ID:PKRoma,项目名称:python-for-android,代码行数:7,代码来源:__init__.py

示例11: get_env

    def get_env(self):
        env = {}

        env["CFLAGS"] = " ".join([
            "-DANDROID", "-mandroid", "-fomit-frame-pointer",
            "--sysroot", self.ctx.ndk_platform])

        env["CXXFLAGS"] = env["CFLAGS"]

        env["LDFLAGS"] = " ".join(['-lm'])

        py_platform = sys.platform
        if py_platform in ['linux2', 'linux3']:
            py_platform = 'linux'

        toolchain_prefix = self.ctx.toolchain_prefix
        toolchain_version = self.ctx.toolchain_version
        command_prefix = self.command_prefix

        env['TOOLCHAIN_PREFIX'] = toolchain_prefix
        env['TOOLCHAIN_VERSION'] = toolchain_version

        print('path is', environ['PATH'])
        cc = find_executable('{command_prefix}-gcc'.format(
            command_prefix=command_prefix), path=environ['PATH'])
        if cc is None:
            warning('Couldn\'t find executable for CC. This indicates a '
                    'problem locating the {} executable in the Android '
                    'NDK, not that you don\'t have a normal compiler '
                    'installed. Exiting.')
            exit(1)

        env['CC'] = '{command_prefix}-gcc {cflags}'.format(
            command_prefix=command_prefix,
            cflags=env['CFLAGS'])
        env['CXX'] = '{command_prefix}-g++ {cxxflags}'.format(
            command_prefix=command_prefix,
            cxxflags=env['CXXFLAGS'])

        env['AR'] = '{}-ar'.format(command_prefix)
        env['RANLIB'] = '{}-ranlib'.format(command_prefix)
        env['LD'] = '{}-ld'.format(command_prefix)
        env['STRIP'] = '{}-strip --strip-unneeded'.format(command_prefix)
        env['MAKE'] = 'make -j5'
        env['READELF'] = '{}-readelf'.format(command_prefix)

        hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx)

        # AND: This hardcodes python version 2.7, needs fixing
        env['BUILDLIB_PATH'] = join(
            hostpython_recipe.get_build_dir(self.arch),
            'build', 'lib.linux-{}-2.7'.format(uname()[-1]))

        env['PATH'] = environ['PATH']

        env['ARCH'] = self.arch

        return env
开发者ID:simudream,项目名称:python-for-android,代码行数:58,代码来源:archs.py

示例12: test_list_recipes

 def test_list_recipes(self):
     """
     Trivial test verifying list_recipes returns a generator with some recipes.
     """
     ctx = Context()
     recipes = Recipe.list_recipes(ctx)
     self.assertTrue(isinstance(recipes, types.GeneratorType))
     recipes = list(recipes)
     self.assertIn('python3', recipes)
开发者ID:PKRoma,项目名称:python-for-android,代码行数:9,代码来源:test_recipe.py

示例13: get_recipe_env

    def get_recipe_env(self, arch):
        env = super(CryptographyRecipe, self).get_recipe_env(arch)

        openssl_recipe = Recipe.get_recipe('openssl', self.ctx)
        env['CFLAGS'] += openssl_recipe.include_flags(arch)
        env['LDFLAGS'] += openssl_recipe.link_dirs_flags(arch)
        env['LIBS'] = openssl_recipe.link_libs_flags()

        return env
开发者ID:PKRoma,项目名称:python-for-android,代码行数:9,代码来源:__init__.py

示例14: setUp

 def setUp(self):
     """
     Setups recipe and context.
     """
     self.context = Context()
     self.context.ndk_api = 21
     self.context.android_api = 27
     self.arch = ArchARMv7_a(self.context)
     self.recipe = Recipe.get_recipe('gevent', self.context)
开发者ID:PKRoma,项目名称:python-for-android,代码行数:9,代码来源:test_gevent.py

示例15: test_recipe_dirs

 def test_recipe_dirs(self):
     """
     Trivial `recipe_dirs()` test.
     Makes sure the list is not empty and has the root directory.
     """
     ctx = Context()
     recipes_dir = Recipe.recipe_dirs(ctx)
     # by default only the root dir `recipes` directory
     self.assertEqual(len(recipes_dir), 1)
     self.assertTrue(recipes_dir[0].startswith(ctx.root_dir))
开发者ID:PKRoma,项目名称:python-for-android,代码行数:10,代码来源:test_recipe.py


注:本文中的pythonforandroid.recipe.Recipe类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。