From 2304f20656018f11e85582ebed455e101576652a Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sun, 3 Feb 2019 17:33:58 +0000 Subject: [PATCH] Removed more references to pygame --- MANIFEST.in | 1 - doc/source/apis.rst | 12 +- doc/source/bootstraps.rst | 2 +- doc/source/services.rst | 12 +- .../common/build/jni/application/src/start.c | 6 +- .../org/renpy/android/ResourceManager.java | 3 +- .../recipes/android/src/android/_android.pyx | 54 --------- .../android/src/android/_android_jni.c | 112 ------------------ test_builds/test.sh | 3 - test_builds/tests/test_apk.py | 69 ----------- testapps/testlauncher_setup/pygame.py | 30 ----- 11 files changed, 11 insertions(+), 293 deletions(-) delete mode 100755 test_builds/test.sh delete mode 100644 test_builds/tests/test_apk.py delete mode 100644 testapps/testlauncher_setup/pygame.py diff --git a/MANIFEST.in b/MANIFEST.in index 1c26fb073d..4d6223ed3d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -10,4 +10,3 @@ recursive-include pythonforandroid/recipes *.py *.patch *.c *.pyx Setup *.h recursive-include pythonforandroid/bootstraps *.properties *.xml *.java *.tmpl *.txt *.png *.aidl *.py *.sh *.c *.h *.html *.patch prune .git -prune pythonforandroid/bootstraps/pygame/build/libs diff --git a/doc/source/apis.rst b/doc/source/apis.rst index 2865ecb524..46726bd39c 100644 --- a/doc/source/apis.rst +++ b/doc/source/apis.rst @@ -98,8 +98,7 @@ Advanced Android API use As mentioned above, the ``android`` Python module provides a simple wrapper around many native Android APIS, and it can be included by adding it to your requirements, e.g. :code:`--requirements=kivy,android`. -It is not automatically included by Kivy unless you use the old (Pygame) -bootstrap. +It is not automatically included with Kivy. The available functionality of this module is not separately documented. You can read the source `on @@ -159,9 +158,6 @@ a Java class. For instance, here is the code to vibrate your device:: # application, this reference is stored automatically by # Kivy's PythonActivity bootstrap - # This one works with Pygame - # PythonActivity = autoclass('org.renpy.android.PythonActivity') - # This one works with SDL2 PythonActivity = autoclass('org.kivy.android.PythonActivity') @@ -176,9 +172,9 @@ Things to note here are: - The class that must be wrapped depends on the bootstrap. This is because Pyjnius is using the bootstrap's java source code to get a - reference to the current activity, which both the Pygame and SDL2 - bootstraps store in the ``mActivity`` static variable. This - difference isn't always important, but it's important to know about. + reference to the current activity, which the bootstraps store in the + ``mActivity`` static variable. This difference isn't always + important, but it's important to know about. - The code closely follows the Java API - this is exactly the same set of function calls that you'd use to achieve the same thing from Java code. diff --git a/doc/source/bootstraps.rst b/doc/source/bootstraps.rst index ef59293221..db82d56ebc 100644 --- a/doc/source/bootstraps.rst +++ b/doc/source/bootstraps.rst @@ -3,7 +3,7 @@ Bootstraps ========== This page is about creating new bootstrap backends. For build options -of existing bootstraps (i.e. with SDL2, Pygame, Webview etc.), see +of existing bootstraps (i.e. with SDL2, Webview, etc.), see :ref:`build options `. python-for-android (p4a) supports multiple *bootstraps*. These fulfill a diff --git a/doc/source/services.rst b/doc/source/services.rst index c63b2ce1be..641bcd89f3 100644 --- a/doc/source/services.rst +++ b/doc/source/services.rst @@ -26,18 +26,16 @@ There are two ways to have services included in your APK. Service folder ~~~~~~~~~~~~~~ -This basic method works with both the new SDL2 and old Pygame -bootstraps. It is recommended to use the second method (below) where -possible. +This is the older method of handling services. It is +recommended to use the second method (below) where possible. Create a folder named ``service`` in your app directory, and add a file ``service/main.py``. This file should contain the Python code that you want the service to run. To start the service, use the :code:`start_service` function from the -:code:`android` module (included automatically with the Pygame -bootstrap, you must add it to the requirements manually with SDL2 if -you wish to use this method):: +:code:`android` module (you may need to add ``android`` to your app +requirements):: import android android.start_service(title='service name', @@ -49,8 +47,6 @@ you wish to use this method):: Arbitrary service scripts ~~~~~~~~~~~~~~~~~~~~~~~~~ -.. note:: This service method is *not supported* by the Pygame bootstrap. - This method is recommended for non-trivial use of services as it is more flexible, supporting multiple services and a wider range of options. diff --git a/pythonforandroid/bootstraps/common/build/jni/application/src/start.c b/pythonforandroid/bootstraps/common/build/jni/application/src/start.c index cc4e5db603..8f746727a7 100644 --- a/pythonforandroid/bootstraps/common/build/jni/application/src/start.c +++ b/pythonforandroid/bootstraps/common/build/jni/application/src/start.c @@ -15,15 +15,11 @@ #include #include "bootstrap_name.h" + #ifndef BOOTSTRAP_USES_NO_SDL_HEADERS #include "SDL.h" -#ifndef BOOTSTRAP_NAME_PYGAME #include "SDL_opengles2.h" #endif -#endif -#ifdef BOOTSTRAP_NAME_PYGAME -#include "jniwrapperstuff.h" -#endif #include "android/log.h" #define ENTRYPOINT_MAXLEN 128 diff --git a/pythonforandroid/bootstraps/common/build/src/main/java/org/renpy/android/ResourceManager.java b/pythonforandroid/bootstraps/common/build/src/main/java/org/renpy/android/ResourceManager.java index 47455abb04..a170c846b4 100644 --- a/pythonforandroid/bootstraps/common/build/src/main/java/org/renpy/android/ResourceManager.java +++ b/pythonforandroid/bootstraps/common/build/src/main/java/org/renpy/android/ResourceManager.java @@ -1,8 +1,7 @@ /** * This class takes care of managing resources for us. In our code, we * can't use R, since the name of the package containing R will - * change. (This same code is used in both org.renpy.android and - * org.renpy.pygame.) So this is the next best thing. + * change. So this is the next best thing. */ package org.renpy.android; diff --git a/pythonforandroid/recipes/android/src/android/_android.pyx b/pythonforandroid/recipes/android/src/android/_android.pyx index d332eedf30..aeaaf2310a 100644 --- a/pythonforandroid/recipes/android/src/android/_android.pyx +++ b/pythonforandroid/recipes/android/src/android/_android.pyx @@ -2,22 +2,6 @@ include "config.pxi" -IF BOOTSTRAP == 'pygame': - cdef extern int SDL_ANDROID_CheckPause() - cdef extern void SDL_ANDROID_WaitForResume() nogil - cdef extern void SDL_ANDROID_MapKey(int scancode, int keysym) - - def check_pause(): - return SDL_ANDROID_CheckPause() - - def wait_for_resume(): - android_accelerometer_enable(False) - SDL_ANDROID_WaitForResume() - android_accelerometer_enable(accelerometer_enabled) - - def map_key(scancode, keysym): - SDL_ANDROID_MapKey(scancode, keysym) - # Android keycodes. KEYCODE_UNKNOWN = 0 KEYCODE_SOFT_LEFT = 1 @@ -179,8 +163,6 @@ python_act = autoclass(JAVA_NAMESPACE + u'.PythonActivity') Rect = autoclass(u'android.graphics.Rect') mActivity = python_act.mActivity if mActivity: - # PyGame backend already has the listener so adding - # one here leads to a crash/too much cpu usage. # SDL2 now does not need the listener so there is # no point adding a processor intensive layout listenere here. height = 0 @@ -274,42 +256,6 @@ def get_buildinfo(): binfo.VERSION_RELEASE = BUILD_VERSION_RELEASE return binfo -IF IS_PYGAME: - # Activate input - required to receive input events. - cdef extern void android_activate_input() - - def init(): - android_activate_input() - - # Action send - cdef extern void android_action_send(char*, char*, char*, char*, char*) - def action_send(mimetype, filename=None, subject=None, text=None, - chooser_title=None): - cdef char *j_mimetype = mimetype - cdef char *j_filename = NULL - cdef char *j_subject = NULL - cdef char *j_text = NULL - cdef char *j_chooser_title = NULL - if filename is not None: - j_filename = filename - if subject is not None: - j_subject = subject - if text is not None: - j_text = text - if chooser_title is not None: - j_chooser_title = chooser_title - android_action_send(j_mimetype, j_filename, j_subject, j_text, - j_chooser_title) - - cdef extern int android_checkstop() - cdef extern void android_ackstop() - - def check_stop(): - return android_checkstop() - - def ack_stop(): - android_ackstop() - # ------------------------------------------------------------------- # URL Opening. def open_url(url): diff --git a/pythonforandroid/recipes/android/src/android/_android_jni.c b/pythonforandroid/recipes/android/src/android/_android_jni.c index 8eee77073b..9fea723ed8 100644 --- a/pythonforandroid/recipes/android/src/android/_android_jni.c +++ b/pythonforandroid/recipes/android/src/android/_android_jni.c @@ -201,118 +201,6 @@ void android_get_buildinfo() { } } -#if IS_PYGAME -void android_activate_input(void) { - static JNIEnv *env = NULL; - static jclass *cls = NULL; - static jmethodID mid = NULL; - - if (env == NULL) { - env = SDL_ANDROID_GetJNIEnv(); - aassert(env); - cls = (*env)->FindClass(env, "org/renpy/android/SDLSurfaceView"); - aassert(cls); - mid = (*env)->GetStaticMethodID(env, cls, "activateInput", "()V"); - aassert(mid); - } - - (*env)->CallStaticVoidMethod(env, cls, mid); -} - -int android_checkstop(void) { - static JNIEnv *env = NULL; - static jclass *cls = NULL; - static jmethodID mid = NULL; - - if (env == NULL) { - env = SDL_ANDROID_GetJNIEnv(); - aassert(env); - cls = (*env)->FindClass(env, "org/renpy/android/SDLSurfaceView"); - aassert(cls); - mid = (*env)->GetStaticMethodID(env, cls, "checkStop", "()I"); - aassert(mid); - } - - return (*env)->CallStaticIntMethod(env, cls, mid); -} - -void android_ackstop(void) { - static JNIEnv *env = NULL; - static jclass *cls = NULL; - static jmethodID mid = NULL; - - if (env == NULL) { - env = SDL_ANDROID_GetJNIEnv(); - aassert(env); - cls = (*env)->FindClass(env, "org/renpy/android/SDLSurfaceView"); - aassert(cls); - mid = (*env)->GetStaticMethodID(env, cls, "ackStop", "()I"); - aassert(mid); - } - - (*env)->CallStaticIntMethod(env, cls, mid); -} - -void android_action_send(char *mimeType, char *filename, char *subject, char *text, char *chooser_title) { - static JNIEnv *env = NULL; - static jclass *cls = NULL; - static jmethodID mid = NULL; - - if (env == NULL) { - env = SDL_ANDROID_GetJNIEnv(); - aassert(env); - cls = (*env)->FindClass(env, "org/renpy/android/Action"); - aassert(cls); - mid = (*env)->GetStaticMethodID(env, cls, "send", - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); - aassert(mid); - } - - jstring j_mimeType = (*env)->NewStringUTF(env, mimeType); - jstring j_filename = NULL; - jstring j_subject = NULL; - jstring j_text = NULL; - jstring j_chooser_title = NULL; - if ( filename != NULL ) - j_filename = (*env)->NewStringUTF(env, filename); - if ( subject != NULL ) - j_subject = (*env)->NewStringUTF(env, subject); - if ( text != NULL ) - j_text = (*env)->NewStringUTF(env, text); - if ( chooser_title != NULL ) - j_chooser_title = (*env)->NewStringUTF(env, text); - - (*env)->CallStaticVoidMethod( - env, cls, mid, - j_mimeType, j_filename, j_subject, j_text, - j_chooser_title); -} - -void android_open_url(char *url) { - static JNIEnv *env = NULL; - static jclass *cls = NULL; - static jmethodID mid = NULL; - - if (env == NULL) { - env = SDL_ANDROID_GetJNIEnv(); - aassert(env); - cls = (*env)->FindClass(env, "org/renpy/android/SDLSurfaceView"); - aassert(cls); - mid = (*env)->GetStaticMethodID(env, cls, "openUrl", "(Ljava/lang/String;)V"); - aassert(mid); - } - - PUSH_FRAME; - - (*env)->CallStaticVoidMethod( - env, cls, mid, - (*env)->NewStringUTF(env, url) - ); - - POP_FRAME; -} -#endif // IS_PYGAME - void android_start_service(char *title, char *description, char *arg) { static JNIEnv *env = NULL; static jclass *cls = NULL; diff --git a/test_builds/test.sh b/test_builds/test.sh deleted file mode 100755 index cd5e5bf5a3..0000000000 --- a/test_builds/test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh - -py.test -s diff --git a/test_builds/tests/test_apk.py b/test_builds/tests/test_apk.py deleted file mode 100644 index 96162629b7..0000000000 --- a/test_builds/tests/test_apk.py +++ /dev/null @@ -1,69 +0,0 @@ - -from pythonforandroid.toolchain import main -from pythonforandroid.recipe import Recipe - -from os import path -import sys - -import pytest - -# Set these values manually before testing (for now) -ndk_dir = '/home/asandy/android/crystax-ndk-10.3.2' -ndk_version='crystax-ndk-10.3.2' - -cur_dir = path.dirname(path.abspath(__file__)) -testapps_dir = path.join(path.split(path.split(cur_dir)[0])[0], 'testapps') - -orig_argv = sys.argv[:] - -def set_argv(argv): - while sys.argv: - sys.argv.pop() - sys.argv.append(orig_argv[0]) - for item in argv: - sys.argv.append(item) - for item in orig_argv[1:]: - if item == '-s': - continue - sys.argv.append(item) - - -argument_combinations = [{'app_dir': path.join(testapps_dir, 'testapp'), - 'requirements': 'python2,pyjnius,kivy', - 'packagename': 'p4a_test_sdl2', - 'bootstrap': 'sdl2', - 'ndk_dir': ndk_dir, - 'ndk_version': ndk_version}, - {'app_dir': path.join(testapps_dir, 'testapp'), - 'requirements': 'python2,pyjnius,kivy', - 'packagename': 'p4a_test_pygame', - 'bootstrap': 'pygame', - 'ndk_dir': ndk_dir, - 'ndk_version': ndk_version}, - {'app_dir': path.join(testapps_dir, 'testapp_flask'), - 'requirements': 'python2,flask,pyjnius', - 'packagename': 'p4a_test_flask', - 'bootstrap': 'webview', - 'ndk_dir': ndk_dir, - 'ndk_version': ndk_version}, - ] - - -@pytest.mark.parametrize('args', argument_combinations) -def test_build_sdl2(args): - - Recipe.recipes = {} - - set_argv(('apk --requirements={requirements} --private ' - '{app_dir} --package=net.p4a.{packagename} --name={packagename} ' - '--version=0.1 --bootstrap={bootstrap} --android_api=19 ' - '--ndk_dir={ndk_dir} --ndk_version={ndk_version} --debug ' - '--permission VIBRATE ' - '--symlink-java-src ' - '--orientation portrait --dist_name=test-{packagename}').format( - **args).split(' ')) - - print('argv are', sys.argv) - - main() - diff --git a/testapps/testlauncher_setup/pygame.py b/testapps/testlauncher_setup/pygame.py deleted file mode 100644 index e2d32449fa..0000000000 --- a/testapps/testlauncher_setup/pygame.py +++ /dev/null @@ -1,30 +0,0 @@ -from distutils.core import setup -from setuptools import find_packages - -options = {'apk': {'debug': None, - 'bootstrap': 'pygame', - 'launcher': None, - 'requirements': ( - 'python2,pygame,' - 'sqlite3,docutils,pygments,kivy,pyjnius,plyer,' - 'audiostream,cymunk,lxml,pil,' # ffmpeg, openssl - 'twisted,numpy'), # pyopenssl - 'android-api': 14, - 'dist-name': 'launchertest_pygame', - 'name': 'TestLauncher-pygame', - 'package': 'org.kivy.testlauncher_pygame', - 'permissions': [ - 'ACCESS_COARSE_LOCATION', 'ACCESS_FINE_LOCATION', - 'BLUETOOTH', 'BODY_SENSORS', 'CAMERA', 'INTERNET', - 'NFC', 'READ_EXTERNAL_STORAGE', 'RECORD_AUDIO', - 'USE_FINGERPRINT', 'VIBRATE', 'WAKE_LOCK', - 'WRITE_EXTERNAL_STORAGE'] - }} - -setup( - name='testlauncher_pygame', - version='1.0', - description='p4a pygame.py apk', - author='Peter Badida', - options=options -)