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

Make it raise an error if an old ndk is used #1883

Merged
merged 5 commits into from
Jul 26, 2019

Conversation

opacam
Copy link
Member

@opacam opacam commented Jun 22, 2019

In order to avoid issues with old android's NDKs, we force to raise an error in case that an NDK version lower than the specified is detected. We also add the ability to extract the android's NDK letter version, which for now, will only be used to inform the user of the version which is using.

Important note: Don't merge this before the ndk-r19 core part I (we can easily adapt this for ndk-r17 but I leave it to ndk-19 so we make sure that travis fails as expected), once the Part I gets merged, we can rebase this into develop, push it and the tests should pass or we could adapt it to ndk-r17 and merge it before

Note: The idea to create this pr comes from this comment from the pull request ndk-r19 initial migration

See also: The reported error in travis test

@opacam opacam added the ndk-r19+ pull requests or issues related with android ndk-r19 label Jun 22, 2019
opacam added a commit to opacam/python-for-android that referenced this pull request Jul 5, 2019
In order to avoid issues with old android's NDKs, we force to raise an error in case that an NDK version lower than the specified is detected. We also add the ability to extract the android's NDK letter version, which for now, will only be used to inform the user of the version which is using

closes: kivy#1883
@AndreMiras
Copy link
Member

Nice PR!
Yes I would be tempted to adapt it for ndk-r17 so we can make an early merge with easy adaptations later.
Also we may want to unit test this feature

opacam added 2 commits July 19, 2019 12:05
In order to avoid issues with old android's NDKs, we force to raise an error in case that an NDK version lower than the specified is detected. We also add the ability to extract the android's NDK letter version, which for now, will only be used to inform the user of the version which is using
@opacam opacam force-pushed the feature-ndk-check branch from 59cc895 to 19972b4 Compare July 19, 2019 10:09
@opacam opacam removed the ndk-r19+ pull requests or issues related with android ndk-r19 label Jul 19, 2019
@opacam
Copy link
Member Author

opacam commented Jul 19, 2019

Ok, adapted to the current situation ndk-r17 and also added unittests for recommendations module.

As a side note: I skipped some of the tests for py2, because I make use of assertLog which is introduced in Python 3.4 and it fails for our tox py2 tests. There are solutions for this, but it would add an extra complexity and I don't think that it's worth it...@AndreMiras, let me know if you think different in this matter 😉

@opacam opacam changed the title [WIP] Make it raise an error if an old ndk is used Make it raise an error if an old ndk is used Jul 19, 2019
@inclement
Copy link
Member

Please feel free to make this Python 3 only if you prefer, I'll fill out #1918 soon and I think it shouldn't be an issue to merge that PR first.

I didn't raise the question there yet, but 3.4+ seems like a fine support base for now.

@opacam
Copy link
Member Author

opacam commented Jul 19, 2019

I didn't raise the question there yet, but 3.4+ seems like a fine support base for now.

Aaahhh, I would go with Python 3.6+ so we could make use of f-strings without external dependencies.

Copy link
Member

@inclement inclement left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @opacam

specified via attribute `MIN_NDK_VERSION`.

.. versionchanged:: 2019.06.06.1.dev0
Added the ability to get android's ndk `letter version` and also
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you capitalise NDK throughout, just for consistency?

'Note: If you got build errors, consider to download the'
' recommended ndk version which is {rec_version} and try'
' it again (after removing all the files generated with this'
' build). To download the android NDK visit the following page: '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be worded more directly, something like:

warning("Unable to read the NDK version from the given directory {}".format(ndk_dir))
warning("Make sure your NDK version is greater than {min_supported}. If you get build errors, download the recommended NDK {rec_version} from {ndk_url}".format(...))

warning(OLD_NDK_MESSAGE)
raise BuildInterruptingException(
'Unsupported NDK version detected {user_version}\n'
'* Note: Minimum supported NDK version is {min_supported}'.format(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'd write something shorter like "The minimum supported NDK version is {min_supported}. You can download it from {ndk_url}".

self.assertEqual(
cm.output,
[
"INFO:p4a:[INFO]: Could not determine NDK version, "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all these exact output checks may be annoying to keep updated. How about storing the unformatted strings in recommendations.py, and importing them here when checking the printed output matches them? I wouldn't necessarily suggest that for most log output, but I think it makes sense for this kind of important message which is a meaningful string in itself and not a throwaway log.

More generally, it might be nice to have helper functions that can pattern match against the expected log level (info, warning, ...) and some of the string content, when the whole string isn't important. That's just a thought, not a request here.

@AndreMiras
Copy link
Member

Yes @opacam of course we can skip python2 now 👍
Yes @inclement good question for python3, honestly I'd rather just support 3.6 and 3.7. It's purely arbitrary. Just because I like f-strings and also Ubuntu LTS doesn't have 3.5 😛

@inclement
Copy link
Member

@opacam I'm not certain about 3.6+ but I'm open for discussion, feel free to raise it on the "drop python2" PR. I suggested assuming 3.4+ here only because that's the version you mentioned needing.

inclement
inclement previously approved these changes Jul 19, 2019
@opacam
Copy link
Member Author

opacam commented Jul 19, 2019

Guys, If you don't mind, please don't merge this, I would like to address the @inclement comments before 😉

@opacam
Copy link
Member Author

opacam commented Jul 19, 2019

Ok, I think I addressed all of the @inclement comments, going to dinner now...I will check later or tomorrow, let me know if you find anything to be changed 😄

@opacam opacam mentioned this pull request Jul 20, 2019
TARGET_NDK_API_GREATER_THAN_TARGET_API_MESSAGE = (
'Target NDK API is {ndk_api}, '
'higher than the target Android API {android_api}.'
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, why in p4a we don't have all the const on the top of the file? It's probably fine, it's just that I'm more used to do it this way, or even sometimes in a dedicated file

mock_open_src_prop.assert_called_once_with(
join(self.ndk_dir, "source.properties")
)
assert version == "17.2.4988734"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: inconsistent assert. I personally prefer this version, but it's not what you seem to be using in the rest of the file.
Same thing in test_read_ndk_version_error below.
But anyway we're far from being consistent in this with p4a currently. Don't know if we want to address or not

assert version is None

def test_check_target_api_error_arch_armeabi(self):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: why are we sometimes leaving a blank space after method definition and sometimes not?

def test_check_ndk_api_warning_old_ndk(self):
"""
Given an `android api` lower than the supported by p4a, we should
get an `BuildInterruptingException`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seem to be a lie, right?

@AndreMiras
Copy link
Member

AndreMiras commented Jul 26, 2019

Very neat! I'm going to give it a try and if nothing seems to break, I'm in for a merge 👍
Edit: yes I forgot, are we rebased on current develop?

Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and didn't see any regression.
@opacam feel free to merge when you're ready

@inclement inclement merged commit 13c3b51 into kivy:develop Jul 26, 2019
@inclement
Copy link
Member

I'm assuming this is fine to merge. Thanks @opacam :)

@opacam opacam mentioned this pull request Aug 24, 2019
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants