55from pythonforandroid .logger import (info , info_notify , warning ,
66 Err_Style , Err_Fore , error )
77from pythonforandroid .util import current_directory
8+ from shutil import rmtree
89
910
1011class Distribution (object ):
@@ -46,7 +47,8 @@ def get_distribution(cls, ctx, name=None, recipes=[],
4647 ndk_api = None ,
4748 force_build = False ,
4849 extra_dist_dirs = [],
49- require_perfect_match = False ):
50+ require_perfect_match = False ,
51+ allow_replace_dist = True ):
5052 '''Takes information about the distribution, and decides what kind of
5153 distribution it will be.
5254
@@ -70,6 +72,10 @@ def get_distribution(cls, ctx, name=None, recipes=[],
7072 require_perfect_match : bool
7173 If True, will only match distributions with precisely the
7274 correct set of recipes.
75+ allow_replace_dist : bool
76+ If True, will allow an existing dist with the specified
77+ name but incompatible requirements to be overwritten by
78+ a new one with the current requirements.
7379 '''
7480
7581 existing_dists = Distribution .get_distributions (ctx )
@@ -123,7 +129,7 @@ def get_distribution(cls, ctx, name=None, recipes=[],
123129 # If there was a name match but we didn't already choose it,
124130 # then the existing dist is incompatible with the requested
125131 # configuration and the build cannot continue
126- if name_match_dist is not None :
132+ if name_match_dist is not None and not allow_replace_dist :
127133 error ('Asked for dist with name {name} with recipes ({req_recipes}) and '
128134 'NDK API {req_ndk_api}, but a dist '
129135 'with this name already exists and has either incompatible recipes '
@@ -154,6 +160,12 @@ def get_distribution(cls, ctx, name=None, recipes=[],
154160
155161 return dist
156162
163+ def folder_exists (self ):
164+ return exists (self .dist_dir )
165+
166+ def delete (self ):
167+ rmtree (self .dist_dir )
168+
157169 @classmethod
158170 def get_distributions (cls , ctx , extra_dist_dirs = []):
159171 '''Returns all the distributions found locally.'''
0 commit comments