Skip to content

Commit 4879d33

Browse files
committed
python: update to 3.13
1 parent 10c5292 commit 4879d33

File tree

27 files changed

+609
-260
lines changed

27 files changed

+609
-260
lines changed

Diff for: pythonforandroid/artifact.py

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import zipfile
2+
import json
3+
import os
4+
import subprocess
5+
6+
7+
class ArtifactName:
8+
9+
platform = "android"
10+
11+
def __init__(self, recipe, arch):
12+
self.recipe = recipe
13+
self._arch = arch
14+
15+
@property
16+
def stage(self):
17+
return "master"
18+
result = subprocess.check_output(
19+
["git", "branch", "--show-current"],
20+
stderr=subprocess.PIPE,
21+
universal_newlines=True,
22+
)
23+
return result.strip()
24+
25+
@property
26+
def kind(self):
27+
return "lib"
28+
29+
@property
30+
def arch(self):
31+
return self._arch.arch
32+
33+
@property
34+
def native_api_level(self):
35+
return str(self.recipe.ctx.ndk_api)
36+
37+
@property
38+
def file_props(self):
39+
return [
40+
self.stage,
41+
self.kind,
42+
self.recipe.name,
43+
self.arch,
44+
self.platform + self.native_api_level,
45+
self.recipe.version,
46+
]
47+
48+
@property
49+
def filename(self):
50+
return "_".join(self.file_props) + ".zip"
51+
52+
53+
def build_artifact(
54+
save_path,
55+
recipe,
56+
arch,
57+
lib_dependencies=[],
58+
files_dependencies=[],
59+
install_instructions=[],
60+
):
61+
# Parse artifact name
62+
artifact_name = ArtifactName(recipe, arch)
63+
zip_path = os.path.join(save_path, artifact_name.filename)
64+
65+
# Contents of zip file
66+
metadata_folder = "metadata/"
67+
data_folder = "data/"
68+
prop_file = os.path.join(metadata_folder, "properties.json")
69+
install_file = os.path.join(metadata_folder, "install.json")
70+
71+
properties = {
72+
"stage": artifact_name.stage,
73+
"name": recipe.name,
74+
"arch": artifact_name.arch,
75+
"native_api_level": artifact_name.native_api_level,
76+
"kind": artifact_name.kind,
77+
"version": recipe.version,
78+
"release_version": recipe.version,
79+
"lib_dependencies": lib_dependencies,
80+
"files_dependencies": files_dependencies,
81+
}
82+
83+
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
84+
zipf.writestr(metadata_folder, "")
85+
zipf.writestr(data_folder, "")
86+
87+
for file_name in lib_dependencies + files_dependencies:
88+
with open(file_name, "rb") as file:
89+
file_name_ = os.path.join(data_folder + os.path.basename(file_name))
90+
zipf.writestr(file_name_, file.read())
91+
file.close()
92+
93+
zipf.writestr(prop_file, json.dumps(properties))
94+
zipf.writestr(install_file, json.dumps(install_instructions))
95+
zipf.close()

Diff for: pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ protected static ArrayList<String> getLibraries(File libsDir) {
5656
libsList.add("python3.9");
5757
libsList.add("python3.10");
5858
libsList.add("python3.11");
59+
libsList.add("python3.12");
60+
libsList.add("python3.13");
5961
libsList.add("main");
6062
return libsList;
6163
}
@@ -75,7 +77,7 @@ public static void loadLibraries(File filesDir, File libsDir) {
7577
// load, and it has failed, give a more
7678
// general error
7779
Log.v(TAG, "Library loading error: " + e.getMessage());
78-
if (lib.startsWith("python3.11") && !foundPython) {
80+
if (lib.startsWith("python3.13") && !foundPython) {
7981
throw new RuntimeException("Could not load any libpythonXXX.so");
8082
} else if (lib.startsWith("python")) {
8183
continue;

Diff for: pythonforandroid/build.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class Context:
9494

9595
java_build_tool = 'auto'
9696

97+
save_prebuilt = False
98+
9799
@property
98100
def packages_path(self):
99101
'''Where packages are downloaded before being unpacked'''
@@ -147,11 +149,16 @@ def setup_dirs(self, storage_dir):
147149
'specify a path with --storage-dir')
148150
self.build_dir = join(self.storage_dir, 'build')
149151
self.dist_dir = join(self.storage_dir, 'dists')
152+
self.prebuilt_dir = join(self.storage_dir, 'output')
150153

151154
def ensure_dirs(self):
152155
ensure_dir(self.storage_dir)
153156
ensure_dir(self.build_dir)
154157
ensure_dir(self.dist_dir)
158+
159+
if self.save_prebuilt:
160+
ensure_dir(self.prebuilt_dir)
161+
155162
ensure_dir(join(self.build_dir, 'bootstrap_builds'))
156163
ensure_dir(join(self.build_dir, 'other_builds'))
157164

@@ -672,6 +679,7 @@ def run_pymodules_install(ctx, arch, modules, project_dir=None,
672679
# Bail out if no python deps and no setup.py to process:
673680
if not modules and (
674681
ignore_setup_py or
682+
project_dir is None or
675683
not project_has_setup_py(project_dir)
676684
):
677685
info('No Python modules and no setup.py to process, skipping')
@@ -687,7 +695,8 @@ def run_pymodules_install(ctx, arch, modules, project_dir=None,
687695
"If this fails, it may mean that the module has compiled "
688696
"components and needs a recipe."
689697
)
690-
if project_has_setup_py(project_dir) and not ignore_setup_py:
698+
if project_dir is not None and \
699+
project_has_setup_py(project_dir) and not ignore_setup_py:
691700
info(
692701
"Will process project install, if it fails then the "
693702
"project may not be compatible for Android install."
@@ -759,7 +768,9 @@ def run_pymodules_install(ctx, arch, modules, project_dir=None,
759768
_env=copy.copy(env))
760769

761770
# Afterwards, run setup.py if present:
762-
if project_has_setup_py(project_dir) and not ignore_setup_py:
771+
if project_dir is not None and (
772+
project_has_setup_py(project_dir) and not ignore_setup_py
773+
):
763774
run_setuppy_install(ctx, project_dir, env, arch)
764775
elif not ignore_setup_py:
765776
info("No setup.py found in project directory: " + str(project_dir))

Diff for: pythonforandroid/graph.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def obvious_conflict_checker(ctx, name_tuples, blacklist=None):
240240
return None
241241

242242

243-
def get_recipe_order_and_bootstrap(ctx, names, bs=None, blacklist=None):
243+
def get_recipe_order_and_bootstrap(ctx, names, bs=None, blacklist=None, should_log = False):
244244
# Get set of recipe/dependency names, clean up and add bootstrap deps:
245245
names = set(names)
246246
if bs is not None and bs.recipe_depends:
@@ -311,7 +311,7 @@ def get_recipe_order_and_bootstrap(ctx, names, bs=None, blacklist=None):
311311
for order in orders:
312312
info(' {}'.format(order))
313313
info('Using the first of these: {}'.format(chosen_order))
314-
else:
314+
elif should_log:
315315
info('Found a single valid recipe set: {}'.format(chosen_order))
316316

317317
if bs is None:
@@ -322,7 +322,7 @@ def get_recipe_order_and_bootstrap(ctx, names, bs=None, blacklist=None):
322322
"Could not find any compatible bootstrap!"
323323
)
324324
recipes, python_modules, bs = get_recipe_order_and_bootstrap(
325-
ctx, chosen_order, bs=bs, blacklist=blacklist
325+
ctx, chosen_order, bs=bs, blacklist=blacklist, should_log=True
326326
)
327327
else:
328328
# check if each requirement has a recipe

Diff for: pythonforandroid/pythonpackage.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,11 @@ def _extract_info_from_package(dependency,
556556

557557
# Get build requirements from pyproject.toml if requested:
558558
requirements = []
559-
pyproject_toml_path = os.path.join(output_folder, 'pyproject.toml')
560-
if os.path.exists(pyproject_toml_path) and include_build_requirements:
559+
if os.path.exists(os.path.join(output_folder,
560+
'pyproject.toml')
561+
) and include_build_requirements:
561562
# Read build system from pyproject.toml file: (PEP518)
562-
with open(pyproject_toml_path) as f:
563+
with open(os.path.join(output_folder, 'pyproject.toml')) as f:
563564
build_sys = toml.load(f)['build-system']
564565
if "requires" in build_sys:
565566
requirements += build_sys["requires"]

0 commit comments

Comments
 (0)