-
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
Fix building ssl for python3 #1217
Conversation
Why was this closed? |
@Zen-CODE Do you know why this was closed? |
@ysangkok It was closed by the OP, I don't know why. |
@agilewalker Do you know why this was closed? |
Perhaps the question for ask is whether #1195 fixes the issue? And if so, why has it not been merged? It seems most likely that the PR was just never merged... Can anyone confirm that pull requests fixes the issue? |
It does fix the issue, we are using it in Electrum. See the readme in https://github.com/spesmilo/electrum/tree/master/gui/kivy |
@ysangkok. Okay, I've re-opened the RP. Will test and merge if I don't see any problems. Thanks |
Even using the PR above (and setting the p4a.source_dir to point to there, I don't get a build error but when running get
If I try your instructions, when I try to checkout the specified commit, I get:
|
Weird that you can't find the commit, did you EDIT: actually, @SomberNight let me know that that commit is in kivy/python-for-android too. So I really can't understand how you couldn't check it out. |
My bad. Okay, I've got it checked out but I still get the "ImportError: No module named '_ssl'" when doing an import ssl. I am using python 3.5 though. I see the PR contains a python3.6 patch, so possibly it only works for 3.6? |
Following the recent discussion on irc, I think the following things need to be done for this to be merged:
I was going to start on this, but hit some other build problems with p4a, which I'm looking into first. |
Since this pull request has a minor conflict with current master, I rebased it while resolving the conflict: https://github.com/JonasT/python-for-android/tree/tlsfix (just in case anyone else needs this) |
Edit: nvm I was silly and forgot the internet permission. pull request seems to work fine at least as of now |
I have checked JonasT fork and it works for me. I hope in a merge. |
@pat1 I think the plan for the future is that python3crystax will be fully abandoned for a direct upstream python 3 build. With this, the missing standard library module issues, including this |
I've an rework openssl recipes that works on latest release and ndk, will open PR today. |
I probe compile test app: https://stackoverflow.com/questions/49884548/how-to-run-kivy-and-flask-apps-together with buildozer==0.0.34:
Error in my phone: (log from adb) files/app/crystax_python/stdlib.zip/ssl.py", line 101, in |
@homdx have you used the "tlsfix" branch? the "master" branch of the |
Hello Jonas,
Thank you for your answers.
The list of environments that I have are:
Available environments:
p4a-py2-api19-ndkbundle
Python 2 with min/target API 19, bundled NDK 19
p4a-py2-api28ndk21
Python 2 with target API 28, bundled NDK 21, min api 21
p4a-py3-api28ndk21
Python 3 with target API 28, NDK 21, min api 21
p4a-py3crystax-api19-ndkbundle
Python 3 Crystax with min/target API 19, and ndk-bundle for API 19
p4a-py3crystax-api26ndk19
Python 3 Crystax with target API 26 and NDK/min api 19
Which seems to correlate with what I see in your repo.
p4a-py3crystax-api26ndk21 would be the most useful build configuration for
me, as I need api26 for some of the painful Oreo stuff Google is bringing
in and there isn't a numpy recipe for plain python3.
I can re-attach the log, but if you have a p4a-py3crystax-api26ndk21 space
which I could pick up, it would probably be best if I jumped on that rathar
than trying to get the p4a-py3crystax-api26ndk19 working.
Regarding the workspace, is the correct syntax then:
p4aspaces shell p4a-py3crystax-api26ndk21 --workspace
Also, please let me know if this will work:
1. create new space with --workspace (which contains project code)
2. after first build, continue using this space for mulitple builds and
even multiple projects until the api configuration is obsolete or the space
stops working.
3. Have several spaces as listed in (2) but all sharing the same workspace?
So do please let me know if the points listed above will be a workable
system, or if there is another way to approach it? With the time cost of
creating spaces, I would like to avoid creating (or re-creating) whenever
possible, though I think once a build starts failing, it will be more time
efficient to create a clean space.
Again, thank you for your time.
John
…On Tue, Jan 1, 2019 at 10:50 PM JonasT ***@***.***> wrote:
@johnbolia <https://github.com/johnbolia> nice thanks for testing 👍 and
thanks for all the feedback! I attempted to clarify the installation
requirements and that the container is thrown away in the README.
Regarding your build issue, the screenshot doesn't seem to be attached for
some reason. But did you try using the p4a-py3crystax-api26ndk21
environment?
How to use of the --workspace command
You can specify a folder with --workspace which is then available in the
container as ~/workspace. Changes to this folder are immediately visible
on both ends (inside & outside of the container) and this folder remains
once the environment/container is stopped. So if you keep your project &
work in there, it will be persisted, while the whole p4a/buildozer install
around it is always fresh with your next launch.
I am not sure if I made a mistake setting up docker, or if this is normal?
This is currently a p4a build spaces limitation. I would need to add an
option to specify which "outside user" to use, such that inside the
container you'd have the correct permissions to access everything in your
workspace. I didn't do that yet, so inside the container things you work as
a root user which works around this permission complexity. (That's ugly
I'll admit, so thanks for putting this back on my radar, I'll add it soon)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1217 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACT71pfePxTlVqB_nLAkR5WLGxXqZz6Qks5u--Y_gaJpZM4RS_QZ>
.
|
Sorry, just a couple other things I forgot to include in the last email.
Regarding super user, although a bit ugly, not a big deal. I am not that
good in a nix environment, so I was just afraid I might have made a
mistake. It may be worth putting something in the documentation that this
behaviour is expected, as I was a bit spooked by the warning and almost
tried re-installing as I thought I had made a mistake. It might be fine as
is, I am an utter newbie with docker and not great with nix.
Also, does the --workspace command setup a volume? I was reading up on
docker and it looks like a similar behavior to what you describe.
Thanks,
John
…On Wed, Jan 2, 2019 at 10:11 AM John ***@***.***> wrote:
Hello Jonas,
Thank you for your answers.
The list of environments that I have are:
Available environments:
p4a-py2-api19-ndkbundle
Python 2 with min/target API 19, bundled NDK 19
p4a-py2-api28ndk21
Python 2 with target API 28, bundled NDK 21, min api 21
p4a-py3-api28ndk21
Python 3 with target API 28, NDK 21, min api 21
p4a-py3crystax-api19-ndkbundle
Python 3 Crystax with min/target API 19, and ndk-bundle for API 19
p4a-py3crystax-api26ndk19
Python 3 Crystax with target API 26 and NDK/min api 19
Which seems to correlate with what I see in your repo.
p4a-py3crystax-api26ndk21 would be the most useful build configuration
for me, as I need api26 for some of the painful Oreo stuff Google is
bringing in and there isn't a numpy recipe for plain python3.
I can re-attach the log, but if you have a p4a-py3crystax-api26ndk21
space which I could pick up, it would probably be best if I jumped on that
rathar than trying to get the p4a-py3crystax-api26ndk19 working.
Regarding the workspace, is the correct syntax then:
p4aspaces shell p4a-py3crystax-api26ndk21 --workspace
Also, please let me know if this will work:
1. create new space with --workspace (which contains project code)
2. after first build, continue using this space for mulitple builds and
even multiple projects until the api configuration is obsolete or the space
stops working.
3. Have several spaces as listed in (2) but all sharing the same workspace?
So do please let me know if the points listed above will be a workable
system, or if there is another way to approach it? With the time cost of
creating spaces, I would like to avoid creating (or re-creating) whenever
possible, though I think once a build starts failing, it will be more time
efficient to create a clean space.
Again, thank you for your time.
John
On Tue, Jan 1, 2019 at 10:50 PM JonasT ***@***.***> wrote:
> @johnbolia <https://github.com/johnbolia> nice thanks for testing 👍 and
> thanks for all the feedback! I attempted to clarify the installation
> requirements and that the container is thrown away in the README.
>
> Regarding your build issue, the screenshot doesn't seem to be attached
> for some reason. But did you try using the p4a-py3crystax-api26ndk21
> environment?
>
> How to use of the --workspace command
>
> You can specify a folder with --workspace which is then available in the
> container as ~/workspace. Changes to this folder are immediately visible
> on both ends (inside & outside of the container) and this folder remains
> once the environment/container is stopped. So if you keep your project &
> work in there, it will be persisted, while the whole p4a/buildozer install
> around it is always fresh with your next launch.
>
> I am not sure if I made a mistake setting up docker, or if this is normal?
>
> This is currently a p4a build spaces limitation. I would need to add an
> option to specify which "outside user" to use, such that inside the
> container you'd have the correct permissions to access everything in your
> workspace. I didn't do that yet, so inside the container things you work as
> a root user which works around this permission complexity. (That's ugly
> I'll admit, so thanks for putting this back on my radar, I'll add it soon)
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#1217 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ACT71pfePxTlVqB_nLAkR5WLGxXqZz6Qks5u--Y_gaJpZM4RS_QZ>
> .
>
|
@johnbolia I vaguely remember some issue with building Crystax + TLS with NDK API/minimum API 21. I use target API 26 + ndk/minimum 19 with Crystax personally and that works fine. Can you attach your build error? (don't use e-mail, respond using the web interface and attach the thing there - then it should show up) Regarding --workspace, it's just a volume yes. It needs a folder path as a parameter, which is the folder that will then be mapped inside as |
For what it's worth, we're also like 3 merges away from obsoleting Crystax I would think. So in 1-2 weeks this whole tlsfix & crystax business might have solved itself 🤷♀️ lol |
@Jonast I have attached the screen output Apologies to the issue thread for going so far off topic, I was on email and forgot all this was posted. |
Ah, it might want clang and only gcc is around. Should be easy to fix, nevertheless I remember CrystaX having some issues with higher minimum(!) API levels so I'm not sure if that environment is very useful anyway (I added a few just for testing mainly)
Do you require that as a minimum API though? This is almost never necessary, so it sounds to me like you might maybe just want to use |
@Jonast I checked with new deps New logs:
and
|
Great)) You reproduce new bug, like this: Then I launch app in phone: give error: Error: dlopen failed: could not load library "libpython2.7.so.1.0" needed by "libmain.so", caused by library "libpython2.7.so.1.0" not found Step for reproduce need Docker with env, provided by @Jonast Start with you branch p4a:
file .p4a now copy this file to folder and build:
And install apk and give errors:)
|
@opacam use |
@Jonast How increase build speed for p4a ? like |
I don't think you can speed up the build, this is a |
Ei @Jonast, the branch of the fix did not contained the |
@opacam build and run Python2
|
yes |
From my log (adb): Maybe request module don't know about let's encrypt certs?? |
About ssl certificate... that is another problem...I monkey patch my applications like this:
This has been working for me...probably it works for you... |
@opacam and where to add this code? |
This should be run before any call to ssl...in you app source code...I would put somewhere before kivy loads your app (you can remove some comments I put in there and adapt to your code) Also I would recommend you to see the following link, so you know what are you doing: https://en.wikipedia.org/wiki/Monkey_patch 😉 |
@opacam funny patch name
|
I'm pretty sure TLS below 1.1 is considered somewhat insecure, so please note that this might not be such a good idea if you want it to be properly encrypted. Did you try shipping your own cert storage and setting it? That might also work (it worked for me) |
Tell me please. how is it done |
@homdx check https://docs.python.org/3/library/ssl.html for load_verify_locations @AndreMiras maybe it would make sense to close this pull request as well? @agilewalker thanks so much for your work, it was very helpful as intermediate solution but we got openssl/TLS workiing on p4a master right now! |
Notice: Flask with kivy in one app also are working!)) under ANDROIDAP=28 ANDROIDNDKVER=r17c NDKAPI=21 and Python3 |
if not os.path.exists(join(ndk_sources_python_dir, '3.6')): | ||
os.mkdir(join(ndk_sources_python_dir, '3.6')) | ||
sh.sed('s#3.5#3.6#', | ||
join(ndk_sources_python_dir, '3.5/Android.mk'), |
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.
Pull request #1195 commits squashed and rebased onto master.