Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildozer build failed with python3 #264

Open
maho opened this issue Dec 4, 2017 · 6 comments
Open

buildozer build failed with python3 #264

maho opened this issue Dec 4, 2017 · 6 comments

Comments

@maho
Copy link
Contributor

maho commented Dec 4, 2017

Everything works ok with py2, but when I tried to build with python3 I got such error:

[INFO]:    -> running python3.5 setup.py build_ext -v
Exception in thread background thread for pid 7434:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/maho/.local/lib/python2.7/site-packages/sh.py", line 2170, in background_thread
    handle_exit_code(exit_code)
  File "/home/maho/.local/lib/python2.7/site-packages/sh.py", line 1929, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/home/maho/.local/lib/python2.7/site-packages/sh.py", line 672, in handle_command_exit_code
    raise exc
ErrorReturnCode_1:

  RAN: /usr/bin/python3.5 setup.py build_ext -v

  STDOUT:
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    import kivy
ImportError: No module named 'kivy'


  STDERR:


('cwd is', '/home/maho/tmp/ee/.buildozer/android/platform/build/build/other_builds/kivent_core-python3crystax/armeabi-v7a/kivent_core/modules/core')
()
                                      [INFO]:    STDOUT:
        Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    import kivy
ImportError: No module named 'kivy'
[INFO]:    STDERR:

[INFO]:    COMMAND:
cd /home/maho/tmp/ee/.buildozer/android/platform/build/build/other_builds/kivent_core-python3crystax/armeabi-v7a/kivent_core/modules/core && /usr/bin/python3.5 setup.py build_ext -v

[WARNING]: ERROR: /usr/bin/python3.5 failed!
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=python3crystax,kivy,cymunk,kivent_core --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/maho/tmp/ee/.buildozer/android/platform/build
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

Steps to reproduce:

make chroot

maho@dlaptop:~$ cd ~/chroots
maho@dlaptop:~/chroots$ mkdir buildozer
maho@dlaptop:~/chroots$ sudo debootstrap stable ~/chroots/buildozer
I: Retrieving InRelease
I: Retrieving Release
I: Retrieving Release.gpg
I: Checking Release signature
I: Valid Release signature (key id 067E3C456BAE240ACEE88F6FEF0F382A1A7B6500)
I: Retrieving Packages
[...]
I: Configuring libgnutls30:amd64...
I: Configuring wget...
I: Configuring tasksel...
I: Configuring tasksel-data...
I: Configuring libc-bin...
I: Configuring systemd...
I: Base system installed successfully.

configure schroot

install schroot and create file /etc/schroot/chroot.d/buildozer.conf with such contents:

[buildozer]
description=Buildozer
directory=/home/maho/chroots/buildozer
users=maho
groups=maho
root-groups=root
aliases=b
type=directory
preserve-environment=false

of course replace /home/maho with appropriate /home/username, the same with users and groups

install neccesary software in chroot

maho@dlaptop:~/chroots$ sudo schroot -c b -- dpkg --add-architecture i386

maho@dlaptop:~/chroots$ sudo schroot -c b -- apt-get update


maho@dlaptop:~/tmp/ee$ sudo schroot -c b -- apt-get install -y build-essential \
ccache git zlib1g-dev python2.7 python2.7-dev python3 python3-pip python3-dev \
libncurses5:i386 libstdc++6:i386 zlib1g:i386 openjdk-8- jdk unzip ant ccache \
autoconf libtool python-virtualenv python-pip pkg-config

Install cython and buildozer in chroot's pip

$ sudo schroot -c b -- pip install "cython<0.26" git+https://github.com/kivy/buildozer

Collecting git+https://github.com/kivy/buildozer
  Cloning https://github.com/kivy/buildozer to /tmp/pip-r3Lhdc-build
Requirement already satisfied: cython<0.26 in /usr/local/lib/python2.7/dist-packages
Collecting pexpect (from buildozer==0.34.dev0)
  Downloading pexpect-4.3.0-py2.py3-none-any.whl (55kB)
    100% |################################| 61kB 509kB/s
Requirement already satisfied: virtualenv in /usr/lib/python2.7/dist-packages (from buildozer==0.34.dev0)
Collecting ptyprocess>=0.5 (from pexpect->buildozer==0.34.dev0)
  Downloading ptyprocess-0.5.2-py2.py3-none-any.whl
Installing collected packages: ptyprocess, pexpect, buildozer
  Running setup.py install for buildozer ... done
Successfully installed buildozer-0.34.dev0 pexpect-4.3.0 ptyprocess-0.5.2


Unpack ndk

Download Crystax NDK and unpack into ~/ndk/crystax-ndk-10.3.2/

Make bare app

$ mkdir ~/tmp/ee
$ cd ~/tmp/ee
$ touch main.py

and then

maho@dlaptop:~/tmp/ee$ schroot -c b buildozer init
File buildozer.spec created, ready to customize!

then edit buildozer.init and place following lines into it:

requirements = python3crystax,kivy
android.ndk_path = /home/maho/ndk/crystax-ndk-10.3.2
log_level = 2

Note, that there is no cymunk nor kivent_core in requirements, it's because of issue in kivy/python-for-android#1184

Clean everything in ~/.buildozer

rm -rf ~/.buildozer .buildozer just in case, to be sure you have fresh installa

run buildozer

maho@dlaptop:~/tmp/ee$ schroot -c b -- buildozer --verbose android debug 2>&1 | tee build.log
[....]

succeeded, althouth there error in the end, which I think can be ignored:

[DEBUG]:        BUILD SUCCESSFUL
[DEBUG]:        Total time: 7 seconds
[INFO]:    <- directory context /home/maho/tmp/ee/.buildozer/android/platform/python-for-android-master
[INFO]:    # Copying APK to current directory
[INFO]:    # Found APK file: /home/maho/tmp/ee/.buildozer/android/platform/build/dists/myapp/bin/myapp-0.1-debug.apk
[DEBUG]:   -> running cp /home/maho/tmp/ee/.buildozer/android/platform/build/dists/myapp/bin/myapp-0.1-debug.apk ./
Could not find hostpython, will not compile to .pyo (this is normal with python3)
WARNING: Received a --sdk argument, but this argument is deprecated and does nothing.
No compiled python is present to zip, skipping.
this should only be the case if you are using the CrystaX python
Traceback (most recent call last):
  File "/usr/local/bin/buildozer", line 11, in <module>
    load_entry_point('buildozer==0.34.dev0', 'console_scripts', 'buildozer')()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 1058, in run_command
    self.target.run_commands(args)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 92, in run_commands
    func(args)
  File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 104, in cmd_debug
    self.buildozer.build()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 212, in build
    self.target.build_package()
  File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 808, in build_package
    copyfile(join(apk_dir, apk), join(self.buildozer.bin_dir, apk_dest))
  File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
    with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: u'/home/maho/tmp/ee/.buildozer/android/platform/build/dists/myapp/build/outputs/apk/myapp-debug.apk'

add cymunk to requirements and run buildozer again

in /buildozer.spec/ now you should have:

requirements = python3crystax,kivy,cymunk
maho@dlaptop:~/tmp/ee$ schroot -c b -- buildozer --verbose android debug 2>&1 | tee build-2.log
[....]

add kivent_core to requirements and run buildozer again

in /buildozer.spec/ now you should have:

requirements = python3crystax,kivy,cymunk,kivent_core
maho@dlaptop:~/tmp/ee$ schroot -c b -- buildozer --verbose android debug 2>&1 | tee build-3.log
[....]
@maho
Copy link
Contributor Author

maho commented Dec 4, 2017

full build log of third command is https://pastebin.com/SARXAjR2

@Kovak
Copy link
Contributor

Kovak commented Dec 4, 2017

Can you build a regular non-kivent kivy app?

@maho
Copy link
Contributor Author

maho commented Dec 4, 2017

I assume yes, as described in "run buildozer" step, I was able to build with kivy only in requirements.

@Kovak
Copy link
Contributor

Kovak commented Dec 4, 2017

Is Kivy installed in the Python3.5 that is running buildozer?

@maho
Copy link
Contributor Author

maho commented Dec 5, 2017

No, only buildozer and cython==0.25.2 is installed there. And buildozer is installed in python2.7 (although I tried to uninstall python2, install python3-pip, link /usr/bin/pip3 to /usr/bin/pip and do steps above, and the same results)

@seisdr
Copy link

seisdr commented Jan 19, 2019

1 year ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants