Skip to content

Commit a5a3829

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 0d079e9 commit a5a3829

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
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 = '-' + '-'.join([arch.nice_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

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-ArmeabiV7A-X86-X86_64-Arm64V8A")
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: 6 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-ArmeabiV7A-X86-X86_64-Arm64V8A "
78+
"with recipes (python3, kivy)>"
7779
)
7880
self.assertEqual(distribution.__str__(), expected_repr)
7981
self.assertEqual(distribution.__repr__(), expected_repr)
@@ -113,7 +115,9 @@ def test_get_distribution_no_name(self, mock_exists):
113115
mock_exists.return_value = False
114116
self.ctx.bootstrap = Bootstrap().get_bootstrap("sdl2", self.ctx)
115117
dist = Distribution.get_distribution(self.ctx)
116-
self.assertEqual(dist.name, "unnamed_dist_1")
118+
self.assertEqual(
119+
dist.name, "unnamed_dist_1-Armeabi-ArmeabiV7A-X86-X86_64-Arm64V8A"
120+
)
117121

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

0 commit comments

Comments
 (0)