UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    [SOLVED]How to Import Python library to clickable?

    Scheduled Pinned Locked Moved App Development
    pythonclickable
    9 Posts 3 Posters 3.4k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • G Offline
        GMNX
        last edited by GMNX

        Hello, I'm new to ubuntu touch, and want to learn it as my Student project.
        So I installed Clickable and create example project like other newborn programmer do, "Hello World"
        Now it run smoothly with command clickable --desktop

        I want to improve it step by step. The first step that I want is import another python library into my .py
        but it got this
        0_1528172604624_Selection_152.png

        can you tell me the proper way to import python module and include it when build the click file?
        thank you

        1 Reply Last reply Reply Quote 1
        • H Offline
          hummlbach
          last edited by

          I think @TimSueberkrueb is using getlibs.py for that... Maybe this helps you: https://github.com/timsueberkrueb/ubports-gettogether/blob/master/timsueberkrueb/pyotherside/presentation.md
          (?)

          1 Reply Last reply Reply Quote 0
          • G Offline
            GMNX
            last edited by GMNX

            Clickable generate project files like this:

            *- clickable.json
            *- hello_world.desktop.in
            *- CMakeLists.txt
            *- hello_world.apparmor
            *- manifest.json.in
            assets/
             - logo.svg
            build/
            * - #this where you get the .click file
            po/
             - hello_world.gmnx.pot
             - CMakeLists.txt
            python-lib/
             - #shared object for target platform (.so file). there is python and pyotherside in this folder
            qml/
             - hello_world.py #the python logic is here
             - Main.qml
            

            it's different structure from the link that you shared
            0_1528177437828_Selection_153.png

            I can't find script folder and get_libs.py

            1 Reply Last reply Reply Quote 0
            • bhdouglassB Offline
              bhdouglass
              last edited by

              If the python library you are wanting to import is not already installed on Ubuntu Touch then you won't be able to easily use it in your app. Something that other people have done is include these dependencies in their apps, you might be able to check out this script for some info: https://github.com/timsueberkrueb/ubuntu-hangups-lib/blob/ce33e2773bb4d3144ef50f4b4291e7d34ff2cad3/get_libs.py

              open-store.io && bhdouglass.com

              1 Reply Last reply Reply Quote 2
              • G Offline
                GMNX
                last edited by

                Thanks for your hint @bhdouglass
                So, if the library in the repo. we can use the get_libs.py

                But, if I need library that using C++ as their backend and bundling it with swig to create Python Library. How do I build this kind of library?
                is there any special tools to crosscompiling into Touch? or we can use any tools based on the Architecture ?

                1 Reply Last reply Reply Quote 0
                • H Offline
                  hummlbach
                  last edited by

                  @GMNX if its something common, you could also find the compiled python modules packaged in the repository. If not or if you want to do it yourself, you may use any way to cross compile it, theres no unique special way afaik. But the clickable docker containers may be a good starting point as they already have the needed change root and compiler installed. Once you have them, you could use
                  docker run -v ~/workdir:/root/workdir -it clickable/ubuntu-sdk:16.04-armhf bash
                  to get a nice cross build environment for xenial for example. (The subdirectory workdir in your home directory would be mounted to /root/workdir inside the container for easy exchange of sources/buildartifacts or whatever...)
                  With that, compiling classical (configure&make) c/c++ stuff is straight forward. Since I'm not so familiar with pythonic packaging and build process and hadn't time to figure out how it works I simply compiled the python modules I needed on the phone lastly... so thats ugly but indeed also possible and maybe the easiest way.

                  1 Reply Last reply Reply Quote 1
                  • G Offline
                    GMNX
                    last edited by

                    thank @hummlbach
                    I'm already finish build the library straight to device.
                    I connect it with clickable shell
                    remount the root folder sudo mount -o remount,rw /
                    Downloading the dependency using apt-get
                    Download the source code
                    Make and install it

                    It build flawlessly, but sadly the library not working properly. It crash when I'm running it, and suddenly make the phone reboot itself.
                    In which log I need to see what's happening before the system crash and rebooted?

                    this what I got in host computer after the Phone crashed. No error message showing
                    0_1531208470949_gmnx@Chaosmatic: ~_172.png

                    H 1 Reply Last reply Reply Quote 0
                    • H Offline
                      hummlbach @GMNX
                      last edited by hummlbach

                      @gmnx are you sure the right compiler was used? What does file yourlib.so say? Ah... You've built it on the device right? Mhmm... now it gets tough... I'm afraid I can't help with that... Try using strace in front of the actual command it may give you a hint. Or perhaps you see something in dmesg... But theres no python yet(?)... Probably the debugger wont help here... But who knows, you could run it with gdb.

                      1 Reply Last reply Reply Quote 0
                      • G Offline
                        GMNX
                        last edited by

                        @hummlbach said in How to Import Python library to clickable?:
                        The question about Python Library is SOLVED, with apt-get install on get_libs.py

                        maybe I need to open new thread, about "How to check Crash Log in Ubuntu Touch?"
                        OR
                        "Create VoIP application with PJSIP in Ubuntu Touch"

                        the Strace log didn't show me exactly what make the system reboot. this show me the technique to see what happen before system crashed
                        since I'm using SSH to my phone, I follow the SSH step

                        1. Log into phone using clickable shell
                        2. Open another tab. Run clickable shell
                        3. in tab 2 run tail -f /var/log/syslog to see system log in realtime
                        4. Reproduce the crash in tab 1
                        5. Watch any error messages in the tab 2

                        Now I need to move to another thread to discuss it, and close this Thread as Solved

                        1 Reply Last reply Reply Quote 0
                        • O olga.bio referenced this topic on
                        • First post
                          Last post