22import glob
33import json
44
5- from pythonforandroid .logger import (info , info_notify , warning , Err_Style , Err_Fore )
5+ from pythonforandroid .logger import (debug , info , info_notify , warning , Err_Style , Err_Fore )
66from pythonforandroid .util import current_directory , BuildInterruptingException
77from shutil import rmtree
88
@@ -91,6 +91,7 @@ def get_distribution(
9191 '''
9292
9393 possible_dists = Distribution .get_distributions (ctx )
94+ debug (f"All possible dists: { possible_dists } " )
9495
9596 # Will hold dists that would be built in the same folder as an existing dist
9697 folder_match_dist = None
@@ -100,6 +101,7 @@ def get_distribution(
100101 possible_dists = [
101102 d for d in possible_dists if
102103 (d .name == name ) and all (arch_name in d .archs for arch_name in archs )]
104+ debug (f"Dist matching name and arch: { possible_dists } " )
103105
104106 if possible_dists :
105107 # There should only be one folder with a given dist name *and* arch.
@@ -115,13 +117,18 @@ def get_distribution(
115117 if (
116118 ndk_api is not None and dist .ndk_api != ndk_api
117119 ) or dist .ndk_api is None :
120+ debug (
121+ f"dist { dist } failed to match ndk_api, target api { ndk_api } , dist api { dist .ndk_api } "
122+ )
118123 continue
119124 for recipe in recipes :
120125 if recipe not in dist .recipes :
126+ debug (f"dist { dist } missing recipe { recipe } " )
121127 break
122128 else :
123129 _possible_dists .append (dist )
124130 possible_dists = _possible_dists
131+ debug (f"Dist matching ndk_api and recipe: { possible_dists } " )
125132
126133 if possible_dists :
127134 info ('Of the existing distributions, the following meet '
@@ -133,17 +140,24 @@ def get_distribution(
133140 # If any dist has perfect recipes, arch and NDK API, return it
134141 for dist in possible_dists :
135142 if force_build :
143+ debug ("Skipping dist due to forced build" )
136144 continue
137145 if ndk_api is not None and dist .ndk_api != ndk_api :
146+ debug ("Skipping dist due to ndk_api mismatch" )
138147 continue
139148 if not all (arch_name in dist .archs for arch_name in archs ):
149+ debug ("Skipping dist due to arch mismatch" )
140150 continue
141151 if (set (dist .recipes ) == set (recipes ) or
142152 (set (recipes ).issubset (set (dist .recipes )) and
143153 not require_perfect_match )):
144154 info_notify ('{} has compatible recipes, using this one'
145155 .format (dist .name ))
146156 return dist
157+ else :
158+ debug (
159+ f"Skipping dist due to recipes mismatch, expected { set (recipes )} , actual { set (dist .recipes )} "
160+ )
147161
148162 # If there was a name match but we didn't already choose it,
149163 # then the existing dist is incompatible with the requested
0 commit comments