Skip to content

Commit 1f2291e

Browse files
committed
Allowed dists to be overwritten by default
1 parent b50fc18 commit 1f2291e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

pythonforandroid/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def android_api(self, value):
130130
def ndk_api(self):
131131
'''The API number compile against'''
132132
if self._ndk_api is None:
133-
raise ValueError('Tried to access ndk_api_api but it has not '
133+
raise ValueError('Tried to access ndk_api but it has not '
134134
'been set - this should not happen, something '
135135
'went wrong!')
136136
return self._ndk_api

pythonforandroid/distribution.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pythonforandroid.logger import (info, info_notify, warning,
66
Err_Style, Err_Fore, error)
77
from pythonforandroid.util import current_directory
8+
from shutil import rmtree
89

910

1011
class 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

Comments
 (0)