Skip to content

Commit 1947491

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 dbf6b2f commit 1947491

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, handle_build_exception
@@ -227,11 +228,14 @@ def build_dist_from_args(ctx, dist, args):
227228
'preparing build directories for those recipes...'.format(
228229
dist.recipes_to_rebuild)
229230
)
231+
needs_clean_site_packages = set()
230232
all_to_rebuild = set()
231233
for recipe_name in dist.recipes_to_rebuild:
232234
recipe = Recipe.get_recipe(recipe_name, ctx)
233235
all_to_rebuild.add(recipe_name)
234236
recipe.clean_build()
237+
if isinstance(recipe, PythonRecipe):
238+
needs_clean_site_packages.add(recipe_name)
235239
# if any recipe depends on this one, we also rebuild it
236240
for affected_recipe in dist.recipes.keys():
237241
try:
@@ -245,6 +249,15 @@ def build_dist_from_args(ctx, dist, args):
245249
):
246250
all_to_rebuild.add(affected_recipe)
247251
test_recipe.clean_build()
252+
if isinstance(test_recipe, PythonRecipe):
253+
needs_clean_site_packages.add(affected_recipe)
254+
if needs_clean_site_packages and exists(ctx.python_installs_dir):
255+
warning(
256+
'Cleaning site packages because the following recipes, ({}), '
257+
'are Python Packages, so we make sure that we rebuild new '
258+
'versions.'.format(', '.join(needs_clean_site_packages))
259+
)
260+
shutil.rmtree(ctx.python_installs_dir)
248261

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

0 commit comments

Comments
 (0)