kivy / buildozer

Generic Python packager for Android and iOS
https://buildozer.readthedocs.io
MIT License
1.75k stars 504 forks source link

Fails to package app on OSX Sierra 10.12.4 (hdiutil: attach failed - image not recognized keka) #494

Closed mattbryson closed 7 years ago

mattbryson commented 7 years ago

Related to #427

Appears to to be a few issues happening here.

1) Fails to find local install of the kivy.app so downloads it 2) Fails to download keka as part of the installation of kivy

I have tried with Kivy as pip package, with Kivy.app in /Applications, with Kivy.app in local dir . and with all 3 at once. buildozer always tries to download Kivy.

I installed buildozer with both

pip install git+http://github.com/kivy/buildozer

and

pip install git+http://github.com/kivy/buildozer@master

I made the simple pong tutorial, and the app runs fine with a pip install of Kivy.

See below for details...

Verify Kivy

➜  pong ls -la /Applications/Kivy.app
total 0
drwxr-xr-x@  3 Matt  staff   102  7 May 22:48 .
drwxrwxr-x+ 83 root  admin  2822 11 May 21:17 ..
drwxr-xr-x@  6 Matt  staff   204  7 May 22:48 Contents
➜  pong ls -la ./Kivy.app
total 0
drwxr-xr-x@ 3 Matt  staff  102  7 May 22:48 .
drwxr-xr-x  6 Matt  staff  204 12 May 11:16 ..
drwxr-xr-x@ 6 Matt  staff  204  7 May 22:48 Contents
➜  pong pip show kivy
Name: Kivy
Version: 1.10.0
Summary: A software library for rapid development of hardware-accelerated multitouch applications.
Home-page: http://kivy.org
Author: Kivy Team and other contributors
Author-email: kivy-dev@googlegroups.com
License: MIT
Location: /usr/local/lib/python2.7/site-packages
Requires: Kivy-Garden, pygments, docutils

Verify python

➜  pong which python
/usr/local/bin/python
➜  pong ls -n /usr/local/bin/python
lrwxr-xr-x  1 501  80  34  8 May 20:54 /usr/local/bin/python -> ../Cellar/python/2.7.13/bin/python

Verify app runs

➜  pong python main.py
Purge log fired. Analysing...
Purge finished!
[INFO   ] [Logger      ] Record log in /Users/Matt/.kivy/logs/kivy_17-05-12_1.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.13 (default, May  8 2017, 20:53:00)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <gl>
[INFO   ] [GL          ] OpenGL version <2.1 NVIDIA-10.16.34 355.10.05.35f05>
[INFO   ] [GL          ] OpenGL vendor <NVIDIA Corporation>
[INFO   ] [GL          ] OpenGL renderer <NVIDIA GeForce GT 650M OpenGL Engine>
[INFO   ] [GL          ] OpenGL parsed version: 2, 1
[INFO   ] [GL          ] Shading version <1.20>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] NPOT texture support is available
[INFO   ] [Base        ] Leaving application in progress...

Verify buildozer

➜  pong buildozer --version
# Check configuration tokens
Buildozer 0.33dev

Attempt to Package app

➜  pong buildozer init
File buildozer.spec created, ready to customize!
➜  pong buildozer osx debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for osx
# Check if kivy-sdk-packager exists
# kivy-sdk-packager does not exist, clone it
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   127    0   127    0     0    341      0 --:--:-- --:--:-- --:--:--   342
100  195k  100  195k    0     0   184k      0  0:00:01  0:00:01 --:--:-- 1030k
Archive:  master.zip
56bd25036d8070b8b0a7bf4770bc94118a2aba79
   creating: kivy-sdk-packager-master/
  inflating: kivy-sdk-packager-master/.gitignore
  inflating: kivy-sdk-packager-master/LICENSE
  inflating: kivy-sdk-packager-master/README.md
 extracting: kivy-sdk-packager-master/__init__.py
  inflating: kivy-sdk-packager-master/appveyor.yml
   creating: kivy-sdk-packager-master/linux/
   creating: kivy-sdk-packager-master/linux/debian/
  inflating: kivy-sdk-packager-master/linux/debian/README.md
   creating: kivy-sdk-packager-master/linux/debian/daily/
  inflating: kivy-sdk-packager-master/linux/debian/daily/changelog
 extracting: kivy-sdk-packager-master/linux/debian/daily/compat
  inflating: kivy-sdk-packager-master/linux/debian/daily/control
  inflating: kivy-sdk-packager-master/linux/debian/daily/copyright
 extracting: kivy-sdk-packager-master/linux/debian/daily/kivy-doc.docs
 extracting: kivy-sdk-packager-master/linux/debian/daily/kivy-examples.install
  inflating: kivy-sdk-packager-master/linux/debian/daily/kivy-tools.install
  inflating: kivy-sdk-packager-master/linux/debian/daily/python-kivy-bin.install
 extracting: kivy-sdk-packager-master/linux/debian/daily/python-kivy-common.install
  inflating: kivy-sdk-packager-master/linux/debian/daily/python-kivy.install
  inflating: kivy-sdk-packager-master/linux/debian/daily/python3-kivy-bin.install
 extracting: kivy-sdk-packager-master/linux/debian/daily/python3-kivy-common.install
  inflating: kivy-sdk-packager-master/linux/debian/daily/python3-kivy.install
  inflating: kivy-sdk-packager-master/linux/debian/daily/rules
   creating: kivy-sdk-packager-master/linux/debian/stable/
  inflating: kivy-sdk-packager-master/linux/debian/stable/changelog
 extracting: kivy-sdk-packager-master/linux/debian/stable/compat
  inflating: kivy-sdk-packager-master/linux/debian/stable/control
  inflating: kivy-sdk-packager-master/linux/debian/stable/copyright
 extracting: kivy-sdk-packager-master/linux/debian/stable/kivy-doc.docs
 extracting: kivy-sdk-packager-master/linux/debian/stable/kivy-examples.install
  inflating: kivy-sdk-packager-master/linux/debian/stable/kivy-tools.install
  inflating: kivy-sdk-packager-master/linux/debian/stable/python-kivy-bin.install
 extracting: kivy-sdk-packager-master/linux/debian/stable/python-kivy-common.install
  inflating: kivy-sdk-packager-master/linux/debian/stable/python-kivy.install
  inflating: kivy-sdk-packager-master/linux/debian/stable/python3-kivy-bin.install
 extracting: kivy-sdk-packager-master/linux/debian/stable/python3-kivy-common.install
  inflating: kivy-sdk-packager-master/linux/debian/stable/python3-kivy.install
  inflating: kivy-sdk-packager-master/linux/debian/stable/rules
   creating: kivy-sdk-packager-master/osx/
  inflating: kivy-sdk-packager-master/osx/README.md
  inflating: kivy-sdk-packager-master/osx/cleanup_app.sh
  inflating: kivy-sdk-packager-master/osx/create-osx-bundle.sh
  inflating: kivy-sdk-packager-master/osx/create-osx-dmg.sh
   creating: kivy-sdk-packager-master/osx/data/
  inflating: kivy-sdk-packager-master/osx/data/MakeSymlinks
  inflating: kivy-sdk-packager-master/osx/data/background.png
  inflating: kivy-sdk-packager-master/osx/data/icon.icns
  inflating: kivy-sdk-packager-master/osx/data/link_duplicate.py
  inflating: kivy-sdk-packager-master/osx/data/script
  inflating: kivy-sdk-packager-master/osx/package_app.py
   creating: kivy-sdk-packager-master/win/
  inflating: kivy-sdk-packager-master/win/DST Root CA X3.pem
 extracting: kivy-sdk-packager-master/win/__init__.py
  inflating: kivy-sdk-packager-master/win/angle.py
  inflating: kivy-sdk-packager-master/win/common.py
   creating: kivy-sdk-packager-master/win/data/
  inflating: kivy-sdk-packager-master/win/data/README.txt
  inflating: kivy-sdk-packager-master/win/data/kivy-bash.bat
  inflating: kivy-sdk-packager-master/win/data/kivy.bat
  inflating: kivy-sdk-packager-master/win/data/kivybash.rc
  inflating: kivy-sdk-packager-master/win/data/kivyenv.sh
  inflating: kivy-sdk-packager-master/win/data/kivywineenv.sh
   creating: kivy-sdk-packager-master/win/data/tools/
  inflating: kivy-sdk-packager-master/win/data/tools/cython.bat
 extracting: kivy-sdk-packager-master/win/data/tools/easy_install.bat
  inflating: kivy-sdk-packager-master/win/data/tools/link_msysgit.bat
  inflating: kivy-sdk-packager-master/win/data/tools/make-portable-python.py
 extracting: kivy-sdk-packager-master/win/data/tools/pip.bat
  inflating: kivy-sdk-packager-master/win/data/tools/register-python.py
  inflating: kivy-sdk-packager-master/win/dropbox.py
  inflating: kivy-sdk-packager-master/win/gdrive.py
  inflating: kivy-sdk-packager-master/win/glew.py
  inflating: kivy-sdk-packager-master/win/gstreamer.py
  inflating: kivy-sdk-packager-master/win/kivy_win_sdk.py
  inflating: kivy-sdk-packager-master/win/readme
  inflating: kivy-sdk-packager-master/win/sdl2.py
# check if Kivy.app exists in local dir
# Downloading kivy...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   178  100   178    0     0   1114      0 --:--:-- --:--:-- --:--:--  1119
100 69.0M  100 69.0M    0     0   352k      0  0:03:20  0:03:20 --:--:--  395k
# Downloading Keka as dependency (to install Kivy)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   591    0   591    0     0   1520      0 --:--:-- --:--:-- --:--:--  1519
hdiutil: attach failed - image not recognized
Traceback (most recent call last):
  File "/usr/local/bin/buildozer", line 11, in <module>
    load_entry_point('buildozer==0.33.dev0', 'console_scripts', 'buildozer')()
  File "/usr/local/lib/python2.7/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/local/lib/python2.7/site-packages/buildozer/__init__.py", line 1020, in run_command
    self.target.run_commands(args)
  File "/usr/local/lib/python2.7/site-packages/buildozer/targets/osx.py", line 237, in run_commands
    func(args)
  File "/usr/local/lib/python2.7/site-packages/buildozer/targets/osx.py", line 250, in cmd_debug
    self.buildozer.prepare_for_build()
  File "/usr/local/lib/python2.7/site-packages/buildozer/__init__.py", line 172, in prepare_for_build
    self.target.check_requirements()
  File "/usr/local/lib/python2.7/site-packages/buildozer/targets/osx.py", line 104, in check_requirements
    self.ensure_kivyapp()
  File "/usr/local/lib/python2.7/site-packages/buildozer/targets/osx.py", line 98, in ensure_kivyapp
    self.download_kivy(kivy_app_dir, py_branch)
  File "/usr/local/lib/python2.7/site-packages/buildozer/targets/osx.py", line 74, in download_kivy
    check_call(('hdiutil', 'attach', 'Keka-1.0.8.dmg'), cwd=cwd)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('hdiutil', 'attach', 'Keka-1.0.8.dmg')' returned non-zero exit status 1
akshayaurora commented 7 years ago

Should be fixed by #505

Rusbens1 commented 7 years ago

Issue still persists for me.

iruriksl commented 6 years ago

It also persists in my case too

akshayaurora commented 6 years ago

@Rusbens1 @iruriksl can you folks please post your logs

drscotthawley commented 6 years ago

@akshayaurora Not fixed. Just found this page when using latest kivy, latest buildozer.

$ python --version Python 3.6.4 :: Anaconda, Inc. macOS 10.13.3 (17D47)

$ buildozer osx debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for osx
# Check if kivy-sdk-packager exists
# kivy-sdk-packager does not exist, clone it
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   127    0   127    0     0    444      0 --:--:-- --:--:-- --:--:--   444
100  193k    0  193k    0     0   255k      0 --:--:-- --:--:-- --:--:--  255k
Archive:  master.zip
1af58fde2b1442369c03dfaf836fccba866a0555
   creating: kivy-sdk-packager-master/
  inflating: kivy-sdk-packager-master/.gitignore  
  inflating: kivy-sdk-packager-master/LICENSE  
  inflating: kivy-sdk-packager-master/README.md  
 extracting: kivy-sdk-packager-master/__init__.py  
  inflating: kivy-sdk-packager-master/appveyor.yml  
   creating: kivy-sdk-packager-master/linux/
   creating: kivy-sdk-packager-master/linux/debian/
  inflating: kivy-sdk-packager-master/linux/debian/README.md  
   creating: kivy-sdk-packager-master/linux/debian/daily/
  inflating: kivy-sdk-packager-master/linux/debian/daily/changelog  
 extracting: kivy-sdk-packager-master/linux/debian/daily/compat  
  inflating: kivy-sdk-packager-master/linux/debian/daily/control  
  inflating: kivy-sdk-packager-master/linux/debian/daily/copyright  
 extracting: kivy-sdk-packager-master/linux/debian/daily/kivy-doc.docs  
 extracting: kivy-sdk-packager-master/linux/debian/daily/kivy-examples.install  
  inflating: kivy-sdk-packager-master/linux/debian/daily/kivy-tools.install  
  inflating: kivy-sdk-packager-master/linux/debian/daily/python-kivy.install  
  inflating: kivy-sdk-packager-master/linux/debian/daily/python3-kivy.install  
  inflating: kivy-sdk-packager-master/linux/debian/daily/rules  
   creating: kivy-sdk-packager-master/linux/debian/stable/
  inflating: kivy-sdk-packager-master/linux/debian/stable/changelog  
 extracting: kivy-sdk-packager-master/linux/debian/stable/compat  
  inflating: kivy-sdk-packager-master/linux/debian/stable/control  
  inflating: kivy-sdk-packager-master/linux/debian/stable/copyright  
 extracting: kivy-sdk-packager-master/linux/debian/stable/kivy-doc.docs  
 extracting: kivy-sdk-packager-master/linux/debian/stable/kivy-examples.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/kivy-tools.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/python-kivy-bin.install  
 extracting: kivy-sdk-packager-master/linux/debian/stable/python-kivy-common.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/python-kivy.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/python3-kivy-bin.install  
 extracting: kivy-sdk-packager-master/linux/debian/stable/python3-kivy-common.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/python3-kivy.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/rules  
   creating: kivy-sdk-packager-master/osx/
  inflating: kivy-sdk-packager-master/osx/README.md  
  inflating: kivy-sdk-packager-master/osx/cleanup_app.sh  
  inflating: kivy-sdk-packager-master/osx/create-osx-bundle.sh  
  inflating: kivy-sdk-packager-master/osx/create-osx-dmg.sh  
   creating: kivy-sdk-packager-master/osx/data/
  inflating: kivy-sdk-packager-master/osx/data/MakeSymlinks  
  inflating: kivy-sdk-packager-master/osx/data/background.png  
  inflating: kivy-sdk-packager-master/osx/data/icon.icns  
  inflating: kivy-sdk-packager-master/osx/data/link_duplicate.py  
  inflating: kivy-sdk-packager-master/osx/data/script  
  inflating: kivy-sdk-packager-master/osx/package_app.py  
   creating: kivy-sdk-packager-master/win/
  inflating: kivy-sdk-packager-master/win/DST Root CA X3.pem  
 extracting: kivy-sdk-packager-master/win/__init__.py  
  inflating: kivy-sdk-packager-master/win/angle.py  
  inflating: kivy-sdk-packager-master/win/common.py  
   creating: kivy-sdk-packager-master/win/data/
  inflating: kivy-sdk-packager-master/win/data/README.txt  
  inflating: kivy-sdk-packager-master/win/data/kivy-bash.bat  
  inflating: kivy-sdk-packager-master/win/data/kivy.bat  
  inflating: kivy-sdk-packager-master/win/data/kivybash.rc  
  inflating: kivy-sdk-packager-master/win/data/kivyenv.sh  
  inflating: kivy-sdk-packager-master/win/data/kivywineenv.sh  
   creating: kivy-sdk-packager-master/win/data/tools/
  inflating: kivy-sdk-packager-master/win/data/tools/cython.bat  
 extracting: kivy-sdk-packager-master/win/data/tools/easy_install.bat  
  inflating: kivy-sdk-packager-master/win/data/tools/link_msysgit.bat  
  inflating: kivy-sdk-packager-master/win/data/tools/make-portable-python.py  
 extracting: kivy-sdk-packager-master/win/data/tools/pip.bat  
  inflating: kivy-sdk-packager-master/win/data/tools/register-python.py  
  inflating: kivy-sdk-packager-master/win/dropbox.py  
  inflating: kivy-sdk-packager-master/win/gdrive.py  
  inflating: kivy-sdk-packager-master/win/glew.py  
  inflating: kivy-sdk-packager-master/win/gstreamer.py  
  inflating: kivy-sdk-packager-master/win/kivy_win_sdk.py  
  inflating: kivy-sdk-packager-master/win/readme  
  inflating: kivy-sdk-packager-master/win/sdl2.py  
# check if Kivy.app exists in local dir
Traceback (most recent call last):
  File "/Users/shawley/anaconda3/bin/buildozer", line 11, in <module>
    load_entry_point('buildozer==0.35.dev0', 'console_scripts', 'buildozer')()
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/__init__.py", line 1058, in run_command
    self.target.run_commands(args)
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 232, in run_commands
    func(args)
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 245, in cmd_debug
    self.buildozer.prepare_for_build()
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/__init__.py", line 173, in prepare_for_build
    self.target.check_requirements()
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 99, in check_requirements
    self.ensure_kivyapp()
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 86, in ensure_kivyapp
    if not int(py_branch) in (2, 3):
ValueError: invalid literal for int() with base 10: '3.6.4'
Scotts-MacBook-Pro-3:sorta shawley$ buildozer osx debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for osx
# Check if kivy-sdk-packager exists
# kivy-sdk-packager found at /Users/shawley/github/sorta/.buildozer/osx/platform
# check if Kivy.app exists in local dir
# Downloading kivy...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   178  100   178    0     0   1745      0 --:--:-- --:--:-- --:--:--  1745
100   162  100   162    0     0    543      0 --:--:-- --:--:-- --:--:--   543
# Extracting and installing Kivy...
hdiutil: attach failed - image not recognized
Traceback (most recent call last):
  File "/Users/shawley/anaconda3/bin/buildozer", line 11, in <module>
    load_entry_point('buildozer==0.35.dev0', 'console_scripts', 'buildozer')()
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/__init__.py", line 1058, in run_command
    self.target.run_commands(args)
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 232, in run_commands
    func(args)
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 245, in cmd_debug
    self.buildozer.prepare_for_build()
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/__init__.py", line 173, in prepare_for_build
    self.target.check_requirements()
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 99, in check_requirements
    self.ensure_kivyapp()
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 93, in ensure_kivyapp
    self.download_kivy(kivy_app_dir, py_branch)
  File "/Users/shawley/anaconda3/lib/python3.6/site-packages/buildozer/targets/osx.py", line 77, in download_kivy
    check_call(('hdiutil', 'attach', cwd + '/Kivy{}.dmg'.format(py_branch)))
  File "/Users/shawley/anaconda3/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('hdiutil', 'attach', '/Users/shawley/github/sorta/.buildozer/osx/platform/kivy-sdk-packager-master/osx/Kivy3.dmg')' returned non-zero exit status 1.
atschwarz commented 6 years ago

Hi,

I received the same error when I've tried to package a kivy app on macOS Sierra 10.12.6 using buildozer.

Is there any workaround to fix this?

python --version
Python 3.6.2

buildozer --version
# Check configuration tokens
Buildozer 0.34

buildozer -v osx debug
# Check configuration tokens
# Ensure build layout
# Create directory /Volumes/Data/Development/ws/python/BfAndroidServer/.buildozer/osx/platform
# Create directory /Volumes/Data/Development/ws/python/BfAndroidServer/.buildozer/osx/app
# Check configuration tokens
# Preparing build
# Check requirements for osx
# Check if kivy-sdk-packager exists
# kivy-sdk-packager does not exist, clone it
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   127    0   127    0     0    224      0 --:--:-- --:--:-- --:--:--   224
100  193k    0  193k    0     0   140k      0 --:--:--  0:00:01 --:--:--  398k
Archive:  master.zip
7582d96094e5fc3ea3e2991241fbfa667e9791f3
   creating: kivy-sdk-packager-master/
  inflating: kivy-sdk-packager-master/.gitignore  
  inflating: kivy-sdk-packager-master/LICENSE  
  inflating: kivy-sdk-packager-master/README.md  
 extracting: kivy-sdk-packager-master/__init__.py  
  inflating: kivy-sdk-packager-master/appveyor.yml  
   creating: kivy-sdk-packager-master/linux/
   creating: kivy-sdk-packager-master/linux/debian/
  inflating: kivy-sdk-packager-master/linux/debian/README.md  
   creating: kivy-sdk-packager-master/linux/debian/daily/
  inflating: kivy-sdk-packager-master/linux/debian/daily/changelog  
 extracting: kivy-sdk-packager-master/linux/debian/daily/compat  
  inflating: kivy-sdk-packager-master/linux/debian/daily/control  
  inflating: kivy-sdk-packager-master/linux/debian/daily/copyright  
 extracting: kivy-sdk-packager-master/linux/debian/daily/kivy-doc.docs  
 extracting: kivy-sdk-packager-master/linux/debian/daily/kivy-examples.install  
  inflating: kivy-sdk-packager-master/linux/debian/daily/kivy-tools.install  
  inflating: kivy-sdk-packager-master/linux/debian/daily/python-kivy.install  
  inflating: kivy-sdk-packager-master/linux/debian/daily/python3-kivy.install  
  inflating: kivy-sdk-packager-master/linux/debian/daily/rules  
   creating: kivy-sdk-packager-master/linux/debian/stable/
  inflating: kivy-sdk-packager-master/linux/debian/stable/changelog  
 extracting: kivy-sdk-packager-master/linux/debian/stable/compat  
  inflating: kivy-sdk-packager-master/linux/debian/stable/control  
  inflating: kivy-sdk-packager-master/linux/debian/stable/copyright  
 extracting: kivy-sdk-packager-master/linux/debian/stable/kivy-doc.docs  
 extracting: kivy-sdk-packager-master/linux/debian/stable/kivy-examples.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/kivy-tools.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/python-kivy-bin.install  
 extracting: kivy-sdk-packager-master/linux/debian/stable/python-kivy-common.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/python-kivy.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/python3-kivy-bin.install  
 extracting: kivy-sdk-packager-master/linux/debian/stable/python3-kivy-common.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/python3-kivy.install  
  inflating: kivy-sdk-packager-master/linux/debian/stable/rules  
   creating: kivy-sdk-packager-master/osx/
  inflating: kivy-sdk-packager-master/osx/README.md  
  inflating: kivy-sdk-packager-master/osx/cleanup_app.sh  
  inflating: kivy-sdk-packager-master/osx/create-osx-bundle.sh  
  inflating: kivy-sdk-packager-master/osx/create-osx-dmg.sh  
   creating: kivy-sdk-packager-master/osx/data/
  inflating: kivy-sdk-packager-master/osx/data/MakeSymlinks  
  inflating: kivy-sdk-packager-master/osx/data/background.png  
  inflating: kivy-sdk-packager-master/osx/data/icon.icns  
  inflating: kivy-sdk-packager-master/osx/data/link_duplicate.py  
  inflating: kivy-sdk-packager-master/osx/data/script  
  inflating: kivy-sdk-packager-master/osx/package_app.py  
   creating: kivy-sdk-packager-master/win/
  inflating: kivy-sdk-packager-master/win/DST Root CA X3.pem  
 extracting: kivy-sdk-packager-master/win/__init__.py  
  inflating: kivy-sdk-packager-master/win/angle.py  
  inflating: kivy-sdk-packager-master/win/common.py  
   creating: kivy-sdk-packager-master/win/data/
  inflating: kivy-sdk-packager-master/win/data/README.txt  
  inflating: kivy-sdk-packager-master/win/data/kivy-bash.bat  
  inflating: kivy-sdk-packager-master/win/data/kivy.bat  
  inflating: kivy-sdk-packager-master/win/data/kivybash.rc  
  inflating: kivy-sdk-packager-master/win/data/kivyenv.sh  
  inflating: kivy-sdk-packager-master/win/data/kivywineenv.sh  
   creating: kivy-sdk-packager-master/win/data/tools/
  inflating: kivy-sdk-packager-master/win/data/tools/cython.bat  
 extracting: kivy-sdk-packager-master/win/data/tools/easy_install.bat  
  inflating: kivy-sdk-packager-master/win/data/tools/link_msysgit.bat  
  inflating: kivy-sdk-packager-master/win/data/tools/make-portable-python.py  
 extracting: kivy-sdk-packager-master/win/data/tools/pip.bat  
  inflating: kivy-sdk-packager-master/win/data/tools/register-python.py  
  inflating: kivy-sdk-packager-master/win/dropbox.py  
  inflating: kivy-sdk-packager-master/win/gdrive.py  
  inflating: kivy-sdk-packager-master/win/glew.py  
  inflating: kivy-sdk-packager-master/win/gstreamer.py  
  inflating: kivy-sdk-packager-master/win/kivy_win_sdk.py  
  inflating: kivy-sdk-packager-master/win/readme  
  inflating: kivy-sdk-packager-master/win/sdl2.py  
# check if Kivy.app exists in local dir
# Downloading kivy...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   178  100   178    0     0    793      0 --:--:-- --:--:-- --:--:--   794
100   162  100   162    0     0    255      0 --:--:-- --:--:-- --:--:--   843
# Extracting and installing Kivy...
hdiutil: attach failed - image not recognized
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/buildozer", line 11, in <module>
    load_entry_point('buildozer==0.34', 'console_scripts', 'buildozer')()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/buildozer/__init__.py", line 1058, in run_command
    self.target.run_commands(args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/buildozer/targets/osx.py", line 232, in run_commands
    func(args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/buildozer/targets/osx.py", line 245, in cmd_debug
    self.buildozer.prepare_for_build()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/buildozer/__init__.py", line 173, in prepare_for_build
    self.target.check_requirements()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/buildozer/targets/osx.py", line 99, in check_requirements
    self.ensure_kivyapp()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/buildozer/targets/osx.py", line 93, in ensure_kivyapp
    self.download_kivy(kivy_app_dir, py_branch)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/buildozer/targets/osx.py", line 77, in download_kivy
    check_call(('hdiutil', 'attach', cwd + '/Kivy{}.dmg'.format(py_branch)))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('hdiutil', 'attach', '/Volumes/Data/Development/ws/python/BfAndroidServer/.buildozer/osx/platform/kivy-sdk-packager-master/osx/Kivy3.dmg')' returned non-zero exit status 1.
atschwarz commented 6 years ago

Hi,

I was able to locate the problem and fix the error.

Considering you are using python3, the main problem is that if buildozer doesn't find a file called Kivy3.app it tries to download a dmg file from http://kivy.org/downloads/1.10.0/Kivy-1.10.0-osx-python3.dmg which obviously does not exist. Thus the downloaded file is invalid and hdiutil ist not able to attach it. And here, the long way of the journey to fix that problem begins :-D

The big hurdle to overcome is to generate your own Kivy3.app inside the temporary directory .buildozer/osx/platform/kivy-sdk-packager-master/osx using the script "create-osx-bundle.sh", modify your buildozer installation to use python3 and fix the local python script package_app.py. Here are the steps to run everything on a fresh installed macOS Sierra 10.12.6. Finally, you got your packaged application as dmg-file. There is place for some optimization to speed up your build, but I leave this as an exercise ;-)

  1. Run this script to create your build environment to package for Android and macOS:

    setup_environment.sh

    
    #!/usr/bin/env bash

Install homebrew if not installed

which brew > /dev/null && echo "Homebrew is already installed..." || /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install some homebrew packages

brew install python3 wget

Create a symbolic link for pip

sudo ln -s /usr/local/bin/pip3 /usr/local/bin/pip

Install JDK 8 for macOS

if [[ $(which java > /dev/null; echo $?) != "0" ]]; then pushd ~/Downloads wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-macosx-x64.dmg hdiutil attach jdk-8u171-macosx-x64.dmg && sudo /usr/sbin/installer -pkg /Volumes/JDK\ 8\ Update\ 171/JDK\ 8\ Update\ 171.pkg -target / hdiutil detach /Volumes/JDK\ 8\ Update\ 171/ rm jdk-8u171-macosx-x64.dmg popd else echo "Java is already installed..." fi

brew install gradle

Install Android SDK-Tools for macOS

if [[ $(which sdkmanager > /dev/null; echo $?) != "0" ]]; then pushd ~/Downloads wget https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip unzip sdk-tools-darwin-3859397.zip rm sdk-tools-darwin-3859397.zip mkdir -p ~/Library/Frameworks/Android && sudo @mv tools ~/Library/Frameworks/Android PATH=$PATH:~/Library/Frameworks/Android/tools/bin/ && export PATH popd else echo "Android sdkmanager is already installed..." fi

Accept all licenses and install Android platform and build tools.

yes | sdkmanager --licenses sdkmanager "platforms;android-21" sdkmanager "build-tools;27.0.3"

Install Crystax NDK 10.3.2 (necessary for python-for-android with python3)

if [ ! -d ~/Library/Frameworks/crystax-ndk-10.3.2 ]; then pushd ~/Downloads wget https://www.crystax.net/download/crystax-ndk-10.3.2-darwin-x86_64.tar.xz tar xf crystax-ndk-10.3.2-darwin-x86_64.tar.xz rm crystax-ndk-10.3.2-darwin-x86_64.tar.xz sudo mv crystax-ndk-10.3.2 ~/Library/Frameworks popd else echo "CrystaX NDK 10.3.2 is already installed..." fi

Install cython 0.25.2

pip3 install "cython == 0.25.2"

Install python-for-android and kivy

pip3 install "python-for-android == 0.6.0" pip3 install "kivy = 1.10.0"

Install virtualenv

pip3 install "virtualenv == 16.0.0"

Install buildozer

pip3 install "buildozer == 0.34"

############################################

Install stuff for macOS packaging.

############################################

Install platypus

if [[ $(which platypus > /dev/null; echo $?) != "0" ]]; then pushd ~/Downloads wget https://www.sveinbjorn.org/files/software/platypus/platypus5.2.zip unzip platypus5.2.zip rm platypus5.2.zip

sudo cp Platypus-5.2/Platypus.app/Contents/Resources/platypus_clt /usr/local/bin/
sudo mv /usr/local/bin/platypus_clt /usr/local/bin/platypus

sudo mkdir -p /usr/local/share/platypus
sudo cp Platypus-5.2/Platypus.app/Contents/Resources/ScriptExec /usr/local/share/platypus
sudo chmod +x /usr/local/share/platypus/ScriptExec
sudo cp -R Platypus-5.2/Platypus.app/Contents/Resources/MainMenu.nib /usr/local/share/platypus

rm -Rf Platypus-5.2
popd

else echo "Platypus is already installed..." fi

Install GStreamer

if [[ ! -d /Library/Frameworks/GStreamer.framework ]]; then pushd ~/Downloads

# You need both, gstreamer runtime binaries and libs and the development package including the headers.

wget https://gstreamer.freedesktop.org/data/pkg/osx/1.14.0/gstreamer-1.0-devel-1.14.0-x86_64.pkg
sudo /usr/sbin/installer -pkg gstreamer-1.0-devel-1.14.0-x86_64.pkg -target /
rm gstreamer-1.0-devel-1.14.0-x86_64.pkg

wget https://gstreamer.freedesktop.org/data/pkg/osx/1.14.0/gstreamer-1.0-1.14.0-x86_64.pkg
sudo /usr/sbin/installer -pkg gstreamer-1.0-1.14.0-x86_64.pkg -target /
rm gstreamer-1.0-1.14.0-x86_64.pkg

popd

else echo "GStreamer is already installed..." fi

Install SDL2 stuff

if [[ ! -d /Library/Frameworks/SDL2.framework ]]; then pushd ~/Downloads wget https://www.libsdl.org/release/SDL2-2.0.4.dmg hdiutil attach SDL2-2.0.4.dmg && sudo cp -R /Volumes/SDL2/SDL2.framework /Library/Frameworks hdiutil detach /Volumes/SDL2 rm SDL2-2.0.4.dmg popd else echo "SDL2 is already installed..." fi

if [[ ! -d /Library/Frameworks/SDL2_image.framework ]]; then pushd ~/Downloads wget https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.dmg hdiutil attach SDL2_image-2.0.1.dmg && sudo cp -R /Volumes/SDL2_image/SDL2_image.framework /Library/Frameworks hdiutil detach /Volumes/SDL2_image rm SDL2_image-2.0.1.dmg popd else echo "SDL2_image is already installed..." fi

if [[ ! -d /Library/Frameworks/SDL2_ttf.framework ]]; then pushd ~/Downloads wget https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.dmg hdiutil attach SDL2_ttf-2.0.14.dmg && sudo cp -R /Volumes/SDL2_ttf/SDL2_ttf.framework /Library/Frameworks hdiutil detach /Volumes/SDL2_ttf rm SDL2_ttf-2.0.14.dmg popd else echo "SDL2_ttf is already installed..." fi

if [[ ! -d /Library/Frameworks/SDL2_mixer.framework ]]; then pushd ~/Downloads wget https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg hdiutil attach SDL2_mixer-2.0.1.dmg && sudo cp -R /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks hdiutil detach /Volumes/SDL2_mixer rm SDL2_mixer-2.0.1.dmg popd else echo "SDL2_mixer is already installed..." fi

Install libintl.8.dylib

if [[ ! -f /usr/local/lib/libintl.8.dylib ]]; then brew install gettext sudo ln -s /usr/local/Cellar/gettext/0.19.8.1/lib/libintl.8.dylib /usr/local/lib/ else echo "libintl.8.dylib is already installed..." fi


2. Run this script inside your project root:
### build_for_osx.sh

!/usr/bin/env bash

PYTHON_VERSION="3.6.5" PYTHON_EXEC_VERSION="python3.6"

Change buildozer to use a python3.6 virtual environment instead of python2.7

pushd /usr/local/lib/$PYTHON_EXEC_VERSION/site-packages/buildozer sed -i '' 's;virtualenv --python=python2.7;virtualenv --python=python3.6;g' init.py popd

Change the osx target to use python3 to run the package_app.py script.

pushd /usr/local/lib/$PYTHON_EXEC_VERSION/site-packages/buildozer/targets sed -i '' "s;'python', 'package_app.py';'python3', 'package_app.py';g" osx.py popd

First run fails but is necessary to create the directory .buildozer

buildozer osx debug if [[ "$?" != 0 ]]; then echo "[INFO] First run of buildozer failed as expected." fi

Go into the kivy sdk directory to create the file Kivy.app

pushd .buildozer/osx/platform/kivy-sdk-packager-master/osx rm -Rf Kivy3.dmg sed -i '' "s;3.5.0;$PYTHON_VERSION;g" create-osx-bundle.sh sed -i '' "s;python3.5;$PYTHON_EXEC_VERSION;g" create-osx-bundle.sh sed -i '' "s;rm {};rm -f {};g" create-osx-bundle.sh ./create-osx-bundle.sh python3

Repair symlink

pushd Kivy.app/Contents/Resources/venv/bin/ rm ./python3 ln -s ../../../Frameworks/python/$PYTHON_VERSION/bin/python3 . popd

Go into kivy sdk directory and fix the script package_app.py to use the specified python version.

pushd .buildozer/osx/platform/kivy-sdk-packager-master/osx sed -i '' "s;3.5.0;$PYTHON_VERSION;g" package_app.py

Make it python3 compatible by removing decode(...) calls.

sed -i '' "s;.decode('utf-8');;g" package_app.py popd

popd

buildozer osx debug

maltfield commented 4 years ago

I was able to locate the problem and fix the error.

This has been extremely helpful in helping me to get kivy to build in MacOS (via GitHub actions) using buildozer. I'm not sure why this isn't documented on the official documentation, since it's--what--2 years old?

I did find a couple issues

  1. it appears that the syntax has since changed for ./create-osx-bundle.sh -- which now takes the version of kivy followed by the version of python. So change
./create-osx-bundle.sh python3

to this (or similar):

./create-osx-bundle.sh 1.11.1 3.7.3
  1. I found that I had to comment out these two blocks
## Change buildozer to use a python3.7 virtual environment instead of python2.7
#pushd /usr/local/lib/$PYTHON_EXEC_VERSION/site-packages/buildozer
#sed -i '' 's;virtualenv --python=python2.7;virtualenv --python=python3.7;g' __init__.py
#popd
#
## Change the osx target to use python3 to run the package_app.py script.
#pushd /usr/local/lib/$PYTHON_EXEC_VERSION/site-packages/buildozer/targets
#sed -i '' "s;'python', 'package_app.py';'python3', 'package_app.py';g" osx.py
#popd
  1. I had to remove 'python3' from the list of requirements in the buildozer.spec file, else it tries to do a pip3 install python3, which of course fails (not sure why this is the default in the spec file from buildozer init

  2. I had to add a bogus item to requirements.txt, because if 'kivy' is the only item, it throws a fit. I put pip in it, so the requirements.txt file's contents is:

kivy
pip
  1. I found that the sed command to drop the decode of utf-8 actually breaks it, and I needed to remove it
#sed -i '' "s;\.decode('utf-8');;g" package_app.py

I'm almost there: currently everything works except the python binary that's shipped with buildozer at myapp.app/Contents/Resources/python. Not sure why, but apparently the python binaries downloaded by buildozer via pyenv change every execution. smh.

mdegenero commented 4 years ago

@maltfield @astahlhofen Were you ever able to figure this issue out? I am currently struggling with the same issue and have not been able to get the above strategy to work. Any help would be really appreciated!

maltfield commented 4 years ago

I recommend that you just fork this repo. It has build scripts that "just work" to spit-out a self-contained kivy executable app in Linux, Windows, and MacOS:

I ended up abandoning buildzoer (mainly because the python binary it was downloading through the ridiculously complex process described above differs on every execution and therefore wasn't deterministic). I spent days on it, then got PyInstaller working in less than a day.

I built the above-linked repo to make this easier for folks to build apps in kivy without having to setup a build environment and fight with the build tools like I did for about a month.