Skip to content

Custom recipe for scipy fails with permission issue #2267

Closed
@advent-embedded

Description

@advent-embedded

Ive a stripped down functionality of scipy lfilter, i could successfully build my recipe when targeted for host PC x86_64, which gives shared object built via cython
when i include the same recipe to kivy, i could pass the compilation step, while installation it stilll seeks to install at my development machine instead of ardroid folders.

 RAN: /home/sosdt002/kivy/plotgraph/.buildozer/android/platform/build/build/other_builds/hostpython3/desktop/hostpython3/native-build/python setup.py install -O2

  STDOUT:
running install
running build
running build_ext
running install_lib
creating /usr/local/lib/python3.7
error: could not create '/usr/local/lib/python3.7': Permission denied

my scipy recipe from local folder

from pythonforandroid.recipe import CythonRecipe
from pythonforandroid.toolchain import Recipe, shprint, current_directory,info
import urllib.parse
import sh
import glob

class ScitoolsRecipe(CythonRecipe):
    url = 'file://' + urllib.parse.quote("/home/sosdt002/Desktop/scitools")
    name = 'scitools'

    depends = ['numpy', 'cython']

    def build_arch(self, arch):
        Recipe.build_arch(self, arch)  # a hack to avoid calling
                                   # PythonRecipe.build_arch
        self.build_cython_components(arch)
        self.install_python_package(arch)  # this is the same as in a PythonRecipe

    def install_python_package(self,arch):
        '''Automate the installation of a Python package (or a cython
        package where the cython components are pre-built).'''
        # arch = self.filtered_archs[0]
        env = self.get_recipe_env(arch)
        # shprint(echo, '$PATH', _env=env)        
        info('Installing {} into site-packages'.format(self.name))

        with current_directory(self.get_build_dir(arch.arch)):
            hostpython = sh.Command(self.ctx.hostpython)

            # shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)
    
    def build_cython_components(self, arch):
        env = self.get_recipe_env(arch)
        info("arch={}".format(env))
        with current_directory(self.get_build_dir(arch.arch)):
            hostpython = sh.Command(self.ctx.hostpython)

            # This first attempt *will* fail, because cython isn't
            # installed in the hostpython
            try:
                shprint(hostpython, 'setup.py', 'build_ext', '-v', _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-v7a'), '-iname', '*.pyx', '-exec',
                      '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)
            shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)

recipe = ScitoolsRecipe()

reading around blogs i found running buildozer with root is not advise to overcome permission issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions