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


Python toolchain.current_directory函数代码示例

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


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

示例1: run_distribute

    def run_distribute(self):
        info_main('# Creating Android project from build and {} bootstrap'.format(
            self.name))

        info('This currently just copies the build stuff straight from the build dir.')
        shprint(sh.rm, '-rf', self.dist_dir)
        shprint(sh.cp, '-r', self.build_dir, self.dist_dir)
        with current_directory(self.dist_dir):
            with open('local.properties', 'w') as fileh:
                fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))

        arch = self.ctx.archs[0]
        if len(self.ctx.archs) > 1:
            raise ValueError('built for more than one arch, but bootstrap cannot handle that yet')
        info('Bootstrap running with arch {}'.format(arch))

        with current_directory(self.dist_dir):
            info('Copying python distribution')

            self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
            self.distribute_aars(arch)
            self.distribute_javaclasses(self.ctx.javaclass_dir)

            python_bundle_dir = join('_python_bundle', '_python_bundle')
            ensure_dir(python_bundle_dir)
            site_packages_dir = self.ctx.python_recipe.create_python_bundle(
                join(self.dist_dir, python_bundle_dir), arch)

            if 'sqlite3' not in self.ctx.recipe_build_order:
                with open('blacklist.txt', 'a') as fileh:
                    fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n')

        self.strip_libraries(arch)
        self.fry_eggs(site_packages_dir)
        super(ServiceOnlyBootstrap, self).run_distribute()
开发者ID:kronenpj,项目名称:python-for-android,代码行数:35,代码来源:__init__.py

示例2: run_distribute

    def run_distribute(self):
        info_main("# Creating Android project ({})".format(self.name))

        arch = self.ctx.archs[0]
        python_install_dir = self.ctx.get_python_install_dir()
        from_crystax = self.ctx.python_recipe.from_crystax

        if len(self.ctx.archs) > 1:
            raise ValueError("SDL2/gradle support only one arch")

        info("Copying SDL2/gradle build for {}".format(arch))
        shprint(sh.rm, "-rf", self.dist_dir)
        shprint(sh.cp, "-r", self.build_dir, self.dist_dir)

        # either the build use environment variable (ANDROID_HOME)
        # or the local.properties if exists
        with current_directory(self.dist_dir):
            with open('local.properties', 'w') as fileh:
                fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))

        with current_directory(self.dist_dir):
            info("Copying Python distribution")

            hostpython = sh.Command(self.ctx.hostpython)
            if self.ctx.python_recipe.name == 'python2':
                try:
                    shprint(hostpython, '-OO', '-m', 'compileall',
                            python_install_dir,
                            _tail=10, _filterout="^Listing")
                except sh.ErrorReturnCode:
                    pass
                if 'python2' in self.ctx.recipe_build_order and not exists('python-install'):
                    shprint(
                        sh.cp, '-a', python_install_dir, './python-install')

            self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
            self.distribute_javaclasses(self.ctx.javaclass_dir,
                                        dest_dir=join("src", "main", "java"))

            python_bundle_dir = join('_python_bundle', '_python_bundle')
            if 'python2' in self.ctx.recipe_build_order:
                # Python 2 is a special case with its own packaging location
                python_bundle_dir = 'private'
            ensure_dir(python_bundle_dir)

            site_packages_dir = self.ctx.python_recipe.create_python_bundle(
                join(self.dist_dir, python_bundle_dir), arch)

            if 'sqlite3' not in self.ctx.recipe_build_order:
                with open('blacklist.txt', 'a') as fileh:
                    fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n')

        self.strip_libraries(arch)
        self.fry_eggs(site_packages_dir)
        super(SDL2GradleBootstrap, self).run_distribute()
开发者ID:KeyWeeUsr,项目名称:python-for-android,代码行数:55,代码来源:__init__.py

示例3: create_python_bundle

    def create_python_bundle(self, dirn, arch):
        ndk_dir = self.ctx.ndk_dir

        # Bundle compiled python modules to a folder
        modules_dir = join(dirn, 'modules')
        ensure_dir(modules_dir)

        modules_build_dir = join(
            self.get_build_dir(arch.arch),
            'android-build',
            'build',
            'lib.linux-arm-3.7')
        module_filens = (glob.glob(join(modules_build_dir, '*.so')) +
                         glob.glob(join(modules_build_dir, '*.py')))
        for filen in module_filens:
            shprint(sh.cp, filen, modules_dir)

        # zip up the standard library
        stdlib_zip = join(dirn, 'stdlib.zip')
        with current_directory(join(self.get_build_dir(arch.arch), 'Lib')):
            stdlib_filens = walk_valid_filens(
                '.', STDLIB_DIR_BLACKLIST, STDLIB_FILEN_BLACKLIST)
            shprint(sh.zip, stdlib_zip, *stdlib_filens)

        # copy the site-packages into place
        ensure_dir(join(dirn, 'site-packages'))
        # TODO: Improve the API around walking and copying the files
        with current_directory(self.ctx.get_python_install_dir()):
            filens = list(walk_valid_filens(
                '.', SITE_PACKAGES_DIR_BLACKLIST, SITE_PACKAGES_FILEN_BLACKLIST))
            for filen in filens:
                ensure_dir(join(dirn, 'site-packages', dirname(filen)))
                sh.cp(filen, join(dirn, 'site-packages', filen))

        # copy the python .so files into place
        python_build_dir = join(self.get_build_dir(arch.arch),
                                'android-build')
        shprint(sh.cp,
                join(python_build_dir,
                     'libpython{}m.so'.format(self.major_minor_version_string)),
                'libs/{}'.format(arch.arch))
        shprint(sh.cp,
                join(python_build_dir,
                     'libpython{}m.so.1.0'.format(self.major_minor_version_string)),
                'libs/{}'.format(arch.arch))

        info('Renaming .so files to reflect cross-compile')
        self.reduce_object_file_names(join(dirn, 'site-packages'))

        return join(dirn, 'site-packages')
开发者ID:jtoledo1974,项目名称:python-for-android,代码行数:50,代码来源:__init__.py

示例4: build_arch

    def build_arch(self, arch):
        env = self.get_recipe_env(arch)
        with current_directory(self.get_build_dir(arch.arch)):
            # sh fails with code 255 trying to execute ./Configure
            # so instead we manually run perl passing in Configure
            perl = sh.Command('perl')
            buildarch = self.select_build_arch(arch)
            # XXX if we don't have no-asm, using clang and ndk-15c, i got:
            # crypto/aes/bsaes-armv7.S:1372:14: error: immediate operand must be in the range [0,4095]
            #  add r8, r6, #.LREVM0SR-.LM0 @ borrow r8
            #              ^
            # crypto/aes/bsaes-armv7.S:1434:14: error: immediate operand must be in the range [0,4095]
            #  sub r6, r8, #.LREVM0SR-.LSR @ pass constants
            config_args = ['shared', 'no-dso', 'no-asm']
            if self.use_legacy:
                config_args.append('no-krb5')
            config_args.append(buildarch)
            if not self.use_legacy:
                config_args.append('-D__ANDROID_API__={}'.format(self.ctx.ndk_api))
            shprint(perl, 'Configure', *config_args, _env=env)
            self.apply_patch(
                'disable-sover{}.patch'.format(
                    '-legacy' if self.use_legacy else ''), arch.arch)
            if self.use_legacy:
                self.apply_patch('rename-shared-lib.patch', arch.arch)

            shprint(sh.make, 'build_libs', _env=env)

            self.install_libs(arch, 'libssl' + self.version + '.so',
                              'libcrypto' + self.version + '.so')
开发者ID:PKRoma,项目名称:python-for-android,代码行数:30,代码来源:__init__.py

示例5: build_arch

    def build_arch(self, arch):
        super(Libxml2Recipe, self).build_arch(arch)
        env = self.get_recipe_env(arch)
        with current_directory(self.get_build_dir(arch.arch)):

            if not exists('configure'):
                shprint(sh.Command('./autogen.sh'), _env=env)
            shprint(sh.Command('autoreconf'), '-vif', _env=env)
            build_arch = shprint(
                sh.gcc, '-dumpmachine').stdout.decode('utf-8').split('\n')[0]
            shprint(sh.Command('./configure'),
                    '--build=' + build_arch,
                    '--host=' + arch.command_prefix,
                    '--target=' + arch.command_prefix,
                    '--without-modules',
                    '--without-legacy',
                    '--without-history',
                    '--without-debug',
                    '--without-docbook',
                    '--without-python',
                    '--without-threads',
                    '--without-iconv',
                    '--disable-shared',
                    '--enable-static',
                    _env=env)

            # Ensure we only build libxml2.la as if we do everything
            # we'll need the glob dependency which is a big headache
            shprint(sh.make, "libxml2.la", _env=env)

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

示例6: build_armeabi

    def build_armeabi(self):
        # AND: Should use an i386 recipe system
        warning('Running hostpython build. Arch is armeabi! '
                'This is naughty, need to fix the Arch system!')

        # AND: Fix armeabi again
        with current_directory(self.get_build_dir('armeabi')):

            if exists('hostpython'):
                info('hostpython already exists, skipping build')
                self.ctx.hostpython = join(self.get_build_dir('armeabi'),
                                           'hostpython')
                self.ctx.hostpgen = join(self.get_build_dir('armeabi'),
                                           'hostpgen')
                return
            
            configure = sh.Command('./configure')

            shprint(configure)
            shprint(sh.make, '-j5')

            shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen')

            if exists('python.exe'):
                shprint(sh.mv, 'python.exe', 'hostpython')
            elif exists('python'):
                shprint(sh.mv, 'python', 'hostpython')
            else:
                warning('Unable to find the python executable after '
                        'hostpython build! Exiting.')
                exit(1)

        self.ctx.hostpython = join(self.get_build_dir('armeabi'), 'hostpython')
        self.ctx.hostpgen = join(self.get_build_dir('armeabi'), 'hostpgen')
开发者ID:micahjohnson150,项目名称:python-for-android,代码行数:34,代码来源:__init__.py

示例7: build_arch

    def build_arch(self, arch):
        super(Libxml2Recipe, self).build_arch(arch)
        env = self.get_recipe_env(arch)
        with current_directory(self.get_build_dir(arch.arch)):
            env["CC"] += " -I%s" % self.get_build_dir(arch.arch)
            shprint(
                sh.Command("./configure"),
                "--host=arm-linux-eabi",
                "--without-modules",
                "--without-legacy",
                "--without-history",
                "--without-debug",
                "--without-docbook",
                "--without-python",
                "--without-threads",
                "--without-iconv",
                _env=env,
            )

            # Ensure we only build libxml2.la as if we do everything
            # we'll need the glob dependency which is a big headache
            shprint(sh.make, "libxml2.la", _env=env)
            shutil.copyfile(
                ".libs/libxml2.a", join(self.ctx.get_libs_dir(arch.arch), "libxml2.a")
            )
开发者ID:KeyWeeUsr,项目名称:python-for-android,代码行数:25,代码来源:__init__.py

示例8: build

def build(target_python, requirements):
    """
    Builds an APK given a target Python and a set of requirements.
    """
    if not requirements:
        return
    testapp = 'setup_testapp_python2.py'
    android_sdk_home = os.environ['ANDROID_SDK_HOME']
    android_ndk_home = os.environ['ANDROID_NDK_HOME']
    crystax_ndk_home = os.environ['CRYSTAX_NDK_HOME']
    if target_python == TargetPython.python3crystax:
        android_ndk_home = crystax_ndk_home
        testapp = 'setup_testapp_python3.py'
    requirements.add(target_python.name)
    requirements = ','.join(requirements)
    print('requirements:', requirements)
    with current_directory('testapps/'):
        try:
            for line in sh.python(
                    testapp, 'apk', '--sdk-dir', android_sdk_home,
                    '--ndk-dir', android_ndk_home, '--bootstrap', 'sdl2', '--requirements',
                    requirements, _err_to_out=True, _iter=True):
                print(line)
        except sh.ErrorReturnCode as e:
            raise
开发者ID:KeyWeeUsr,项目名称:python-for-android,代码行数:25,代码来源:rebuild_updated_recipes.py

示例9: build_arch

    def build_arch(self, arch):
        super(LibZMQRecipe, self).build_arch(arch)
        env = self.get_recipe_env(arch)
        #
        # libsodium_recipe = Recipe.get_recipe('libsodium', self.ctx)
        # libsodium_dir = libsodium_recipe.get_build_dir(arch.arch)
        # env['sodium_CFLAGS'] = '-I{}'.format(join(
        #     libsodium_dir, 'src'))
        # env['sodium_LDLAGS'] = '-L{}'.format(join(
        #     libsodium_dir, 'src', 'libsodium', '.libs'))

        curdir = self.get_build_dir(arch.arch)
        prefix = join(curdir, "install")
        with current_directory(curdir):
            bash = sh.Command('sh')
            shprint(
                bash, './configure',
                '--host=arm-linux-androideabi',
                '--without-documentation',
                '--prefix={}'.format(prefix),
                '--with-libsodium=no',
                _env=env)
            shprint(sh.make, _env=env)
            shprint(sh.make, 'install', _env=env)
            shutil.copyfile('.libs/libzmq.so', join(
                self.ctx.get_libs_dir(arch.arch), 'libzmq.so'))

            bootstrap_obj_dir = join(self.ctx.bootstrap.build_dir, 'obj', 'local', arch.arch)
            ensure_dir(bootstrap_obj_dir)
            shutil.copyfile(
                '{}/sources/cxx-stl/gnu-libstdc++/{}/libs/{}/libgnustl_shared.so'.format(
                    self.ctx.ndk_dir, self.ctx.toolchain_version, arch),
                join(bootstrap_obj_dir, 'libgnustl_shared.so'))
开发者ID:XX-net,项目名称:python-for-android,代码行数:33,代码来源:__init__.py

示例10: build_arch

    def build_arch(self, arch):
        with current_directory(self.get_build_dir()):

            if exists('hostpython'):
                info('hostpython already exists, skipping build')
                self.ctx.hostpython = join(self.get_build_dir(),
                                           'hostpython')
                self.ctx.hostpgen = join(self.get_build_dir(),
                                           'hostpgen')
                return
            
            configure = sh.Command('./configure')

            shprint(configure)
            shprint(sh.make, '-j5')

            shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen')

            if exists('python.exe'):
                shprint(sh.mv, 'python.exe', 'hostpython')
            elif exists('python'):
                shprint(sh.mv, 'python', 'hostpython')
            else:
                warning('Unable to find the python executable after '
                        'hostpython build! Exiting.')
                exit(1)

        self.ctx.hostpython = join(self.get_build_dir(), 'hostpython')
        self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen')
开发者ID:423230557,项目名称:python-for-android,代码行数:29,代码来源:__init__.py

示例11: build_cython_components

    def build_cython_components(self, arch):
        env = self.get_recipe_env(arch)
        with current_directory(self.get_build_dir(arch.arch)):
            info('hostpython is ' + self.ctx.hostpython)
            hostpython = sh.Command(self.ctx.hostpython)

            app_mk = join(self.get_build_dir(arch.arch), 'Application.mk')
            if not exists(app_mk):
                shprint(sh.cp, join(self.get_recipe_dir(), 'Application.mk'), app_mk)
            app_setup = join(self.get_build_dir(arch.arch), 'setup.py')
            if not exists(app_setup):
                shprint(sh.cp, join(self.get_recipe_dir(), 'setup.py'), app_setup)

            # This first attempt *will* fail, because cython isn't
            # installed in the hostpython
            try:
                shprint(hostpython, 'setup.py', 'build_ext', _env=env)
            except sh.ErrorReturnCode_1:
                pass

            # ...so we manually run cython from the user's system
            shprint(sh.find, self.get_build_dir('armeabi'), '-iname', '*.pyx', '-exec',
                    self.ctx.cython, '{}', ';', _env=env)

            # now cython has already been run so the build works
            shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env)

            # stripping debug symbols lowers the file size a lot
            build_lib = glob.glob('./build/lib*')
            shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
                    env['STRIP'], '{}', ';', _env=env)
开发者ID:zwyuan,项目名称:python-for-android,代码行数:31,代码来源:__init__.py

示例12: build_armeabi

    def build_armeabi(self):
        # AND: I'm going to ignore any extra pythonrecipe or cythonrecipe behaviour for now
        
        arch = ArchAndroid(self.ctx)
        env = self.get_recipe_env(arch)
        
        env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format(
            jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
        env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl/include -I{jni_path}/sdl_mixer'.format(
            jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
        env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl_ttf -I{jni_path}/sdl_image'.format(
            jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
        debug('pygame cflags', env['CFLAGS'])

        
        env['LDFLAGS'] = env['LDFLAGS'] + ' -L{libs_path} -L{src_path}/obj/local/{arch} -lm -lz'.format(
            libs_path=self.ctx.libs_dir, src_path=self.ctx.bootstrap.build_dir, arch=env['ARCH'])

        env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink')

        with current_directory(self.get_build_dir('armeabi')):
            info('hostpython is ' + self.ctx.hostpython)
            hostpython = sh.Command(self.ctx.hostpython)
            shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)

            info('strip is ' + env['STRIP'])
            build_lib = glob.glob('./build/lib*')
            assert len(build_lib) == 1
            print('stripping pygame')
            shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
                    env['STRIP'], '{}', ';')

        python_install_path = join(self.ctx.build_dir, 'python-install')
        # AND: Should do some deleting here!
        print('Should remove pygame tests etc. here, but skipping for now')
开发者ID:radiodee1,项目名称:python-for-android,代码行数:35,代码来源:__init__.py

示例13: build_arch

    def build_arch(self, arch):
        # AND: Should use an i386 recipe system
        warning("Running hostpython build. Arch is armeabi! " "This is naughty, need to fix the Arch system!")

        # AND: Fix armeabi again
        with current_directory(self.get_build_dir(arch.arch)):

            if exists("hostpython"):
                info("hostpython already exists, skipping build")
                self.ctx.hostpython = join(self.get_build_dir("armeabi"), "hostpython")
                self.ctx.hostpgen = join(self.get_build_dir("armeabi"), "hostpgen")
                return

            configure = sh.Command("./configure")

            shprint(configure)
            shprint(sh.make, "-j5", "BUILDPYTHON=hostpython", "hostpython", "PGEN=Parser/hostpgen", "Parser/hostpgen")

            shprint(sh.mv, join("Parser", "hostpgen"), "hostpgen")

            # if exists('python.exe'):
            #     shprint(sh.mv, 'python.exe', 'hostpython')
            # elif exists('python'):
            #     shprint(sh.mv, 'python', 'hostpython')
            if exists("hostpython"):
                pass  # The above commands should automatically create
                # the hostpython binary, unlike with python2
            else:
                warning("Unable to find the python executable after " "hostpython build! Exiting.")
                exit(1)

        self.ctx.hostpython = join(self.get_build_dir(arch.arch), "hostpython")
        self.ctx.hostpgen = join(self.get_build_dir(arch.arch), "hostpgen")
开发者ID:hottwaj,项目名称:python-for-android,代码行数:33,代码来源:__init__.py

示例14: build_arch

 def build_arch(self, arch):
     super(C_iGraphRecipe, self).build_arch(arch)
     jobs = self.get_recipe_env(arch).get('MAKE_JOBS', 1)
     with current_directory(self.get_build_dir(arch.arch)):
         shprint(sh.bash, './configure', '--prefix={}/python-install'.format(self.get_build_container_dir(arch.arch)), '--host=arm-linux-eabi')
         shprint(sh.make, '-j{}'.format(jobs))
         shprint(sh.make, '-j{}'.format(jobs), 'install')
开发者ID:LogicalDash,项目名称:python-for-android,代码行数:7,代码来源:__init__.py

示例15: build_arch

 def build_arch(self, arch):
     super(LibtorrentRecipe, self).build_arch(arch)
     env = self.get_recipe_env(arch)
     with current_directory(join(self.get_build_dir(arch.arch), 'bindings/python')):
         # Compile libtorrent with boost libraries and python bindings
         b2 = sh.Command(join(env['BOOST_ROOT'], 'b2'))
         shprint(b2,
                 '-q',
                 '-j5',
                 'toolset=gcc-' + env['ARCH'],
                 'target-os=android',
                 'threading=multi',
                 'link=shared',
                 'boost-link=shared',
                 'boost=source',
                 'encryption=openssl' if 'openssl' in recipe.ctx.recipe_build_order else '',
                 '--prefix=' + env['CROSSHOME'],
                 'release', _env=env)
     # Common build directories
     build_subdirs = 'gcc-arm/release/boost-link-shared/boost-source'
     if 'openssl' in recipe.ctx.recipe_build_order:
         build_subdirs += '/encryption-openssl'
     build_subdirs += '/libtorrent-python-pic-on/target-os-android/threading-multi/visibility-hidden'
     # Copy the shared libraries into the libs folder
     shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/python/build', build_subdirs, 'libboost_python.so'),
                     join(self.ctx.get_libs_dir(arch.arch), 'libboost_python.so'))
     shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/system/build', build_subdirs, 'libboost_system.so'),
                     join(self.ctx.get_libs_dir(arch.arch), 'libboost_system.so'))
     if 'openssl' in recipe.ctx.recipe_build_order:
         shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/date_time/build', build_subdirs, 'libboost_date_time.so'),
                     join(self.ctx.get_libs_dir(arch.arch), 'libboost_date_time.so'))
     shutil.copyfile(join(self.get_build_dir(arch.arch), 'bin', build_subdirs, 'libtorrent_rasterbar.so'),
                     join(self.ctx.get_libs_dir(arch.arch), 'libtorrent_rasterbar.so'))
     shutil.copyfile(join(self.get_build_dir(arch.arch), 'bindings/python/bin', build_subdirs, 'libtorrent.so'),
                     join(self.ctx.get_site_packages_dir(arch.arch), 'libtorrent.so'))
开发者ID:yileye,项目名称:python-for-android,代码行数:35,代码来源:__init__.py


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