-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy path__init__.py
More file actions
56 lines (47 loc) · 2.15 KB
/
Copy path__init__.py
File metadata and controls
56 lines (47 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from pythonforandroid.recipe import PyProjectRecipe
from pythonforandroid.toolchain import shprint, current_directory, info
from pythonforandroid.patching import will_build
import sh
from os.path import exists, join
class PyjniusRecipe(PyProjectRecipe):
version = '1.7.0'
url = 'https://github.com/kivy/pyjnius/archive/{version}.zip'
name = 'pyjnius'
depends = [('genericndkbuild', 'sdl2', 'sdl3'), 'six']
site_packages_name = 'jnius'
hostpython_prerequisites = ["Cython<3.2"]
patches = [
"use_cython.patch",
('genericndkbuild_jnienv_getter.patch', will_build('genericndkbuild')),
('sdl3_jnienv_getter.patch', will_build('sdl3')),
]
def get_recipe_env(self, arch, **kwargs):
env = super().get_recipe_env(arch, **kwargs)
generic_main_libs = (
join(self.ctx.bootstrap.build_dir, 'libs', arch.arch,
'libmain_{}.so'.format(arch.arch)),
join(self.ctx.bootstrap.build_dir, 'obj', 'local', arch.arch,
'libmain_{}.so'.format(arch.arch)),
)
if any(exists(lib) for lib in generic_main_libs):
env['PYJNIUS_ANDROID_LIBMAIN'] = 'main_{}'.format(arch.arch)
# Taken from CythonRecipe
env['LDFLAGS'] = env['LDFLAGS'] + ' ' + ' '.join([
'-L{}'.format(self.ctx.get_libs_dir(arch.arch)),
'-L{}'.format(self.ctx.libs_dir),
'-L{}'.format(join(self.ctx.bootstrap.build_dir, 'libs',
arch.arch)),
'-L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
arch.arch)),
])
env['LDSHARED'] = env['CC'] + ' -shared'
env['LIBLINK'] = 'NOTNONE'
# NDKPLATFORM is our switch for detecting Android platform, so can't be None
env['NDKPLATFORM'] = "NOTNONE"
return env
def postbuild_arch(self, arch):
super().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()