Skip to content

Commit 096e3e5

Browse files
committed
[dist] Add an arch suffix to our dists
So we avoid to overwrite them when arch changes (which is probably what we want)
1 parent b7a2520 commit 096e3e5

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

pythonforandroid/distribution.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def get_distribution(cls, ctx, name=None, recipes=[],
9999

100100
# 0) Check if a dist with that name already exists
101101
if name is not None and name:
102-
possible_dists = [d for d in possible_dists if d.name == name]
102+
possible_dists = [
103+
d for d in possible_dists if d.name.startswith(name)
104+
]
103105
if possible_dists:
104106
name_match_dist = possible_dists[0]
105107

@@ -224,7 +226,10 @@ def get_distribution(cls, ctx, name=None, recipes=[],
224226
i += 1
225227
name = filen.format(i)
226228

227-
dist.name = name
229+
# we add a suffix to our dist name, so we avoid to
230+
# overwrite them when building for different arch
231+
suffix_arch = f"_{{{'·'.join([arch.arch for arch in ctx.archs])}}}"
232+
dist.name = name + suffix_arch
228233
dist.dist_dir = join(ctx.dist_dir, dist.name)
229234
dist.recipes = recipes_with_version
230235
dist.archs = req_archs

pythonforandroid/toolchain.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,13 +1106,12 @@ def apk(self, args):
11061106
else:
11071107
raise BuildInterruptingException('Couldn\'t find the built APK')
11081108

1109-
info_main('# Found APK file: {}'.format(apk_file))
1109+
info_main(f'# Found APK file: {apk_file}')
11101110
if apk_add_version:
11111111
info('# Add version number to APK')
1112-
apk_name, apk_suffix = basename(apk_file).split("-", 1)
1113-
apk_file_dest = "{}-{}-{}".format(
1114-
apk_name, build_args.version, apk_suffix)
1115-
info('# APK renamed to {}'.format(apk_file_dest))
1112+
apk_name, apk_suffix = basename(apk_file).split("_{", 1)
1113+
apk_file_dest = f'{apk_name}-{build_args.version}-{{{apk_suffix}'
1114+
info(f'# APK renamed to {apk_file_dest}')
11161115
shprint(sh.cp, apk_file, apk_file_dest)
11171116
else:
11181117
shprint(sh.cp, apk_file, './')

tests/test_bootstrap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def test_attributes(self):
8484

8585
# test dist_dir success
8686
self.setUp_distribution_with_bootstrap(bs)
87-
self.assertTrue(bs.dist_dir.endswith("dists/test_prj"))
87+
self.assertTrue(bs.dist_dir.endswith(
88+
"dists/test_prj_{armeabi·armeabi-v7a·x86·x86_64·arm64-v8a}")
89+
)
8890

8991
def test_build_dist_dirs(self):
9092
"""A test which will initialize a bootstrap and will check if the

tests/test_distribution.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def test_properties(self):
7373
distribution = self.ctx.bootstrap.distribution
7474
self.assertEqual(self.ctx, distribution.ctx)
7575
expected_repr = (
76-
"<Distribution: name test_prj with recipes (python3, kivy)>"
76+
"<Distribution: name "
77+
"test_prj_{armeabi·armeabi-v7a·x86·x86_64·arm64-v8a} "
78+
"with recipes (python3, kivy)>"
7779
)
7880
self.assertEqual(distribution.__str__(), expected_repr)
7981
self.assertEqual(distribution.__repr__(), expected_repr)
@@ -114,7 +116,10 @@ def test_get_distribution_no_name(self, mock_exists):
114116
mock_exists.return_value = False
115117
self.ctx.bootstrap = Bootstrap().get_bootstrap("sdl2", self.ctx)
116118
dist = Distribution.get_distribution(self.ctx)
117-
self.assertEqual(dist.name, "unnamed_dist_1")
119+
self.assertEqual(
120+
dist.name,
121+
"unnamed_dist_1_{armeabi·armeabi-v7a·x86·x86_64·arm64-v8a}"
122+
)
118123

119124
@mock.patch("pythonforandroid.util.chdir")
120125
@mock.patch("pythonforandroid.distribution.open", create=True)

0 commit comments

Comments
 (0)