Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider arch when looking for compatible dist. #1716

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions pythonforandroid/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __repr__(self):
@classmethod
def get_distribution(cls, ctx, name=None, recipes=[],
ndk_api=None,
archs=None,
force_build=False,
extra_dist_dirs=[],
require_perfect_match=False,
Expand All @@ -62,8 +63,10 @@ def get_distribution(cls, ctx, name=None, recipes=[],
exists, it will be used.
recipes : list
The recipes that the distribution must contain.
force_download: bool
If True, only downloaded dists are considered.
ndk_api : str
NDK API level used
archs : list
List of architectures to be built
force_build : bool
If True, the dist is forced to be built locally.
extra_dist_dirs : list
Expand Down Expand Up @@ -92,15 +95,13 @@ def get_distribution(cls, ctx, name=None, recipes=[],
# 1) Check if any existing dists meet the requirements
_possible_dists = []
for dist in possible_dists:
if (
ndk_api is not None and dist.ndk_api != ndk_api
) or dist.ndk_api is None:
if ((ndk_api is not None and dist.ndk_api != ndk_api)
or dist.ndk_api is None or dist.archs is None):
continue
for recipe in recipes:
if recipe not in dist.recipes:
break
else:
if (set(recipes).issubset(set(dist.recipes))
and set(archs).issubset(set(dist.archs))):
_possible_dists.append(dist)

possible_dists = _possible_dists

if possible_dists:
Expand All @@ -116,9 +117,7 @@ def get_distribution(cls, ctx, name=None, recipes=[],
continue
if ndk_api is not None and dist.ndk_api != ndk_api:
continue
if (set(dist.recipes) == set(recipes) or
(set(recipes).issubset(set(dist.recipes)) and
not require_perfect_match)):
if (set(dist.recipes) == set(recipes) or not require_perfect_match):
info_notify('{} has compatible recipes, using this one'
.format(dist.name))
return dist
Expand Down
8 changes: 5 additions & 3 deletions pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def dist_from_args(ctx, args):
name=args.dist_name,
recipes=split_argument_list(args.requirements),
ndk_api=args.ndk_api,
archs=split_argument_list(args.arch),
force_build=args.force_build,
require_perfect_match=args.require_perfect_match,
allow_replace_dist=args.allow_replace_dist)
Expand Down Expand Up @@ -569,6 +570,7 @@ def add_parser(subparsers, *args, **kwargs):
self.ctx.java_build_tool = args.java_build_tool

self._archs = split_argument_list(args.arch)
self._cached_dist = None

self.ctx.local_recipes = args.local_recipes
self.ctx.copy_libs = args.copy_libs
Expand Down Expand Up @@ -792,9 +794,9 @@ def export_dist(self, args):

@property
def _dist(self):
ctx = self.ctx
dist = dist_from_args(ctx, self.args)
return dist
if (self._cached_dist is None):
self._cached_dist = dist_from_args(self.ctx, self.args)
return self._cached_dist

@require_prebuilt_dist
def apk(self, args):
Expand Down