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

ctypes.py and _ctypes.so are not available #333

Closed
olymk2 opened this issue Mar 4, 2015 · 13 comments
Closed

ctypes.py and _ctypes.so are not available #333

olymk2 opened this issue Mar 4, 2015 · 13 comments

Comments

@olymk2
Copy link
Contributor

olymk2 commented Mar 4, 2015

Seems quite a few libraries require _ctypes.so to be available i have found a few reported by others and in my case freetype requires it.

seems there are reports of people getting it to work (I have not managed myself yet) here are some links i have found.

Patch here
https://groups.google.com/forum/?hl=en#!searchin/python-android/ctypes/python-android/vDaaJXNYz_A/eazMVI-DQSYJ

related issue here
#301

and another attempt here
https://bitbucket.org/Nodrev/kivy-python-for-android-with-ctypes/commits/30948f20cef489dba165b3b33aefccbb5f400b84#chg-recipes/python/recipe.sh

I have been trying myself but i dont seem to get a ctypes.so file created, my attempt is here but i am unsure about what i am doing :p
https://github.com/olymk2/python-for-android/tree/feature/ctypes

Would be good to see this one patch an dbuilding.

olymk2 pushed a commit to olymk2/python-for-android that referenced this issue Mar 18, 2015
olymk2 pushed a commit to olymk2/python-for-android that referenced this issue Mar 18, 2015
@tito
Copy link
Member

tito commented Mar 18, 2015

@olymk2 Great progress on your fork, i'm waiting your PR :)

olymk2 pushed a commit to olymk2/python-for-android that referenced this issue Mar 18, 2015
olymk2 pushed a commit to olymk2/python-for-android that referenced this issue Mar 18, 2015
@olymk2
Copy link
Contributor Author

olymk2 commented Mar 18, 2015

i am hoping to put one in soon using this PR olymk2#1

it seems to build the ctypes.so file and place it in ../libs/armeabi/_ctypes.so as i expect how ever running on an android tablet i am still getting.

.buildozer/android/app/_applibs/freetype/init.py", line 19, in
.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/ctypes/init.py", line 10, in
ImportError: No module named _ctypes
Python for android ended.
System.exit called, status: 0

when i try to use a library that requires ctypes in this case freetype i still get

so i am not sure if there is something else i need todo after the .so file exists i have put in the PythonService.java file to load the library.

does anyone have any ideas ? i could put it in for a pr now because it does build the .so file.

@tito
Copy link
Member

tito commented Mar 18, 2015

the libs in libs are more "system" lib, not python extension.

Either the _ctypes.so is biglinked with libpython.so, or it's separated in the ctypes/_ctypes.so directory, same on desktop.

@olymk2
Copy link
Contributor Author

olymk2 commented Mar 18, 2015

okay, i will try again later see if i can figure out if its creating a folder for ctypes or if its being biglinked.

its quite difficult to spot whats going on as the build process chucks out so much content.

thanks for the tip

olymk2 pushed a commit to olymk2/python-for-android that referenced this issue Mar 18, 2015
@olymk2
Copy link
Contributor Author

olymk2 commented Mar 19, 2015

Created a dead basic repo to test python imports, link here if its usefull to any one https://github.com/olymk2/buildozer-test-imports

@olymk2
Copy link
Contributor Author

olymk2 commented Mar 19, 2015

just an update with progress i can see ctypes is created and placed in the path below.

/opt/buildozer/testappimports/.buildozer/android/platform/python-for-android/dist/testappimports/private/lib/python2.7/lib-dynload/_ctypes.so

_ctypes.so is 168.1 kB in /testappimports/private/lib/python2.7/lib-dynload/_ctypes.so

but still no joy, i did manage to patch out all errors i could see during the build process i am wondering if i have something else going wrong some where

@olymk2
Copy link
Contributor Author

olymk2 commented Mar 20, 2015

Okay this may actually be working i just built my test project wondering if i have some cruft left on my system perhaps the clean is not fully clearing everything away.

going to blow away the build on my main program later and see if it works anyone fancy trying the above to see if it works, if you use the test project be aware it builds the project in /opt/buildozer so change or take that out of the spec file.

@GeoRW
Copy link

GeoRW commented Apr 4, 2015

Hi, I tried this and it worked!
_ctypes.so was built correctly and included in android package.
-rwxr-xr-x 1 georw georw 485084 Apr 4 15:58 _ctypes.so

I applied the patch from:
https://groups.google.com/forum/?hl=en#!searchin/python-android/ctypes/python-android/vDaaJXNYz_A/eazMVI-DQSYJ
as well as fix for malloc.h:
In the file: android-ndk-r9d/platforms/android-14/arch-arm/usr/include/malloc.h have the line: extern size_t malloc_usable_size(void_); //instead of (const void_)

All compiled well, and it's working on Android.
Regards

@olymk2
Copy link
Contributor Author

olymk2 commented Apr 4, 2015

@GeoRW I have a PR in for these changes, you will find that although it compiles you can not import any libraries because ctypes does not know where to look.

There is a simple fix for that also in this branch #343 if you have tested from this branch may be worth commenting hopefully we can get it merged :)

@GeoRW
Copy link

GeoRW commented Apr 4, 2015

well, I can use the compiled library in Android without any issues. no need to patch util.py in my case. I'm loading libwebp.so when using https://github.com/expobrain/python-webm which requires ctypes. Don't know much about C and the whole build process, but happy to make this working for my project. Cheers.

@GeoRW
Copy link

GeoRW commented Apr 4, 2015

ok, tried the patches at #343 on clean environment and all workes fine without a need to patch malloc.h in NDK. ctypes library is compiled and packaged correctly. Cheers

@tito
Copy link
Member

tito commented May 16, 2015

Ctypes is now part of python-for-android!

@smpsupply
Copy link

Hello all, I tried to compile with buildozer and python-2.7.2 is downloaded. I tried to follow the solution provided here but I found the recipe is different. After finish build, _ctypes still doesn't appear in the folder. My environment is MacOS 10.13.4. Hope someone can help. Thanks.

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

No branches or pull requests

4 participants