Skip to content

Commit 30ac677

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

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-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: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from pythonforandroid.logger import (info, info_notify, warning,
66
Err_Style, Err_Fore, error)
77
from pythonforandroid.util import current_directory
8+
from os.path import exists
9+
from shutil import rmtree
810

911

1012
class Distribution(object):
@@ -46,7 +48,8 @@ def get_distribution(cls, ctx, name=None, recipes=[],
4648
ndk_api=None,
4749
force_build=False,
4850
extra_dist_dirs=[],
49-
require_perfect_match=False):
51+
require_perfect_match=False,
52+
allow_replace_dist=True):
5053
'''Takes information about the distribution, and decides what kind of
5154
distribution it will be.
5255
@@ -70,6 +73,10 @@ def get_distribution(cls, ctx, name=None, recipes=[],
7073
require_perfect_match : bool
7174
If True, will only match distributions with precisely the
7275
correct set of recipes.
76+
allow_replace_dist : bool
77+
If True, will allow an existing dist with the specified
78+
name but incompatible requirements to be overwritten by
79+
a new one with the current requirements.
7380
'''
7481

7582
existing_dists = Distribution.get_distributions(ctx)
@@ -123,7 +130,7 @@ def get_distribution(cls, ctx, name=None, recipes=[],
123130
# If there was a name match but we didn't already choose it,
124131
# then the existing dist is incompatible with the requested
125132
# configuration and the build cannot continue
126-
if name_match_dist is not None:
133+
if name_match_dist is not None and not allow_replace_dist:
127134
error('Asked for dist with name {name} with recipes ({req_recipes}) and '
128135
'NDK API {req_ndk_api}, but a dist '
129136
'with this name already exists and has either incompatible recipes '
@@ -154,6 +161,12 @@ def get_distribution(cls, ctx, name=None, recipes=[],
154161

155162
return dist
156163

164+
def folder_exists(self):
165+
return exists(self.dist_dir)
166+
167+
def delete(self):
168+
rmtree(self.dist_dir)
169+
157170
@classmethod
158171
def get_distributions(cls, ctx, extra_dist_dirs=[]):
159172
'''Returns all the distributions found locally.'''

0 commit comments

Comments
 (0)