@@ -8,6 +8,7 @@ import 'package:path/path.dart' as p;
88import 'package:serious_python_platform_interface/serious_python_platform_interface.dart' ;
99
1010import 'src/cpython.dart' ;
11+ import 'src/log.dart' ;
1112
1213/// An implementation of [SeriousPythonPlatform] that uses method channels.
1314class SeriousPythonAndroid extends SeriousPythonPlatform {
@@ -33,24 +34,23 @@ class SeriousPythonAndroid extends SeriousPythonPlatform {
3334 List <String >? modulePaths,
3435 Map <String , String >? environmentVariables,
3536 bool ? sync }) async {
36- Future setenv (String key, String value) async {
37- await methodChannel.invokeMethod <String >(
38- 'setEnvironmentVariable' , {'name' : key, 'value' : value});
39- }
37+ Future <void > setenv (String key, String value) =>
38+ methodChannel.invokeMethod <String >(
39+ 'setEnvironmentVariable' , {'name' : key, 'value' : value});
4040
4141 // load libpyjni.so to get JNI reference
4242 try {
4343 await methodChannel
4444 .invokeMethod <String >('loadLibrary' , {'libname' : 'pyjni' });
4545 await setenv ("FLET_JNI_READY" , "1" );
4646 } catch (e) {
47- debugPrint ( "Warning: Unable to load libpyjni.so library: $e " );
47+ spDebug ( " Unable to load libpyjni.so library: $e " );
4848 }
4949
5050 // unpack python bundle
5151 final nativeLibraryDir =
5252 await methodChannel.invokeMethod <String >('getNativeLibraryDir' );
53- debugPrint ("getNativeLibraryDir: $nativeLibraryDir " );
53+ spDebug ("getNativeLibraryDir: $nativeLibraryDir " );
5454
5555 var bundlePath = "$nativeLibraryDir /libpythonbundle.so" ;
5656 var sitePackagesZipPath = "$nativeLibraryDir /libpythonsitepackages.so" ;
@@ -60,7 +60,7 @@ class SeriousPythonAndroid extends SeriousPythonPlatform {
6060 }
6161 var pythonLibPath =
6262 await extractFileZip (bundlePath, targetPath: "python_bundle" );
63- debugPrint ("pythonLibPath: $pythonLibPath " );
63+ spDebug ("pythonLibPath: $pythonLibPath " );
6464
6565 var programDirPath = p.dirname (appPath);
6666
@@ -74,22 +74,22 @@ class SeriousPythonAndroid extends SeriousPythonPlatform {
7474 if (await File (sitePackagesZipPath).exists ()) {
7575 var sitePackagesPath = await extractFileZip (sitePackagesZipPath,
7676 targetPath: "python_site_packages" );
77- debugPrint ("sitePackagesPath: $sitePackagesPath " );
77+ spDebug ("sitePackagesPath: $sitePackagesPath " );
7878 moduleSearchPaths.add (sitePackagesPath);
7979 }
8080
81- setenv ("PYTHONINSPECT" , "1" );
82- setenv ("PYTHONDONTWRITEBYTECODE" , "1" );
83- setenv ("PYTHONNOUSERSITE" , "1" );
84- setenv ("PYTHONUNBUFFERED" , "1" );
85- setenv ("LC_CTYPE" , "UTF-8" );
86- setenv ("PYTHONHOME" , pythonLibPath);
87- setenv ("PYTHONPATH" , moduleSearchPaths.join (":" ));
81+ await setenv ("PYTHONINSPECT" , "1" );
82+ await setenv ("PYTHONDONTWRITEBYTECODE" , "1" );
83+ await setenv ("PYTHONNOUSERSITE" , "1" );
84+ await setenv ("PYTHONUNBUFFERED" , "1" );
85+ await setenv ("LC_CTYPE" , "UTF-8" );
86+ await setenv ("PYTHONHOME" , pythonLibPath);
87+ await setenv ("PYTHONPATH" , moduleSearchPaths.join (":" ));
8888
8989 // set environment variables
9090 if (environmentVariables != null ) {
9191 for (var v in environmentVariables.entries) {
92- setenv (v.key, v.value);
92+ await setenv (v.key, v.value);
9393 }
9494 }
9595
0 commit comments