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 Python 3 Compatability Issues #175

Closed
FeralBytes opened this issue Feb 1, 2015 · 9 comments
Closed

Buildozer Python 3 Compatability Issues #175

FeralBytes opened this issue Feb 1, 2015 · 9 comments
Labels

Comments

@FeralBytes
Copy link
Contributor

I will be posting any bugs I come across and their associated patches. Once I have buildozer working all of the way I will make a pull request.

Here is the first traceback I recieved using Buildozer with Python3.

buildozer android debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Install platform
# Apache ANT found at /home/wolfrage/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/wolfrage/.buildozer/android/platform/android-sdk-21
# Android NDK found at /home/wolfrage/.buildozer/android/platform/android-ndk-r9c
# Check application requirements
# Check garden requirements
# Compile platform
# Distribution already compiled, pass.
# Build the application #1
# Package the application
Traceback (most recent call last):
  File "/usr/local/bin/buildozer", line 9, in <module>
    load_entry_point('buildozer==0.26', 'console_scripts', 'buildozer')()
  File "/usr/local/lib/python3.4/dist-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/local/lib/python3.4/dist-packages/buildozer/__init__.py", line 967, in run_command
    self.target.run_commands(args)
  File "/usr/local/lib/python3.4/dist-packages/buildozer/target.py", line 85, in run_commands
    func(args)
  File "/usr/local/lib/python3.4/dist-packages/buildozer/target.py", line 97, in cmd_debug
    self.buildozer.build()
  File "/usr/local/lib/python3.4/dist-packages/buildozer/__init__.py", line 194, in build
    self.target.build_package()
  File "/usr/local/lib/python3.4/dist-packages/buildozer/targets/android.py", line 529, in build_package
    self._update_libraries_references(dist_dir)
  File "/usr/local/lib/python3.4/dist-packages/buildozer/targets/android.py", line 690, in _update_libraries_references
    fd.write(line.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
@FeralBytes
Copy link
Contributor Author

Kivy developers, please tell me if you want this patch implemented in a different way before I make a pull request.
Patch:
Line 690 of android.py is

                fd.write(line.decode('utf-8'))

Becomes:

                if sys.hexversion < 0x03000000:
                    fd.write(line)

Or:

                if 'python3' not in sys.executable:
                    fd.write(line)

@FeralBytes
Copy link
Contributor Author

New Traceback, this one was caused by adding a service to my kivy app.

Traceback (most recent call last):
  File "/usr/local/bin/buildozer", line 9, in <module>
    load_entry_point('buildozer==0.26', 'console_scripts', 'buildozer')()
  File "/usr/local/lib/python3.4/dist-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/local/lib/python3.4/dist-packages/buildozer/__init__.py", line 967, in run_command
    self.target.run_commands(args)
  File "/usr/local/lib/python3.4/dist-packages/buildozer/target.py", line 85, in run_commands
    func(args)
  File "/usr/local/lib/python3.4/dist-packages/buildozer/target.py", line 97, in cmd_debug
    self.buildozer.build()
  File "/usr/local/lib/python3.4/dist-packages/buildozer/__init__.py", line 191, in build
    self.build_application()
  File "/usr/local/lib/python3.4/dist-packages/buildozer/__init__.py", line 672, in build_application
    self._add_sitecustomize()
  File "/usr/local/lib/python3.4/dist-packages/buildozer/__init__.py", line 778, in _add_sitecustomize
    data = header + data
TypeError: Can't convert 'bytes' object to str implicitly

@FeralBytes
Copy link
Contributor Author

One way to patch this is that
Line 778-780

        data = header + data
        with open(main_py, 'wb') as fd:
            fd.write(data)

Becomes:

        data = header + str(data, 'utf8')
        with open(main_py, 'wb') as fd:
            fd.write(bytes(data, 'utf8'))

But I am not sure if that will be Python 2 compatable. Probably not given the use of bytes().

@tito
Copy link
Member

tito commented Mar 8, 2015

In the buildozer.init, you have IS_PY3 available that you can use for having a different behavior :)

@FeralBytes
Copy link
Contributor Author

OK I will adjust the code to use IS_PY3.

@FeralBytes
Copy link
Contributor Author

@tito I applied the patches as requested but Buildozer still fails full log attached. Same patches worked on 0.26, so must be something relatively recent.

@dvenkatsagar
Copy link
Contributor

There is also another bug where it fails the application build step with python3, but python-for-android doesnt support python3 yet.

Error given:
build.py: error: unrecognized arguments: debug

/usr/bin/python3.4 build.py --name 'My Application' --version 0.0.1 --package org.test.myapp --private /home/sagar/Repositories/Scripts/Projects/contributions/Test App/.buildozer/android/app --sdk 24 --minsdk 14 --orientation landscape debug

@wannaphong
Copy link

Now , Buildozer Python 3 Compatability 100% ?

@kived
Copy link
Contributor

kived commented Apr 21, 2016

WIth #321 merged, I can successfully build an APK with Python 3.4.3 on OS X. With my unmerged PRs #323 and kivy/python-for-android#720, I can also build an APK with the android_new (p4a revamp) target.

This issue references multiple different problems, and it looks like they have either been fixed or I cannot duplicate them with the current code. I'm going to close this issue; if any of these problems persist please open a separate issue for each problem.

@kived kived closed this as completed Apr 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants