-
Notifications
You must be signed in to change notification settings - Fork 503
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
Code improvements around NDK download #961
Code improvements around NDK download #961
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking very good, thank you!
I wrote some comments, but most of them are remark or nitpick, just so we're aware of. So as usual feel free to ignore obviously.
Something more major however is tests are failing. Do you have an idea why? Do you need help investigating?
======================================================================
ERROR: test_p4a_recommended_android_ndk_found (tests.test_buildozer.TestBuildozer)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/mock.py", line 1128, in patched
arg = patching.__enter__()
File "/usr/lib/python3.4/unittest/mock.py", line 1197, in __enter__
original, local = self.get_original()
File "/usr/lib/python3.4/unittest/mock.py", line 1171, in get_original
"%s does not have the attribute %r" % (target, name)
AttributeError: <module 'buildozer.targets.android' from '/home/travis/build/kivy/buildozer/buildozer/targets/android.py'> does not have the attribute 'open'
----------------------------------------------------------------------
buildozer/__init__.py
Outdated
@@ -879,10 +871,27 @@ def namify(self, name): | |||
def root_dir(self): | |||
return realpath(dirname(self.specfilename)) | |||
|
|||
@property | |||
def user_build_dir(self): | |||
'''The user-provided build dir, if any.''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that we now have a dedicated method for this. But I also have a nitpick.
PEP-0257 say docstring should be double quotes, not single. Same in other docstrings. I know buildozer and p4a is already inconsistent here.
https://www.python.org/dev/peps/pep-0257/#what-is-a-docstring
if self.user_build_dir is not None: | ||
self.error( | ||
('Failed: build_dir is specified as {} in the buildozer config. `appclean` will ' | ||
'not attempt to delete files in a user-specified build directory.').format(self.user_build_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that you thought about preventing that
# that python-for-android cannot provide a recommendation, which in | ||
# turn only happens if the python-for-android is old and probably | ||
# doesn't support any newer NDK. | ||
DEFAULT_ANDROID_NDK_VERSION = '17c' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that comment
# Default p4a dir | ||
p4a_dir = join(self.buildozer.platform_dir, self.p4a_directory_name) | ||
|
||
# Possibly overriden by user setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/overriden/overridden/
else: | ||
pa_dir = self.pa_dir | ||
# make sure to read p4a version only the first time | ||
if self.p4a_recommended_ndk_version is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we implement some kind of caching, then maybe in the future we want to make it a dedicated property that automagically deals with it
@@ -430,7 +437,7 @@ def _install_android_ndk(self): | |||
archive = 'android-ndk-r{0}-linux-{1}.tar.bz2' | |||
is_64 = (os.uname()[4] == 'x86_64') | |||
else: | |||
raise SystemError('Unsupported platform: {0}'.format(platform)) | |||
raise SystemError('Unsupported platform: {}'.format(platform)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if you caught that with unit tests or with sharp eyes 😄
I fixed the previous test failure about the open function (which seemed like a reasonable failure, I don't know why it worked locally), but now I get another issue that I can't reproduce locally:
The failure is straightforward enough, but it isn't clear why it's failing and why it only fails in travis... |
d5ac294
to
f3dab17
Compare
I've pushed an improvement to how the dist dir is calculated (including a backwards compatibility fix, I think this was broken in #978 for existing dists). Let's see if the tests will pass now... |
f3dab17
to
5d1ddd2
Compare
Actually there might be some further rebase issues, not for merging quite yet. |
59d744b
to
877fc87
Compare
I could reproduce on my local Ubuntu.
Using
Also as I suggested on Discord, maybe we should also migrate that build to |
877fc87
to
8bc5ffd
Compare
@@ -47,26 +47,28 @@ | |||
# does. | |||
DEFAULT_SDK_TAG = '4333796' | |||
|
|||
DEFAULT_ARCH = 'armeabi-v7a' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually at some point maybe the default should be arm64-v8a
since the play store requires at least that one when uploading APK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but chose not to change the default in this particular PR.
Hah, looks like just importing mock works. Must be a unittest.mock change between Python 3.6 and 3.7. I've just changed the code to import mock for now, this can easily be changed and investigated later. I'd rather get this merged as soon as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried it locally the APK build OK. Let's squash and merge it
Here's the follow up PR that fixes mocking #983 |
Thanks @AndreMiras! |
Made a few improvements while checking NDK version downloads were working correctly.
I'm pretty satisfied that everything is good, thanks @opacam for doing the real work here.
In particular, the scenarios that need covering are:
I was worried there might be some issues with how buildozer stores the NDKs, but it all seems basically good.
Also added a new command
buildozer appclean
that deletes the build directory (i.e. app_dir/.buildozer), because this is much nicer than telling users to delete it themselves.