Skip to content

Commit 6293f70

Browse files
committed
recipes
1 parent db4e736 commit 6293f70

File tree

8 files changed

+131
-4
lines changed

8 files changed

+131
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ testapps/build/
3838

3939
# Dolphin (the KDE file manager autogenerates the file `.directory`)
4040
.directory
41+
.DS_Store

pythonforandroid/bootstraps/common/build/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
6+
distributionUrl=http\://mirrors.cloud.tencent.com/gradle/gradle-8.0.2-all.zip
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
2+
3+
4+
class HttptoolsRecipe(CompiledComponentsPythonRecipe):
5+
version = '0.6.1'
6+
#url = 'https://github.com/MagicStack/httptools/archive/refs/tags/v{version}.zip'
7+
url = 'https://files.pythonhosted.org/packages/67/1d/d77686502fced061b3ead1c35a2d70f6b281b5f723c4eff7a2277c04e4a2/httptools-{version}.tar.gz'
8+
depends = ['setuptools']
9+
call_hostpython_via_targetpython = False
10+
11+
12+
recipe = HttptoolsRecipe()
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from os import makedirs, remove
2+
from os.path import exists, join
3+
import sh
4+
5+
from pythonforandroid.recipe import Recipe
6+
from pythonforandroid.logger import shprint
7+
8+
9+
class LibPthread(Recipe):
10+
'''
11+
This is a dumb recipe. We may need this because some recipes inserted some
12+
flags `-lpthread` without our control, case of:
13+
14+
- :class:`~pythonforandroid.recipes.uvloop.UvloopRecipe`
15+
16+
.. note:: the libpthread doesn't exist in android but it is integrated into
17+
libc, so we create a symbolic link which we will remove when our build
18+
finishes'''
19+
20+
def build_arch(self, arch):
21+
libc_path = join(arch.ndk_lib_dir_versioned, 'libc')
22+
# Create a temporary folder to add to link path with a fake libpthread.so:
23+
fake_libpthread_temp_folder = join(
24+
self.get_build_dir(arch.arch),
25+
"p4a-libpthread-recipe-tempdir"
26+
)
27+
if not exists(fake_libpthread_temp_folder):
28+
makedirs(fake_libpthread_temp_folder)
29+
30+
# Set symlinks, and make sure to update them on every build run:
31+
if exists(join(fake_libpthread_temp_folder, "libpthread.so")):
32+
remove(join(fake_libpthread_temp_folder, "libpthread.so"))
33+
shprint(sh.ln, '-sf',
34+
libc_path + '.so',
35+
join(fake_libpthread_temp_folder, "libpthread.so"),
36+
)
37+
if exists(join(fake_libpthread_temp_folder, "libpthread.a")):
38+
remove(join(fake_libpthread_temp_folder, "libpthread.a"))
39+
shprint(sh.ln, '-sf',
40+
libc_path + '.a',
41+
join(fake_libpthread_temp_folder, "libpthread.a"),
42+
)
43+
44+
# Add folder as -L link option for all recipes if not done yet:
45+
if fake_libpthread_temp_folder not in arch.extra_global_link_paths:
46+
arch.extra_global_link_paths.append(
47+
fake_libpthread_temp_folder
48+
)
49+
50+
51+
recipe = LibPthread()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
2+
3+
4+
class MarkupsafeRecipe(CompiledComponentsPythonRecipe):
5+
version = '2.1.5'
6+
url = 'https://files.pythonhosted.org/packages/87/5b/aae44c6655f3801e81aa3eef09dbbf012431987ba564d7231722f68df02d/MarkupSafe-{version}.tar.gz'
7+
depends = ['setuptools']
8+
call_hostpython_via_targetpython = False
9+
10+
11+
recipe = MarkupsafeRecipe()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import re
2+
from pythonforandroid.logger import info
3+
from pythonforandroid.recipe import CythonRecipe
4+
5+
6+
class PyyamlRecipe(CythonRecipe):
7+
version = '6.0.1'
8+
url = 'https://files.pythonhosted.org/packages/cd/e5/af35f7ea75cf72f2cd079c95ee16797de7cd71f29ea7c68ae5ce7be1eda0/PyYAML-{version}.tar.gz'
9+
depends = ['setuptools']
10+
11+
# def get_recipe_env(self, arch=None, with_flags_in_cc=True):
12+
# """
13+
# - Moves all -I<inc> -D<macro> from CFLAGS to CPPFLAGS environment.
14+
# - Moves all -l<lib> from LDFLAGS to LIBS environment.
15+
# - Copies all -l<lib> from LDLIBS to LIBS environment.
16+
# - Fixes linker name (use cross compiler) and flags (appends LIBS)
17+
# """
18+
# env = super().get_recipe_env(arch, with_flags_in_cc)
19+
# # CFLAGS may only be used to specify C compiler flags, for macro definitions use CPPFLAGS
20+
# regex = re.compile(r'(?:\s|^)-[DI][\S]+')
21+
# env['CPPFLAGS'] = ''.join(re.findall(regex, env['CFLAGS'])).strip()
22+
# env['CFLAGS'] = re.sub(regex, '', env['CFLAGS'])
23+
# info('Moved "{}" from CFLAGS to CPPFLAGS.'.format(env['CPPFLAGS']))
24+
# # LDFLAGS may only be used to specify linker flags, for libraries use LIBS
25+
# regex = re.compile(r'(?:\s|^)-l[\w\.]+')
26+
# env['LIBS'] = ''.join(re.findall(regex, env['LDFLAGS'])).strip()
27+
# env['LIBS'] += ' {}'.format(''.join(re.findall(regex, env['LDLIBS'])).strip())
28+
# env['LDFLAGS'] = re.sub(regex, '', env['LDFLAGS'])
29+
# info('Moved "{}" from LDFLAGS to LIBS.'.format(env['LIBS']))
30+
# return env
31+
32+
33+
recipe = PyyamlRecipe()

pythonforandroid/recipes/ujson/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33

44
class UJsonRecipe(CompiledComponentsPythonRecipe):
5-
version = '1.35'
6-
url = 'https://pypi.python.org/packages/source/u/ujson/ujson-{version}.tar.gz'
7-
depends = []
5+
version = '5.9.0'
6+
url = 'https://files.pythonhosted.org/packages/6e/54/6f2bdac7117e89a47de4511c9f01732a283457ab1bf856e1e51aa861619e/ujson-{version}.tar.gz'
7+
depends = ['setuptools']
8+
call_hostpython_via_targetpython = False
9+
810

911

1012
recipe = UJsonRecipe()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
class UvloopRecipe(PythonRecipe):
4+
# 0.19.0
5+
version = '0.19.0'
6+
url = 'https://files.pythonhosted.org/packages/9c/16/728cc5dde368e6eddb299c5aec4d10eaf25335a5af04e8c0abd68e2e9d32/uvloop-{version}.tar.gz'
7+
depends = ['cython', 'setuptools', 'librt', 'libpthread']
8+
call_hostpython_via_targetpython = False
9+
10+
def get_recipe_env(self, arch):
11+
env = super().get_recipe_env(arch)
12+
env["LIBUV_CONFIGURE_HOST"] = arch.command_prefix
13+
env["PLATFORM"] = "android"
14+
return env
15+
16+
17+
recipe = UvloopRecipe()

0 commit comments

Comments
 (0)