Cette page ne concerne que python 3 Pour python 2.7, voir la page Buildozer avec python 2.7
En décembre 2018, buildozer compile officiellement avec python 3, ne plus utiliser Crystax
sudo dpkg --add-architecture i386 sudo apt-get update
sudo apt-get install filezilla terminator caja-open-terminal grsync gparted geany geany-plugins ncdu git thunderbird blender inkscape vlc gimp audacity gdebi keepassxc geeqie blender simple-scan gnome-system-tools cups locales
sudo apt-get install libsdl2-dev zlib1g-dev pkg-config autoconf automake cmake dkms libtool libsdl2-2.0-0 ccache openjdk-8-jdk unzip ffmpeg libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev libgstreamer1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libidn11:i386 zlib1g:i386 openjdk-8-source libssl-dev openssl gcc libpangoxft-1.0-0:i386 adb libtool build-essential python3-pip python3-dev python3-six libpython3-all-dev python3-all python3-all-dev python3-virtualenv virtualenv
libav-tools
Successfully installed
MarkupSafe-1.1.0 appdirs-1.4.3 colorama-0.4.1 jinja2-2.10 sh-1.12.14
sudo pip3 install jinja2 appdirs sh colorama setuptools
cython3: 0.28.4-1
sudo apt-get install cython3
Building wheels for collected packages:
pyyaml, bs4, twisted, kivy, pyjnius, Kivy-Garden
Installing collected packages: pyyaml, soupsieve, beautifulsoup4, bs4, unidecode, lxml, attrs, Automat, PyHamcrest, constantly, hyperlink, incremental, zope.interface, twisted, numpy, opencv-python, Kivy-Garden, docutils, pygments, kivy, pygame, ptyprocess, pexpect, buildozer, pyjnius
Successfully installed
Automat-0.7.0 Kivy-Garden-0.1.4 PyHamcrest-1.9.0 attrs-18.2.0 beautifulsoup4-4.7.0 bs4-0.0.1 buildozer-0.37 constantly-15.1.0 docutils-0.14 hyperlink-18.0.0 incremental-17.5.0 kivy-1.10.1 lxml-4.2.6 numpy-1.15.4 opencv-python-3.4.5.20 pexpect-4.6.0 ptyprocess-0.6.0 pygame-1.9.4 pygments-2.3.1 pyjnius-1.1.4 pyyaml-3.13 soupsieve-1.6.1 twisted-18.9.0 unidecode-1.0.23 zope.interface-4.6.0
sudo pip3 install pyyaml bs4 unidecode lxml twisted numpy opencv-python kivy pygame buildozer pyjnius
sudo dpkg --add-architecture i386 sudo apt-get update # Logiciels sudo apt-get install filezilla terminator caja-open-terminal grsync gparted geany geany-plugins ncdu git thunderbird blender inkscape vlc gimp audacity gdebi keepassxc geeqie blender simple-scan gnome-system-tools cups locales # System sudo apt-get install python-pip python-freenect libsdl2-dev zlib1g-dev pkg-config autoconf automake cmake libav-tools dkms libtool libsdl2-2.0-0 ccache openjdk-8-jdk unzip ffmpeg libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev libgstreamer1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev zlib1g:i386 openjdk-8-source libssl-dev openssl gcc libpangoxft-1.0-0:i386 adb libtool build-essential python-dev python3-pip python3-dev python3-six python-six libpython3-all-dev python3-all python3-all-dev python3-virtualenv virtualenv # pip3 sudo pip3 install jinja2 appdirs sh colorama setuptools sudo pip3 install pyyaml bs4 unidecode lxml twisted numpy opencv-python kivy pygame cython buildozer pyjnius pygame kivy buildozer cython sudo pip3 install --upgrade cython==0.29 sudo pip3 install --upgrade pyjnius pygame kivy buildozer sudo pip3 install https://github.com/kivy/buildozer/archive/master.zip # pip sudo pip install twisted numpy opencv-python pygame kivy colorama sh appdirs jinja2 six pyopenssl cython setuptools sudo pip install buildozer sudo pip install https://github.com/kivy/buildozer/archive/master.zip sudo pip install -U --force-reinstall Cython # locales sudo dpkg-reconfigure locales
!!!!!!!!!!!!!!!! Ne surtout pas faire ça, ça va casser tous les programmes construit en python !!!!!!!!!!!!!!!!!!!!
sudo apt-get install build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev cd /usr/src sudo wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz sudo tar xzf Python-3.7.0.tgz cd Python-3.7.0 sudo ./configure --enable-optimizations sudo make altinstall python3 -V
Dépendances suffisantes mais peut-être pas nécessaires:
sudo apt-get install python3-dev zlib1g-dev pkg-config python3-colorama python3-sh python3-appdirs python3-jinja2 python3-six autoconf automake libtool build-essential cmake libav-tools dkms
Vérifier la version de cython à installer:
En décembre 2018, version = 0.29.1
sudo pip3 install cython
Pour imposer une version:
sudo pip3 install --upgrade cython==0.23
Mais quelle version est nécessaire ?
sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 openjdk-8-jdk unzip zlib1g-dev zlib1g:i386
Version stable:
sudo pip3 install buildozer
retourne
Successfully installed buildozer-0.37 virtualenv-16.1.0
# via pip (latest stable, recommended) sudo pip install buildozer # latest dev version sudo pip install https://github.com/kivy/buildozer/archive/master.zip # Successfully installed buildozer-0.38.dev0 # git clone, for working on buildozer git clone https://github.com/kivy/buildozer cd buildozer python setup.py build sudo pip install -e .
Ouvrir un terminal dans votre projet:
buildozer init
Points importants
# (str) Source code where the main.py live source.dir = . # (list) Source files to include (let empty to include all the files) source.include_exts = py,png,jpg,kv,atlas,ogg # (list) List of inclusions using pattern matching source.include_patterns = data/*.png, sound/*.ogg # (list) Application requirements # comma seperated e.g. requirements = sqlite3,kivy requirements = python3,kivy,openssl # (str) Presplash of the application presplash.filename = %(source.dir)s/data/logo_labomedia.png # (str) Icon of the application icon.filename = %(source.dir)s/data/multipong.png # (str) Supported orientation (one of landscape, portrait or all) orientation = landscape # (list) Permissions android.permissions = INTERNET,CHANGE_WIFI_MULTICAST_STATE,ACCESS_NETWORK_STATE,ACCESS_WIFI_STATE # (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86 android.arch = armeabi-v7a
Il faut définir une version pour l'application que vous compilez.
Cette ligne doit être la première ligne de code du fichier main.py; les versions seront gérées dans ce fichier.
__version__ = '0.67'
# (str) Application versioning (method 1) version.regex = __version__ = ['"](.*)['"] version.filename = %(source.dir)s/main.py # (str) Application versioning (method 2) # version = 1.2.0
La version est définie dans ce fichier buildozer.spec:
# (str) Application versioning (method 1) #version.regex = __version__ = ['"](.*)['"] #version.filename = %(source.dir)s/main.py # (str) Application versioning (method 2) version = 1.2.0
buildozer -v android debug
Cette méthode n'exécute pas le apk, mais lance le main.py. Utilisez logcat.
sudo apt-get install adb adb root adb shell kminilte:/sdcard/kivy/TapOSC $ logcat
* A vérifier si c'est toujours actuel en 2019 avec python 3 par défaut !
Dans truc.kv:
Label: id: Titre font_size: root.width/28 text: self.titre.text
Dans main.py:
class Machin(Screen): titre = ObjectProperty() # Dans le __init__() ou ailleurs self.titre.text = "éèàùê"