How to use the python-for-android.pythonforandroid.recipe.PythonRecipe function in python-for-android

To help you get started, we’ve selected a few python-for-android examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codelv / enaml-native / python-for-android / pythonforandroid / recipe.py View on Github external
return env

    def build_compiled_components(self,arch):
        super(CppCompiledComponentsPythonRecipe, self).build_compiled_components(arch)

        # Copy libgnustl_shared.so
        with current_directory(self.get_build_dir(arch.arch)):
            sh.cp(
                "{ctx.ndk_dir}/sources/cxx-stl/stlport//libs/{arch.arch}/libstlport_shared.so".format(ctx=self.ctx,arch=arch),
                self.ctx.get_libs_dir(arch.arch)
            )


class CythonRecipe(PythonRecipe):
    pre_build_ext = False
    cythonize = True
    cython_args = []

    def __init__(self, *args, **kwargs):
        super(CythonRecipe, self).__init__(*args, **kwargs)
        depends = self.depends
        depends.append(('python2', 'python2crystax', 'python3crystax'))
        depends = list(set(depends))
        self.depends = depends

    def build_arch(self, arch):
        '''Build any cython components, then install the Python module by
        calling setup.py install with the target Python dir.
        '''
        Recipe.build_arch(self, arch)
github codelv / enaml-native-cli / python-for-android / pythonforandroid / recipe.py View on Github external
return os.path.abspath(join(sys.prefix, 'packages', self.name))

    def download(self):
        """ Copy it right from the source """
        #: Zip the srz
        src_root = self.get_package_root()
        with current_directory(src_root):
            dst_root = join(self.ctx.packages_path, self.name)
            if not exists(dst_root):
                os.makedirs(dst_root)
            sh.zip('-r', join(dst_root, self.url), 'src')
            sh.zip('-r', join(self.ctx.packages_path, self.name, self.url), 'src')



class CompiledComponentsPythonRecipe(PythonRecipe):
    pre_build_ext = False

    build_cmd = 'build_ext'

    def build_arch(self, arch):
        '''Build any cython components, then install the Python module by
        calling setup.py install with the target Python dir.
        '''
        Recipe.build_arch(self, arch)
        self.build_compiled_components(arch)
        self.install_python_package(arch)

    def build_compiled_components(self, arch):
        info('Building compiled components in {}'.format(self.name))

        env = self.get_recipe_env(arch)
github codelv / enaml-native / python-for-android / pythonforandroid / recipe.py View on Github external
def clean_build(self, arch=None):
        super(PythonRecipe, self).clean_build(arch=arch)
        name = self.folder_name
        python_install_dirs = glob.glob(join(self.ctx.python_installs_dir, '*'))
        for python_install in python_install_dirs:
            site_packages_dir = glob.glob(join(python_install, 'lib', 'python*',
                                               'site-packages'))
            if site_packages_dir:
                build_dir = join(site_packages_dir[0], name)
                if exists(build_dir):
                    info('Deleted {}'.format(build_dir))
                    rmtree(build_dir)
github codelv / enaml-native-cli / python-for-android / pythonforandroid / recipe.py View on Github external
return env

    def build_compiled_components(self,arch):
        super(CppCompiledComponentsPythonRecipe, self).build_compiled_components(arch)

        # Copy libgnustl_shared.so
        with current_directory(self.get_build_dir(arch.arch)):
            sh.cp(
                "{ctx.ndk_dir}/sources/cxx-stl/stlport//libs/{arch.arch}/libstlport_shared.so".format(ctx=self.ctx,arch=arch),
                self.ctx.get_libs_dir(arch.arch)
            )


class CythonRecipe(PythonRecipe):
    pre_build_ext = False
    cythonize = True
    cython_args = []

    def __init__(self, *args, **kwargs):
        super(CythonRecipe, self).__init__(*args, **kwargs)
        depends = self.depends
        depends.append(('python2', 'python2crystax', 'python3crystax'))
        depends = list(set(depends))
        self.depends = depends

    def build_arch(self, arch):
        '''Build any cython components, then install the Python module by
        calling setup.py install with the target Python dir.
        '''
        Recipe.build_arch(self, arch)
github codelv / enaml-native-cli / python-for-android / pythonforandroid / recipe.py View on Github external
def clean_build(self, arch=None):
        super(PythonRecipe, self).clean_build(arch=arch)
        name = self.folder_name
        python_install_dirs = glob.glob(join(self.ctx.python_installs_dir, '*'))
        for python_install in python_install_dirs:
            site_packages_dir = glob.glob(join(python_install, 'lib', 'python*',
                                               'site-packages'))
            if site_packages_dir:
                build_dir = join(site_packages_dir[0], name)
                if exists(build_dir):
                    info('Deleted {}'.format(build_dir))
                    rmtree(build_dir)
github codelv / enaml-native / python-for-android / pythonforandroid / recipe.py View on Github external
def get_hostrecipe_env(self, arch):
        env = environ.copy()
        env['PYTHONPATH'] = join(dirname(self.real_hostpython_location), 'Lib', 'site-packages')
        return env

    def install_hostpython_package(self, arch):
        env = self.get_hostrecipe_env(arch)
        real_hostpython = sh.Command(self.real_hostpython_location)
        shprint(real_hostpython, 'setup.py', 'install', '-O2',
                '--root={}'.format(dirname(self.real_hostpython_location)),
                '--install-lib=Lib/site-packages',
                _env=env, *self.setup_extra_args)


class CompiledComponentsPythonRecipe(PythonRecipe):
    pre_build_ext = False

    build_cmd = 'build_ext'

    def build_arch(self, arch):
        '''Build any cython components, then install the Python module by
        calling setup.py install with the target Python dir.
        '''
        Recipe.build_arch(self, arch)
        self.build_compiled_components(arch)
        self.install_python_package(arch)

    def build_compiled_components(self, arch):
        info('Building compiled components in {}'.format(self.name))

        env = self.get_recipe_env(arch)
github codelv / enaml-native-cli / python-for-android / pythonforandroid / recipe.py View on Github external
def install_hostpython_package(self, arch):
        env = self.get_hostrecipe_env(arch)
        real_hostpython = sh.Command(self.real_hostpython_location)
        if ('python2crystax' in self.ctx.recipe_build_order or
            'python3crystax' in self.ctx.recipe_build_order):
            shprint(real_hostpython, 'setup.py', 'install', '-O2',
                    _env=env, *self.setup_extra_args)
            return
        shprint(real_hostpython, 'setup.py', 'install', '-O2',
                '--root={}'.format(dirname(self.real_hostpython_location)),
                '--install-lib=Lib/site-packages',
                _env=env, *self.setup_extra_args)


class EnamlNativeRecipe(PythonRecipe):
    """ A python recipe that builds directly from the source. """
    #: Anything using setuptools fails without this
    call_hostpython_via_targetpython = False

    def get_package_root(self):
        """ Get the path where the `src` folder exists """
        return os.path.abspath(join(sys.prefix, 'packages', self.name))

    def download(self):
        """ Copy it right from the source """
        #: Zip the srz
        src_root = self.get_package_root()
        with current_directory(src_root):
            dst_root = join(self.ctx.packages_path, self.name)
            if not exists(dst_root):
                os.makedirs(dst_root)

python-for-android

A development tool that packages Python apps into binaries that can run on Android devices.

MIT
Latest version published 10 months ago

Package Health Score

76 / 100
Full package analysis

Similar packages