-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
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
Nice PR! |
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
59cc895
to
19972b4
Compare
Ok, adapted to the current situation As a side note: I skipped some of the tests for py2, because I make use of |
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. |
Aaahhh, I would go with Python 3.6+ so we could make use of |
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, thanks @opacam
pythonforandroid/recommendations.py
Outdated
specified via attribute `MIN_NDK_VERSION`. | ||
|
||
.. versionchanged:: 2019.06.06.1.dev0 | ||
Added the ability to get android's ndk `letter version` and also |
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.
Could you capitalise NDK throughout, just for consistency?
pythonforandroid/recommendations.py
Outdated
'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: ' |
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 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(...))
pythonforandroid/recommendations.py
Outdated
warning(OLD_NDK_MESSAGE) | ||
raise BuildInterruptingException( | ||
'Unsupported NDK version detected {user_version}\n' | ||
'* Note: Minimum supported NDK version is {min_supported}'.format( |
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.
Again, I'd write something shorter like "The minimum supported NDK version is {min_supported}. You can download it from {ndk_url}".
tests/test_recommendations.py
Outdated
self.assertEqual( | ||
cm.output, | ||
[ | ||
"INFO:p4a:[INFO]: Could not determine NDK version, " |
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 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.
Yes @opacam of course we can skip python2 now 👍 |
@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. |
Guys, If you don't mind, please don't merge this, I would like to address the @inclement comments before 😉 |
So it will be easier for us to maintain the tests for recommendations module
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 😄 |
TARGET_NDK_API_GREATER_THAN_TARGET_API_MESSAGE = ( | ||
'Target NDK API is {ndk_api}, ' | ||
'higher than the target Android API {android_api}.' | ||
) |
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.
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" |
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.
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): | ||
|
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.
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`. |
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 comment seem to be a lie, right?
Very neat! I'm going to give it a try and if nothing seems to break, I'm in for a merge 👍 |
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.
Tested and didn't see any regression.
@opacam feel free to merge when you're ready
I'm assuming this is fine to merge. Thanks @opacam :) |
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 tondk-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 beforeNote: 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