Skip to content

Commit 479e71e

Browse files
committed
[dist] Remove python-install when reusing dist and...
when we detect an updated python recipe, so we make sure that the new one is built and installed. Note: this will remove all the python's site packages...maybe is not the best solution but it will do the job for now...
1 parent a985deb commit 479e71e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pythonforandroid/toolchain.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from os import environ
1111
from pythonforandroid import __version__
1212
from pythonforandroid.pythonpackage import get_dep_names_of_package
13+
from pythonforandroid.recipe import PythonRecipe
1314
from pythonforandroid.recommendations import (
1415
RECOMMENDED_NDK_API, RECOMMENDED_TARGET_API)
1516
from pythonforandroid.util import BuildInterruptingException
@@ -228,11 +229,14 @@ def build_dist_from_args(ctx, dist, args):
228229
'preparing build directories for those recipes...'.format(
229230
dist.recipes_to_rebuild)
230231
)
232+
needs_clean_site_packages = set()
231233
all_to_rebuild = set()
232234
for recipe_name in dist.recipes_to_rebuild:
233235
recipe = Recipe.get_recipe(recipe_name, ctx)
234236
all_to_rebuild.add(recipe_name)
235237
recipe.clean_build()
238+
if isinstance(recipe, PythonRecipe):
239+
needs_clean_site_packages.add(recipe_name)
236240
# if any recipe depends on this one, we also rebuild it
237241
for affected_recipe in dist.recipes.keys():
238242
try:
@@ -246,6 +250,15 @@ def build_dist_from_args(ctx, dist, args):
246250
):
247251
all_to_rebuild.add(affected_recipe)
248252
test_recipe.clean_build()
253+
if isinstance(test_recipe, PythonRecipe):
254+
needs_clean_site_packages.add(affected_recipe)
255+
if needs_clean_site_packages and exists(ctx.python_installs_dir):
256+
warning(
257+
'Cleaning site packages because the following recipes, ({}), '
258+
'are Python Packages, so we make sure that we rebuild new '
259+
'versions.'.format(', '.join(needs_clean_site_packages))
260+
)
261+
shutil.rmtree(ctx.python_installs_dir)
249262

250263
more_to_rebuild = set(dist.recipes_to_rebuild) ^ all_to_rebuild
251264
if more_to_rebuild:

0 commit comments

Comments
 (0)