Skip to content

Commit fbd9e7f

Browse files
committed
Fixed up check on existing folder when overwriting distributions
1 parent 53443c7 commit fbd9e7f

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

pythonforandroid/distribution.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,24 @@ def get_distribution(cls, ctx, name=None, recipes=[],
8686

8787
existing_dists = Distribution.get_distributions(ctx)
8888

89-
possible_dists = existing_dists
89+
possible_dists = existing_dists[:]
9090

91-
name_match_dists = []
91+
# Will hold dists that would be built in the same folder as an existing dist
92+
folder_match_dist = None
9293

9394
# 0) Check if a dist with that name and architecture already exists
94-
# There may be more than one dist with the same name but different arch targets
9595
if name is not None and name:
9696
possible_dists = [
9797
d for d in possible_dists if
9898
(d.name == name) and (arch_name in d.archs)]
9999

100+
# There should only be one folder with a given dist name *and* arch.
101+
# We could check that here, but for compatibility let's let it slide
102+
# and just record the details of one of them. We only use this data to
103+
# possibly fail the build later, so it doesn't really matter if there
104+
# was more than one clash.
105+
folder_match_dist = possible_dists[0]
106+
100107
# 1) Check if any existing dists meet the requirements
101108
_possible_dists = []
102109
for dist in possible_dists:
@@ -133,22 +140,22 @@ def get_distribution(cls, ctx, name=None, recipes=[],
133140
.format(dist.name))
134141
return dist
135142

136-
assert len(possible_dists) < 2
137-
138143
# If there was a name match but we didn't already choose it,
139144
# then the existing dist is incompatible with the requested
140145
# configuration and the build cannot continue
141-
if name_match_dists and not allow_replace_dist:
146+
if folder_match_dist is not None and not allow_replace_dist:
142147
raise BuildInterruptingException(
143148
'Asked for dist with name {name} with recipes ({req_recipes}) and '
144149
'NDK API {req_ndk_api}, but a dist '
145150
'with this name already exists and has either incompatible recipes '
146151
'({dist_recipes}) or NDK API {dist_ndk_api}'.format(
147152
name=name,
148153
req_ndk_api=ndk_api,
149-
dist_ndk_api=name_match_dist.ndk_api,
154+
dist_ndk_api=folder_match_dist.ndk_api,
150155
req_recipes=', '.join(recipes),
151-
dist_recipes=', '.join(name_match_dist.recipes)))
156+
dist_recipes=', '.join(folder_match_dist.recipes)))
157+
158+
assert len(folder_match_dist) < 2
152159

153160
# If we got this far, we need to build a new dist
154161
dist = Distribution(ctx)
@@ -170,7 +177,6 @@ def get_distribution(cls, ctx, name=None, recipes=[],
170177
dist.ndk_api = ctx.ndk_api
171178
dist.archs = [arch_name]
172179

173-
174180
return dist
175181

176182
def folder_exists(self):

0 commit comments

Comments
 (0)