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

Doc clarification on p4a requirements for basic kivy app with SDL2 bootstrap #724

Closed
bidafiwoc opened this issue Apr 27, 2016 · 2 comments
Closed

Comments

@bidafiwoc
Copy link

bidafiwoc commented Apr 27, 2016

The quickstart docs at http://python-for-android.readthedocs.org/en/latest/quickstart/, describe how to invoke p4a to get a basic distribution with a pygame bootstrap:

To create a basic distribution, run .e.g:

python-for-android create --dist_name=testproject --bootstrap=pygame --requirements=sdl,python2

Later, the same document states:

You can build an SDL2 APK similarly, creating a dist as follows:

python-for-android create --dist_name=testsdl2 --bootstrap=sdl2 --requirements=sdl2,python2

You can then make an APK in the same way, but this is more experimental and doesn’t support as much customisation yet.

However, in my testing with a helloworld program (using p4a with Android API 16 / NDK 11c, and a physical device running 5.0.2), I find that the above example for the pygame bootstrap works, while the example for the SDL2 bootstrap does not work without modification.

The error I get in this SDL2-bootstrap hello-world example is pretty straightforward. Via logcat, I see an ImportError: No module named kivy. I can similarly verify that the kivy module is missing (in the SDL2-bootstrap APK) by unpacking the APK file generated by p4a with both bootstraps. Inside the assets/private.mp3 gzipped tarball (itself inside the zipped APK), I find the lib/python2.7/site-packages directory. In the APK created with pygame-bootstrap (as above), this directory is populated with a kivy subdirectory (among others). In the APK created with SDL2-bootstrap (again, as above recommended via quickstart docs), this directory is largely empty (save a README file).

The fix, once recognized, is fairly straightforward. I have to explicitly add a requirement on kivy to make the SDL2 bootstrap function properly. I use the following to successfully run the same helloworld test with SDL2 bootstrap:

python-for-android create --dist_name=testsdl2 --bootstrap=sdl2 --requirements=sdl2,kivy,python2

What's particularly strange to me, is that I can't intuitively understand how kivy module was added to the pygame bootstrap in the first place. From the quickstart docs (snippets above), the only difference between the pygame and sdl2 calls were the difference between sdl + pygame requirements and sdl2 requirements (respectively). As such, to see the inclusion of kivy in the former, and not the latter, I would have expected to see a dependency upon kivy in either of the sdl or pygame recipes, and not in the sdl2 recipe. However, when running p4a recipes, I don't see any dependency on kivy in either case. This leads me to intuit that there's perhaps some extra stuff going on behind the scenes in the case of the pygame bootstrap, that's not present in the case of the sdl2 bootstrap.

Besides adding the kivy requirement to the sdl2 bootstrap quickstart example, I would suggest it might be worthwhile (for the community's sake) to expand upon bootstrap issues a bit in the python-for-android online docs ( http://python-for-android.readthedocs.org/ ) to prevent further confusion. In particular, while I understand that pygame boostrap is deprecated (albeit more feature-complete at the current time than sdl2 boostrap), I'd be interested to learn more about the roadmap between the two, and suggested best practices for new development. If I understood the situation better myself, I'd make a commit + PR. In the meantime, I hope this issue report helps.

Thanks!

@inclement
Copy link
Member

The pygame bootstrap itself has kivy listed as a dependency, and it's therefore automatically included with that bootstrap. This is because the bootstrap is quite kivy specific and probably won't work for other things.

The sdl2 bootstrap doesn't automatically include kivy because this bootstrap can be used with other libraries instead, such as PySDL2.

The sdl2 bootstrap is now the focus of almost all development and supports most of the same things as the pygame one plus probably more. If it works for your needs, I recommend using it already.

@inclement
Copy link
Member

I've added a note about kivy needing to be declared in this section of the doc. If you'd like to keep an open issue about any other sdl2 doc problems, please make one specifically for this.

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

2 participants