Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
38ba1ad
Fixes python build with macOS venv
AndreMiras Apr 28, 2020
83dc122
Merge pull request #2159 from AndreMiras/feature/fix_macos_venv_build
AndreMiras Apr 29, 2020
36825d7
Get --add-source working for dirs in Gradle builds (#2156)
kollivier Apr 29, 2020
4b6e095
Adding more assets (#2132)
robertpfeiffer Apr 29, 2020
3bdeaca
Removed python2 support mention from README (#2162)
inclement Apr 29, 2020
9dded87
Adds pygame recipe
Oct 28, 2019
d5c672e
Adds macOS install instructions
AndreMiras May 1, 2020
36426f4
Merge pull request #2165 from AndreMiras/feature/documentation_update
AndreMiras May 1, 2020
66f6a34
Merge pull request #2164 from AndreMiras/feature/pygame_recipe
AndreMiras May 1, 2020
1b887be
Bump to SDL2 2.0.10 & extract .java from SDL2 tarball: merge conflict…
inclement May 1, 2020
b6a35e9
Merge pull request #2175 from kivy/release-2020.04.29
inclement May 7, 2020
581c4b4
Narrows some context manager scopes
AndreMiras May 8, 2020
04b8f35
Downgrades to SDL2 2.0.9
AndreMiras May 8, 2020
2808130
Merge pull request #2180 from AndreMiras/feature/downgrade_sdl2_2.0.9
AndreMiras May 8, 2020
eaf4c2f
Post release version bump 2020.04.29.dev0 (#2176)
AndreMiras May 8, 2020
f96356b
Merge pull request #2179 from AndreMiras/feature/narrow_context_manager
AndreMiras May 9, 2020
afa99bb
Updates release documentation
AndreMiras May 7, 2020
c0d3015
Fixes service only unittest loading
AndreMiras May 9, 2020
4fbcefd
Reuse common AssetExtract.java
AndreMiras May 9, 2020
f29262a
Merge pull request #2181 from AndreMiras/feature/service_only_unittes…
AndreMiras May 9, 2020
f3e9222
Merge pull request #2177 from AndreMiras/feature/release_documentatio…
AndreMiras May 9, 2020
c03f0ff
Use common Hardware.java
AndreMiras May 9, 2020
a3b18f1
Moves kamranzafar/ java directory to common/
AndreMiras May 9, 2020
a0b878d
Removes java concurrency/ folder
AndreMiras May 9, 2020
f00d00b
Merge pull request #2184 from AndreMiras/feature/common_kamranzafar_java
AndreMiras May 9, 2020
de7d06a
Merge pull request #2183 from AndreMiras/feature/common_hardware_java
AndreMiras May 9, 2020
9f9a42f
Merge pull request #2182 from AndreMiras/feature/share_asset_extract
AndreMiras May 9, 2020
2604406
Merge pull request #2185 from AndreMiras/feature/delete_unused_java_c…
AndreMiras May 9, 2020
54c9b62
Deletes deprecated renpy Python{Activity,Service}.java
AndreMiras May 9, 2020
d0deae0
Java code linting using PMD 6.23.0
AndreMiras May 10, 2020
0730f6c
Merge pull request #2186 from AndreMiras/feature/removes_deprecated_r…
AndreMiras May 10, 2020
7b27577
Merge pull request #2187 from AndreMiras/feature/java_code_cleaning
AndreMiras May 10, 2020
53722ed
Share PythonUtil.java between bootstraps
AndreMiras May 10, 2020
eeed13c
Merge pull request #2188 from AndreMiras/feature/share_java_python_util
AndreMiras May 10, 2020
0de6aca
Fix for 'cannot find setuptools module'
frederic-simard May 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
# installs java 1.8, android's SDK/NDK and p4a
- make -f ci/makefiles/osx.mk
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
script: make testapps-no-venv/armeabi-v7a
script: make testapps/armeabi-v7a
- <<: *testapps
name: Rebuild updated recipes
script: travis_wait 30 make docker/run/make/rebuild_updated_recipes
Expand Down
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ testapps/%: virtualenv
python setup.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--arch=$($@_APP_ARCH)

testapps-no-venv/%:
pip3 install Cython==0.28.6
pip3 install -e .
$(eval $@_APP_ARCH := $(shell basename $*))
cd testapps/on_device_unit_tests/ && \
python3 setup.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--arch=$($@_APP_ARCH)

clean:
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type d -name "*.egg-info" -exec rm -r {} +
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies you want, and bundle it in an APK along with your own code.

Features include:

- Support for building with both Python 2 and Python 3.
- Different app backends including Kivy, PySDL2, and a WebView with
Python webserver.
- Automatic support for most pure Python modules, and built in support
Expand Down
25 changes: 14 additions & 11 deletions doc/source/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ At this point, wait for reviewer approval and conclude any discussion that arise
- Merge the release branch to the ``master`` branch.
- Also merge the release branch to the ``develop`` branch.
- Tag the release commit in ``master``, with tag ``vYYYY.MM.DD``. Include a short summary of the changes.
- Create the release distributions: ``python3 setup.py sdist bdist_wheel``
- Upload the release to pypi: ``python3 -m twine upload``.
- Release distributions and PyPI upload should be `handled by the CI
<https://github.com/kivy/python-for-android/blob/v2020.04.29/.travis.yml#L60-L70>`_.
- Add to the Github release page (see e.g. `this example <https://github.com/kivy/python-for-android/releases/tag/v2019.06.06>`__):
- The python-for-android README summary
- A short list of major changes in this release, if any
Expand All @@ -67,15 +67,18 @@ At this point, wait for reviewer approval and conclude any discussion that arise

Release checklist
~~~~~~~~~~~~~~~~~

- [ ] Check that the [build is passing](https://travis-ci.org/kivy/python-for-android)
- [ ] Run the tests locally via `tox`: this performs some long-running tests that are skipped on Travis.
- [ ] Build and run the [on_device_unit_tests](https://github.com/kivy/python-for-android/tree/master/testapps/on_device_unit_tests) app using buildozer. Check that they all pass.
- [ ] Build and run the following [testapps](https://github.com/kivy/python-for-android/tree/master/testapps) for arch `armeabi-v7a` and `arm64-v8a`:
- `python3 setup_testapp_python3_sqlite_openssl.py apk`
- [ ] `armeabi-v7a`
- [ ] `arm64-v8a`
- [ ] Check that the version number is correct
::

- [ ] Check that the builds are passing
- [ ] [Travis build](https://travis-ci.org/kivy/python-for-android)
- [ ] [GitHub Action](https://github.com/kivy/python-for-android/actions)
- [ ] Run the tests locally via `tox`: this performs some long-running tests that are skipped on Travis.
- [ ] Build and run the [on_device_unit_tests](https://github.com/kivy/python-for-android/tree/master/testapps/on_device_unit_tests) app using buildozer. Check that they all pass.
- [ ] Build (or download from github actions) and run the following [testapps](https://github.com/kivy/python-for-android/tree/master/testapps/on_device_unit_tests) for arch `armeabi-v7a` and `arm64-v8a`:
- [ ] on_device_unit_tests
- [ ] `armeabi-v7a` (`cd testapps/on_device_unit_tests && PYTHONPATH=.:../../ python3 setup.py apk --ndk-dir=<your-ndk-dir> --sdk-dir=<your-sdk-dir> --arch=armeabi-v7a --debug`)
- [ ] `arm64-v8a` (`cd testapps/on_device_unit_tests && PYTHONPATH=.:../../ python3 setup.py apk --ndk-dir=<your-ndk-dir> --sdk-dir=<your-sdk-dir> --arch=arm64-v8a --debug`)
- [ ] Check that the version number is correct



Expand Down
9 changes: 9 additions & 0 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ complete)::

sudo pacman -S core/autoconf core/automake core/gcc core/make core/patch core/pkgconf extra/cmake extra/jdk8-openjdk extra/python-pip extra/unzip extra/zip

On macOS::

brew cask install autoconf automake java8 libtool pkg-config

If Java 8 is no longer available you can still install it via::

brew tap homebrew/cask-versions
brew cask install homebrew/cask-versions/adoptopenjdk8

Installing Android SDK
~~~~~~~~~~~~~~~~~~~~~~

Expand Down
17 changes: 11 additions & 6 deletions doc/source/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ On Ubuntu fix it my making sure only the :code:`openjdk-8-jdk` package is instal
In the similar fashion for macOS you need to install the :code:`java8` package::

brew cask install java8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home


Error: Cask 'java8' is unavailable: No Cask with this name exists
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In order to install Java 8 on macOS you may need extra steps::

brew tap homebrew/cask-versions
brew cask install homebrew/cask-versions/adoptopenjdk8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home


JNI DETECTED ERROR IN APPLICATION: static jfieldID 0x0000000 not valid for class java.lang.Class<org.renpy.android.PythonActivity>
Expand All @@ -173,12 +184,6 @@ This error appears in the logcat log if you try to access
fix it, change your code to reference
``org.kivy.android.PythonActivity`` instead.

websocket-client: if you see errors relating to 'SSL not available'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ensure you have the package backports.ssl-match-hostname in the buildozer requirements, since Kivy targets python 2.7.x

You may also need sslopt={"cert_reqs": ssl.CERT_NONE} as a parameter to ws.run_forever() if you get an error relating to host verification

Requested API target 19 is not available, install it with the SDK android tool
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2020.04.29'
__version__ = '2020.04.29.dev0'
27 changes: 23 additions & 4 deletions pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ def get_build_dir(self):
def get_dist_dir(self, name):
return join(self.ctx.dist_dir, name)

def get_common_dir(self):
return os.path.abspath(join(self.bootstrap_dir, "..", 'common'))

@property
def name(self):
modname = self.__class__.__module__
Expand All @@ -152,6 +149,23 @@ def get_bootstrap_dirs(self):
]
return bootstrap_dirs

def _copy_in_final_files(self):
if self.name == "sdl2":
# Get the paths for copying SDL2's java source code:
sdl2_recipe = Recipe.get_recipe("sdl2", self.ctx)
sdl2_build_dir = sdl2_recipe.get_jni_dir()
src_dir = join(sdl2_build_dir, "SDL", "android-project",
"app", "src", "main", "java",
"org", "libsdl", "app")
target_dir = join(self.dist_dir, 'src', 'main', 'java', 'org',
'libsdl', 'app')

# Do actual copying:
info('Copying in SDL2 .java files from: ' + str(src_dir))
if not os.path.exists(target_dir):
os.makedirs(target_dir)
copy_files(src_dir, target_dir, override=True)

def prepare_build_dir(self):
"""Ensure that a build dir exists for the recipe. This same single
dir will be used for building all different archs."""
Expand All @@ -168,7 +182,12 @@ def prepare_build_dir(self):
def prepare_dist_dir(self):
ensure_dir(self.dist_dir)

def run_distribute(self):
def assemble_distribution(self):
''' Copies all the files into the distribution (this function is
overridden by the specific bootstrap classes to do this)
and add in the distribution info.
'''
self._copy_in_final_files()
self.distribution.save_info(self.dist_dir)

@classmethod
Expand Down
54 changes: 34 additions & 20 deletions pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ def get_bootstrap_name():
join(curdir, 'templates')))


def try_unlink(fn):
if exists(fn):
os.unlink(fn)


def ensure_dir(path):
if not exists(path):
makedirs(path)
Expand Down Expand Up @@ -239,8 +234,7 @@ def make_package(args):
assets_dir = "src/main/assets"

# Delete the old assets.
try_unlink(join(assets_dir, 'public.mp3'))
try_unlink(join(assets_dir, 'private.mp3'))
shutil.rmtree(assets_dir, ignore_errors=True)
ensure_dir(assets_dir)

# Add extra environment variable file into tar-able directory:
Expand Down Expand Up @@ -304,6 +298,15 @@ def make_package(args):
tar_dirs.append(python_bundle_dir)
if get_bootstrap_name() == "webview":
tar_dirs.append('webview_includes')

for asset in args.assets:
asset_src, asset_dest = asset.split(":")
if isfile(realpath(asset_src)):
ensure_dir(dirname(join(assets_dir, asset_dest)))
shutil.copy(realpath(asset_src), join(assets_dir, asset_dest))
else:
shutil.copytree(realpath(asset_src), join(assets_dir, asset_dest))

if args.private or args.launcher:
make_tar(
join(assets_dir, 'private.mp3'), tar_dirs, args.ignore_path,
Expand Down Expand Up @@ -380,6 +383,9 @@ def make_package(args):
for spec in args.extra_source_dirs:
if ':' in spec:
specdir, specincludes = spec.split(':')
print('WARNING: Currently gradle builds only support including source '
'directories, so when building using gradle all files in '
'{} will be included.'.format(specdir))
else:
specdir = spec
specincludes = '**'
Expand Down Expand Up @@ -524,24 +530,28 @@ def make_package(args):
for patch_name in os.listdir(join('src', 'patches')):
patch_path = join('src', 'patches', patch_name)
print("Applying patch: " + str(patch_path))

# -N: insist this is FORWARD patch, don't reverse apply
# -p1: strip first path component
# -t: batch mode, don't ask questions
patch_command = ["patch", "-N", "-p1", "-t", "-i", patch_path]

try:
subprocess.check_output([
# -N: insist this is FORWARd patch, don't reverse apply
# -p1: strip first path component
# -t: batch mode, don't ask questions
"patch", "-N", "-p1", "-t", "-i", patch_path
])
# Use a dry run to establish whether the patch is already applied.
# If we don't check this, the patch may be partially applied (which is bad!)
subprocess.check_output(patch_command + ["--dry-run"])
except subprocess.CalledProcessError as e:
if e.returncode == 1:
# Return code 1 means it didn't apply, this will
# usually mean it is already applied.
print("Warning: failed to apply patch (" +
"exit code 1), " +
"assuming it is already applied: " +
str(patch_path)
)
# Return code 1 means not all hunks could be applied, this usually
# means the patch is already applied.
print("Warning: failed to apply patch (exit code 1), "
"assuming it is already applied: ",
str(patch_path))
else:
raise e
else:
# The dry run worked, so do the real thing
subprocess.check_output(patch_command)


def parse_args_and_make_package(args=None):
Expand Down Expand Up @@ -599,6 +609,10 @@ def parse_args_and_make_package(args=None):
help='Custom key=value to add in application metadata')
ap.add_argument('--uses-library', dest='android_used_libs', action='append', default=[],
help='Used shared libraries included using <uses-library> tag in AndroidManifest.xml')
ap.add_argument('--asset', dest='assets',
action="append", default=[],
metavar="/path/to/source:dest",
help='Put this in the assets folder at assets/dest')
ap.add_argument('--icon', dest='icon',
help=('A png file to use as the icon for '
'the application.'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import org.kivy.android.PythonUtil;

import org.renpy.android.Hardware;

//imports for channel definition
import android.app.NotificationManager;
import android.app.NotificationChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import android.util.Log;
import java.util.ArrayList;
import java.io.FilenameFilter;
import java.util.regex.Pattern;


Expand Down Expand Up @@ -34,8 +33,13 @@ protected static ArrayList<String> getLibraries(File libsDir) {
ArrayList<String> libsList = new ArrayList<String>();
addLibraryIfExists(libsList, "sqlite3", libsDir);
addLibraryIfExists(libsList, "ffi", libsDir);
addLibraryIfExists(libsList, "png16", libsDir);
addLibraryIfExists(libsList, "ssl.*", libsDir);
addLibraryIfExists(libsList, "crypto.*", libsDir);
addLibraryIfExists(libsList, "SDL2", libsDir);
addLibraryIfExists(libsList, "SDL2_image", libsDir);
addLibraryIfExists(libsList, "SDL2_mixer", libsDir);
addLibraryIfExists(libsList, "SDL2_ttf", libsDir);
libsList.add("python3.5m");
libsList.add("python3.6m");
libsList.add("python3.7m");
Expand All @@ -45,7 +49,6 @@ protected static ArrayList<String> getLibraries(File libsDir) {
}

public static void loadLibraries(File filesDir, File libsDir) {
String filesDirPath = filesDir.getAbsolutePath();
boolean foundPython = false;

for (String lib : getLibraries(libsDir)) {
Expand All @@ -61,7 +64,7 @@ public static void loadLibraries(File filesDir, File libsDir) {
// general error
Log.v(TAG, "Library loading error: " + e.getMessage());
if (lib.startsWith("python3.8") && !foundPython) {
throw new java.lang.RuntimeException("Could not load any libpythonXXX.so");
throw new RuntimeException("Could not load any libpythonXXX.so");
} else if (lib.startsWith("python")) {
continue;
} else {
Expand All @@ -72,5 +75,5 @@ public static void loadLibraries(File filesDir, File libsDir) {
}

Log.v(TAG, "Loaded everything!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,30 @@
// spaces amount
package org.renpy.android;

import java.io.*;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.File;

import java.util.zip.GZIPInputStream;

import android.content.res.AssetManager;

import org.kamranzafar.jtar.*;
import org.kamranzafar.jtar.TarEntry;
import org.kamranzafar.jtar.TarInputStream;

public class AssetExtract {

private AssetManager mAssetManager = null;
private Activity mActivity = null;

public AssetExtract(Activity act) {
mActivity = act;
mAssetManager = act.getAssets();
public AssetExtract(Context context) {
mAssetManager = context.getAssets();
}

public boolean extractTar(String asset, String target) {
Expand All @@ -51,7 +48,7 @@ public boolean extractTar(String asset, String target) {

try {
entry = tis.getNextEntry();
} catch ( java.io.IOException e ) {
} catch ( IOException e ) {
Log.e("python", "extracting tar", e);
return false;
}
Expand Down Expand Up @@ -97,7 +94,7 @@ public boolean extractTar(String asset, String target) {

out.flush();
out.close();
} catch ( java.io.IOException e ) {
} catch ( IOException e ) {
Log.e("python", "extracting zip", e);
return false;
}
Expand Down
Loading