5
5
from pythonforandroid .logger import (info , info_notify , warning ,
6
6
Err_Style , Err_Fore , error )
7
7
from pythonforandroid .util import current_directory
8
+ from shutil import rmtree
8
9
9
10
10
11
class Distribution (object ):
@@ -46,7 +47,8 @@ def get_distribution(cls, ctx, name=None, recipes=[],
46
47
ndk_api = None ,
47
48
force_build = False ,
48
49
extra_dist_dirs = [],
49
- require_perfect_match = False ):
50
+ require_perfect_match = False ,
51
+ allow_replace_dist = True ):
50
52
'''Takes information about the distribution, and decides what kind of
51
53
distribution it will be.
52
54
@@ -70,6 +72,10 @@ def get_distribution(cls, ctx, name=None, recipes=[],
70
72
require_perfect_match : bool
71
73
If True, will only match distributions with precisely the
72
74
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.
73
79
'''
74
80
75
81
existing_dists = Distribution .get_distributions (ctx )
@@ -123,7 +129,7 @@ def get_distribution(cls, ctx, name=None, recipes=[],
123
129
# If there was a name match but we didn't already choose it,
124
130
# then the existing dist is incompatible with the requested
125
131
# 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 :
127
133
error ('Asked for dist with name {name} with recipes ({req_recipes}) and '
128
134
'NDK API {req_ndk_api}, but a dist '
129
135
'with this name already exists and has either incompatible recipes '
@@ -154,6 +160,12 @@ def get_distribution(cls, ctx, name=None, recipes=[],
154
160
155
161
return dist
156
162
163
+ def folder_exists (self ):
164
+ return exists (self .dist_dir )
165
+
166
+ def delete (self ):
167
+ rmtree (self .dist_dir )
168
+
157
169
@classmethod
158
170
def get_distributions (cls , ctx , extra_dist_dirs = []):
159
171
'''Returns all the distributions found locally.'''
0 commit comments