Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 13 additions & 11 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
skip_branch_with_pr: true

environment:
FLUTTER_VERSION: 3.24.5
GITHUB_TOKEN:
secure: 9SKIwc3VSfYJ5IChvNR74mEv2nb0ZFftUzn3sGRdXipXEfKSxY50DoodChHvlqZduQNhjg0oyLWAAa3n+iwWvVM2yI7Cgb14lFNClijz/kHI/PibnjDMNvLKaAygcfAc

Expand Down Expand Up @@ -51,9 +52,9 @@ for:

install:
- HOMEBREW_NO_AUTO_UPDATE=1 brew install cocoapods
- flutter upgrade
- source ci/install_flutter.sh
- flutter config --enable-macos-desktop
- flutter doctor
- flutter doctor -v

build: off

Expand All @@ -72,16 +73,14 @@ for:

install:
- HOMEBREW_NO_AUTO_UPDATE=1 brew install cocoapods
- flutter upgrade
- flutter config --enable-macos-desktop
- source ci/install_flutter.sh
# - xcrun simctl list runtimes
# - xcrun simctl create "e2e test" "iPhone 12" "com.apple.CoreSimulator.SimRuntime.iOS-17-2"
# - xcrun xctrace list devices
# - |
# UDID=$(xcrun xctrace list devices | grep "^e2e test Simulator (17.2)" | awk '{gsub(/[()]/,""); print $NF}')
# echo $UDID
# xcrun simctl boot "${UDID:?No Simulator with this name found}"
#- flutter doctor -v

build: off

Expand Down Expand Up @@ -117,8 +116,7 @@ for:
- sudo chown $USER /dev/kvm
- emulator -avd "${DEVICE_NAME}" -memory 2048 -wipe-data -no-boot-anim -cache-size 1000 -noaudio -no-window -partition-size 8192 &
- adb wait-for-device shell 'while [[ -z $(getprop dev.bootcomplete) ]]; do sleep 1; done;'
- flutter upgrade --force
- flutter doctor -v
- source ci/install_flutter.sh

build: off

Expand All @@ -141,7 +139,12 @@ for:
# VC_REDIST_DIR: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT'

install:
- flutter upgrade --force
- dart pub global activate fvm
- set PATH=%LOCALAPPDATA%\Pub\Cache\bin;%USERPROFILE%\fvm\default\bin;%PATH%
- fvm install %FLUTTER_VERSION%
- fvm global %FLUTTER_VERSION%
- flutter --version
- flutter doctor

build: off

Expand All @@ -161,7 +164,7 @@ for:
install:
- sudo apt update --allow-releaseinfo-change
- sudo apt install -y xvfb libgtk-3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
- flutter upgrade --force
- source ci/install_flutter.sh

build: off

Expand All @@ -185,8 +188,7 @@ for:
- sudo apt install -y clang ninja-build xvfb libgtk-3-dev gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav
- git clone https://github.com/flutter/flutter.git -b stable "$HOME/flutter"
- export PATH="$PATH:$HOME/flutter/bin"
- flutter upgrade
- flutter doctor
- source ci/install_flutter.sh

build: off

Expand Down
6 changes: 6 additions & 0 deletions ci/install_flutter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dart pub global activate fvm
export PATH=$HOME/.pub-cache/bin:$HOME/fvm/default/bin:$PATH
fvm install $FLUTTER_VERSION
fvm global $FLUTTER_VERSION
flutter --version
flutter doctor
4 changes: 4 additions & 0 deletions src/serious_python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.5

* Added Java `loadLibrary` to Android plugin to support `pyjnius` ([#128](https://github.com/flet-dev/serious-python/issues/128)).

## 0.8.4

* Copy `site-packages/flutter` contents to `SERIOUS_PYTHON_FLUTTER_PACKAGES`.
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python/example/flet_example/app/app.zip.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cc3d88a7793723d9bdec03813d7a47d758276bef6e78107138fd0acb7d386fca
43f8a7b00e44a09647dda36299259976950ba7259c5060de20677c449690fc73
12 changes: 6 additions & 6 deletions src/serious_python/example/flet_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -482,42 +482,42 @@ packages:
path: "../.."
relative: true
source: path
version: "0.8.2"
version: "0.8.4"
serious_python_android:
dependency: transitive
description:
path: "../../../serious_python_android"
relative: true
source: path
version: "0.8.2"
version: "0.8.4"
serious_python_darwin:
dependency: transitive
description:
path: "../../../serious_python_darwin"
relative: true
source: path
version: "0.8.2"
version: "0.8.4"
serious_python_linux:
dependency: transitive
description:
path: "../../../serious_python_linux"
relative: true
source: path
version: "0.8.2"
version: "0.8.4"
serious_python_platform_interface:
dependency: transitive
description:
path: "../../../serious_python_platform_interface"
relative: true
source: path
version: "0.8.2"
version: "0.8.4"
serious_python_windows:
dependency: transitive
description:
path: "../../../serious_python_windows"
relative: true
source: path
version: "0.8.2"
version: "0.8.4"
shared_preferences:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python/example/run_example/app/app.zip.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
86fcefd284f101b084bfb8b72d9eebe97d65c880b1dc97a9b8719ed40c4a3e24
081229a0c5551f4c29faa2b6e8a23cba9e971d66f95565892561898e146a5d5e
36 changes: 33 additions & 3 deletions src/serious_python/example/run_example/app/src/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
print("Hello from Python program!")

import _imp
import os
from pathlib import Path
from time import sleep

import _imp

_imp.extension_suffixes()

print("HELLO!")
Expand Down Expand Up @@ -94,12 +95,14 @@ def test_sqlite():
out_dir = Path(result_filename).parent
conn = sqlite3.connect(str(out_dir.joinpath("mydb.db")))

conn.execute("""CREATE TABLE COMPANY
conn.execute(
"""CREATE TABLE COMPANY
(ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL);""")
SALARY REAL);"""
)

conn.execute(
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) \
Expand Down Expand Up @@ -131,7 +134,34 @@ def test_sqlite():
return f"\nsqlite: test_basic - error: {e}"


def test_pyjnius():
from time import sleep

from jnius import autoclass

activity = autoclass(os.getenv("MAIN_ACTIVITY_HOST_CLASS_NAME")).mActivity
Secure = autoclass("android.provider.Settings$Secure")

version = autoclass("android.os.Build$VERSION")
os_build = autoclass("android.os.Build")
base_os = version.BASE_OS

DisplayMetrics = autoclass("android.util.DisplayMetrics")
metrics = DisplayMetrics()

return (
str(activity.getClass().getName())
+ " os: "
+ str(os_build)
+ " FLET_JNI_READY: "
+ str(os.getenv("FLET_JNI_READY"))
+ " DPI: "
+ str(metrics.getDeviceDensity())
)


r += test_sqlite()
r += test_pyjnius()
# test_lru()
# test_numpy_basic()
# test_numpy_performance()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#numpy
lru-dict
lru-dict
pyjnius
2 changes: 1 addition & 1 deletion src/serious_python/example/run_example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class _MyAppState extends State<MyApp> {
title: const Text('Serious Python example app'),
),
body: Center(
child: Text(_pyResult),
child: SelectableText(_pyResult),
),
),
);
Expand Down
12 changes: 6 additions & 6 deletions src/serious_python/example/run_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -296,42 +296,42 @@ packages:
path: "../.."
relative: true
source: path
version: "0.8.1"
version: "0.8.4"
serious_python_android:
dependency: transitive
description:
path: "../../../serious_python_android"
relative: true
source: path
version: "0.8.1"
version: "0.8.4"
serious_python_darwin:
dependency: transitive
description:
path: "../../../serious_python_darwin"
relative: true
source: path
version: "0.8.1"
version: "0.8.4"
serious_python_linux:
dependency: transitive
description:
path: "../../../serious_python_linux"
relative: true
source: path
version: "0.8.1"
version: "0.8.4"
serious_python_platform_interface:
dependency: transitive
description:
path: "../../../serious_python_platform_interface"
relative: true
source: path
version: "0.8.1"
version: "0.8.4"
serious_python_windows:
dependency: transitive
description:
path: "../../../serious_python_windows"
relative: true
source: path
version: "0.8.1"
version: "0.8.4"
shelf:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: serious_python
description: A cross-platform plugin for adding embedded Python runtime to your Flutter apps.
homepage: https://flet.dev
repository: https://github.com/flet-dev/serious-python
version: 0.8.4
version: 0.8.5

platforms:
ios:
Expand Down
4 changes: 4 additions & 0 deletions src/serious_python_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.5

* Added Java `loadLibrary` to Android plugin to support `pyjnius` ([#128](https://github.com/flet-dev/serious-python/issues/128)).

## 0.8.4

* Copy `site-packages/flutter` contents to `SERIOUS_PYTHON_FLUTTER_PACKAGES`.
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python_android/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.flet.serious_python_android'
version '0.8.4'
version '0.8.5'

def python_version = '3.12'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package com.flet.serious_python_android;

import java.lang.*;
import android.content.Context;
import android.content.ContextWrapper;
import androidx.annotation.NonNull;
import android.system.Os;
import android.content.Intent;
import android.app.Activity;

import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;

/** AndroidPlugin */
public class AndroidPlugin implements FlutterPlugin, MethodCallHandler {
public class AndroidPlugin implements FlutterPlugin, MethodCallHandler, ActivityAware {

public static final String MAIN_ACTIVITY_HOST_CLASS_NAME = "MAIN_ACTIVITY_HOST_CLASS_NAME";
public static Activity mActivity = null;

/// The MethodChannel that will the communication between Flutter and native
/// Android
///
Expand All @@ -30,6 +38,16 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
this.context = flutterPluginBinding.getApplicationContext();
}

@Override
public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) {
mActivity = activityPluginBinding.getActivity();
try {
Os.setenv(MAIN_ACTIVITY_HOST_CLASS_NAME, this.getClass().getCanonicalName(), true);
} catch (Exception e) {
// nothing to do
}
}

@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
if (call.method.equals("getPlatformVersion")) {
Expand All @@ -38,6 +56,13 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
ContextWrapper contextWrapper = new ContextWrapper(context);
String nativeLibraryDir = contextWrapper.getApplicationInfo().nativeLibraryDir;
result.success(nativeLibraryDir);
} else if (call.method.equals("loadLibrary")) {
try {
System.loadLibrary(call.argument("libname"));
result.success(null);
} catch (Throwable e) {
result.error("Error", e.getMessage(), null);
}
} else if (call.method.equals("setEnvironmentVariable")) {
String name = call.argument("name");
String value = call.argument("value");
Expand All @@ -56,4 +81,14 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
}

@Override
public void onDetachedFromActivity() {}

@Override
public void onDetachedFromActivityForConfigChanges() {}

@Override
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {}

}
Loading