Requirements’e ancak recipesi olan modüller eklenirse indirme yapıyor.
Recipe ne demek, bilenler veya bilmeyenler için anlatmaya çalışayım:
.buildozer/android/platform/python-for-android-master/pythonforandroid/recipes isimli klasörün içinde bulunan her klasör, bir modüle ait.
Requests modülünün recipesi üzerinden anlatmaya devam edeyim (Bildiğiniz veya bilmediğiniz gibi requests 3. kişiler tarafından yazılmış bir modül):
Yukarıda bahsettiğim klasörün içinde requests isminde bir klasör var. Bu klasörün içinde bir __init__.py
dosyası bulunur. (Kimi modüllerde patch isimli başka klasörler ve dosyalar da var.)
Mesela aşağıdaki script, .buildozer/android/platform/python-for-android-master/pythonforandroid/recipes/requests klasörü içindeki __init__.py
'de yazan kodlar:
from pythonforandroid.toolchain import PythonRecipe
class RequestsRecipe(PythonRecipe):
version = '2.13.0'
url = 'https://github.com/kennethreitz/requests/archive/v{version}.tar.gz'
depends = ['hostpython2', 'setuptools']
site_packages_name = 'requests'
call_hostpython_via_targetpython = False
recipe = RequestsRecipe()
Hemen hemen bütün tariflerde (recipes), __init__.py
dosyasına benzer bir dosya var.
Mesela aşağıdaki, .buildozer/android/platform/python-for-android-master/pythonforandroid/recipes/kivy klasörü içindeki __init__.py
'de yazan kodlar.
Yani her __init__.py
'de benzer kodlar yazmıyor.
from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchARM
from os.path import exists, join
import sh
import glob
class KivyRecipe(CythonRecipe):
version = '1.10.0'
url = 'https://github.com/kivy/kivy/archive/{version}.zip'
name = 'kivy'
depends = [('sdl2', 'pygame'), 'pyjnius']
# patches = ['setargv.patch']
def cythonize_build(self, env, build_dir='.'):
super(KivyRecipe, self).cythonize_build(env, build_dir=build_dir)
if not exists(join(build_dir, 'kivy', 'include')):
return
# If kivy is new enough to use the include dir, copy it
# manually to the right location as we bypass this stage of
# the build
with current_directory(build_dir):
build_libs_dirs = glob.glob(join('build', 'lib.*'))
for dirn in build_libs_dirs:
shprint(sh.cp, '-r', join('kivy', 'include'),
join(dirn, 'kivy'))
def get_recipe_env(self, arch):
env = super(KivyRecipe, self).get_recipe_env(arch)
if 'sdl2' in self.ctx.recipe_build_order:
env['USE_SDL2'] = '1'
env['KIVY_SPLIT_EXAMPLES'] = '1'
env['KIVY_SDL2_PATH'] = ':'.join([
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer'),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
])
return env
recipe = KivyRecipe()
Gördüğünüz gibi bu scriptlerin içinde depends isimli, modülün gereksinim duyduğu diğer modüller yazılmış. Burada dikkatimi çeken şöyle bir durum var. Mesela kivy modülü pyjnius isimli bir modüle gereksinim duyuyor.
Pyjnius recipesi klasöründeki __init__.py
dosyasına bakıyorum. Aşağıdaki kodlar da onun da başka bağımlı olduğu programlar olduğunu görüyorum.
from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, info
from pythonforandroid.patching import will_build, check_any
import sh
from os.path import join
class PyjniusRecipe(CythonRecipe):
version = 'master'
url = 'https://github.com/kivy/pyjnius/archive/{version}.zip'
name = 'pyjnius'
depends = [('python2', 'python3crystax'), ('genericndkbuild', 'sdl2', 'sdl'), 'six']
site_packages_name = 'jnius'
patches = [('sdl2_jnienv_getter.patch', will_build('sdl2')),
('genericndkbuild_jnienv_getter.patch', will_build('genericndkbuild'))]
def postbuild_arch(self, arch):
super(PyjniusRecipe, self).postbuild_arch(arch)
info('Copying pyjnius java class to classes build dir')
with current_directory(self.get_build_dir(arch.arch)):
shprint(sh.cp, '-a', join('jnius', 'src', 'org'), self.ctx.javaclass_dir)
recipe = PyjniusRecipe()
Ayrıca mesela bu Pyjnius klasörünün içinde yani .buildozer/android/platform/python-for-android-master/pythonforandroid/recipes/pyjnius dizininde, sdl2_jnienv_getter.patch ve genericndkbuild_jnienv_getter.patch isimli başka dosyalar var.
Mesela genericndkbuild_jnienv_getter.patch dosyasının içinde aşağıdakiler yazıyor.
diff --git a/jnius/jnius_jvm_android.pxi b/jnius/jnius_jvm_android.pxi
index ac89fec..71daa43 100644
--- a/jnius/jnius_jvm_android.pxi
+++ b/jnius/jnius_jvm_android.pxi
@@ -1,5 +1,5 @@
# on android, rely on SDL to get the JNI env
-cdef extern JNIEnv *SDL_ANDROID_GetJNIEnv()
+cdef extern JNIEnv *WebView_AndroidGetJNIEnv()
cdef JNIEnv *get_platform_jnienv():
- return SDL_ANDROID_GetJNIEnv()
+ return <JNIEnv*>WebView_AndroidGetJNIEnv()
diff --git a/setup.py b/setup.py
index 740510f..0c8e55f 100644
--- a/setup.py
+++ b/setup.py
@@ -53,7 +53,7 @@ except ImportError:
if platform == 'android':
# for android, we use SDL...
- libraries = ['sdl', 'log']
+ libraries = ['main', 'log']
library_dirs = ['libs/' + getenv('ARCH')]
elif platform == 'darwin':
import subprocess
Ve sdl2_jnienv_getter.patch dosyasında da aşağıdakiler yazıyor.
diff --git a/jnius/jnius_jvm_android.pxi b/jnius/jnius_jvm_android.pxi
index ac89fec..71daa43 100644
--- a/jnius/jnius_jvm_android.pxi
+++ b/jnius/jnius_jvm_android.pxi
@@ -1,5 +1,5 @@
# on android, rely on SDL to get the JNI env
-cdef extern JNIEnv *SDL_ANDROID_GetJNIEnv()
+cdef extern JNIEnv *SDL_AndroidGetJNIEnv()
cdef JNIEnv *get_platform_jnienv():
- return SDL_ANDROID_GetJNIEnv()
+ return <JNIEnv*>SDL_AndroidGetJNIEnv()
diff --git a/setup.py b/setup.py
index 740510f..0c8e55f 100644
--- a/setup.py
+++ b/setup.py
@@ -53,7 +53,7 @@ except ImportError:
if platform == 'android':
# for android, we use SDL...
- libraries = ['sdl', 'log']
+ libraries = ['SDL2', 'log']
library_dirs = ['libs/' + getenv('ARCH')]
elif platform == 'darwin':
import subprocess
Son paylaştığım iki dosyanın içindeki kodların syntaxı şuan benim için anlaşılmaz seviyede. Oysa __init__.py
klasörünün içindeki kodların syntax’ı daha anlaşılır.
Bir önceki mesajımda size gönderdiğim linkte de beautifulsoup4, lxml, libxml2, libxslt için yazılmış __init__.py
dosyaları var. libxslt için ayrıca bir patch dosyası yazılmış. Bunların aynısını .buildozer/android/platform/python-for-android-master/pythonforandroid/recipes dizini içerisinde oluşturdum, ancak yine hatayla sonuçlandı.
Özetle demek istediğim, yanılmıyorsam beautifulsoup4 için çalışır durumda olan bir recipe’ye ihtiyaç var.