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
6 changes: 6 additions & 0 deletions src/serious_python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.8.8

* Set `MinimumOSVersion` to `13.0` for generated Python frameworks.
* Pyodide 0.27.2
* Python 3.12.9

## 0.8.7

* Fixed: `xcframeworks` migration script didn't work for sub-directories.
Expand Down
66 changes: 61 additions & 5 deletions src/serious_python/bin/package_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import 'macos_utils.dart' as macos_utils;
import 'sitecustomize.dart';

const mobilePyPiUrl = "https://pypi.flet.dev";
const pyodideRootUrl = "https://cdn.jsdelivr.net/pyodide/v0.26.2/full";
const pyodideRootUrl = "https://cdn.jsdelivr.net/pyodide/v0.27.2/full";
const pyodideLockFile = "pyodide-lock.json";

const buildPythonVersion = "3.12.6";
const buildPythonReleaseDate = "20240909";
const buildPythonVersion = "3.12.9";
const buildPythonReleaseDate = "20250205";
const defaultSitePackagesDir = "__pypackages__";
const sitePackagesEnvironmentVariable = "SERIOUS_PYTHON_SITE_PACKAGES";
const flutterPackagesFlutterEnvironmentVariable =
Expand Down Expand Up @@ -507,7 +507,7 @@ class PackageCommand extends Command {
if (!await File(pythonArchivePath).exists()) {
// download Python distr from GitHub
final url =
"https://github.com/indygreg/python-build-standalone/releases/download/$buildPythonReleaseDate/$pythonArchiveFilename";
"https://github.com/astral-sh/python-build-standalone/releases/download/$buildPythonReleaseDate/$pythonArchiveFilename";

if (_verbose) {
verbose(
Expand All @@ -523,13 +523,18 @@ class PackageCommand extends Command {

// extract Python from archive
if (_verbose) {
"Extracting Python distributive from $pythonArchivePath to ${_pythonDir!.path}";
verbose(
"Extracting Python distributive from $pythonArchivePath to ${_pythonDir!.path}");
} else {
stdout.writeln("Extracting Python distributive");
}

await Process.run(
'tar', ['-xzf', pythonArchivePath, '-C', _pythonDir!.path]);

if (Platform.isMacOS) {
copySysconfigFiles(_pythonDir!.path);
}
}
}

Expand All @@ -542,6 +547,57 @@ class PackageCommand extends Command {
return await runExec(pythonExePath, args, environment: environment);
}

void copySysconfigFiles(String pythonDir) {
final libPath = Directory(path.join(pythonDir, "python", "lib"));

// Find the Python version dynamically (e.g., python3.10, python3.11)
if (!libPath.existsSync()) {
stderr.writeln('Python lib directory not found: $libPath');
exit(1);
}

// Find the actual Python 3.x subdirectory
final pythonSubDir = libPath
.listSync()
.whereType<Directory>()
.firstWhere((dir) => RegExp(r'python3\.\d+').hasMatch(dir.path),
orElse: () => throw Exception('No Python 3.x directory found'))
.path;

final targetDir = Directory(pythonSubDir);

// Search for `_sysconfigdata__*.py` files
final files = targetDir
.listSync()
.whereType<File>()
.where((file) => RegExp(r'_sysconfigdata__.*\.py$').hasMatch(file.path))
.toList();

if (files.isEmpty) {
stderr.writeln('No matching _sysconfigdata__ files found in $targetDir');
exit(1);
}

for (final file in files) {
final dir = file.parent.path;

// Define the new filenames
final targets = [
'_sysconfigdata__darwin_arm64_iphoneos.py',
'_sysconfigdata__darwin_arm64_iphonesimulator.py',
'_sysconfigdata__darwin_x86_64_iphonesimulator.py',
];

for (final target in targets) {
final targetPath = '$dir/$target';
file.copySync(targetPath);
if (_verbose) {
verbose('Copied ${file.path} -> $targetPath');
}
}
}
}

Future<HttpServer> startSimpleServer() async {
const htmlHeader = "<!DOCTYPE html><html><body>\n";
const htmlFooter = "</body></html>\n";
Expand Down
16 changes: 16 additions & 0 deletions src/serious_python/bin/sitecustomize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ custom_system = "{platform}"
custom_platform = "{tag}"
custom_mac_ver = "{mac_ver}"

import collections
import platform
import sysconfig
import sys

if custom_system:
platform.system = lambda: custom_system
Expand All @@ -24,6 +26,20 @@ if custom_mac_ver:

platform.mac_ver = custom_mac_ver_impl

if custom_system == "iOS":
IOSVersionInfo = collections.namedtuple(
"IOSVersionInfo",
["system", "release", "model", "is_simulator"]
)

tag_parts = custom_platform.split("-")

def custom_ios_ver(system="", release="", model="", is_simulator=False):
return IOSVersionInfo(custom_system, tag_parts[1], "iPhone", "simulator" in tag_parts[3])

platform.ios_ver = custom_ios_ver

sys.implementation._multiarch = f"{tag_parts[2]}_{tag_parts[3]}"

orig_platform_version = platform.version
platform.version = lambda: orig_platform_version() + ";embedded"
Expand Down
46 changes: 23 additions & 23 deletions src/serious_python/example/run_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.19.0"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -150,18 +150,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
version: "10.0.7"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
version: "3.0.8"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -296,42 +296,42 @@ packages:
path: "../.."
relative: true
source: path
version: "0.8.6"
version: "0.8.8"
serious_python_android:
dependency: transitive
description:
path: "../../../serious_python_android"
relative: true
source: path
version: "0.8.6"
version: "0.8.8"
serious_python_darwin:
dependency: transitive
description:
path: "../../../serious_python_darwin"
relative: true
source: path
version: "0.8.6"
version: "0.8.8"
serious_python_linux:
dependency: transitive
description:
path: "../../../serious_python_linux"
relative: true
source: path
version: "0.8.6"
version: "0.8.8"
serious_python_platform_interface:
dependency: transitive
description:
path: "../../../serious_python_platform_interface"
relative: true
source: path
version: "0.8.6"
version: "0.8.8"
serious_python_windows:
dependency: transitive
description:
path: "../../../serious_python_windows"
relative: true
source: path
version: "0.8.6"
version: "0.8.8"
shelf:
dependency: transitive
description:
Expand All @@ -344,7 +344,7 @@ packages:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
version: "0.0.0"
source_span:
dependency: transitive
description:
Expand All @@ -357,10 +357,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
version: "1.12.0"
stream_channel:
dependency: transitive
description:
Expand All @@ -373,10 +373,10 @@ packages:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.3.0"
sync_http:
dependency: transitive
description:
Expand All @@ -397,10 +397,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.7.3"
toml:
dependency: transitive
description:
Expand Down Expand Up @@ -429,10 +429,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev"
source: hosted
version: "14.2.5"
version: "14.3.0"
web:
dependency: transitive
description:
Expand All @@ -445,10 +445,10 @@ packages:
dependency: transitive
description:
name: webdriver
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.4"
xdg_directories:
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.7
version: 0.8.8

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

* Set `MinimumOSVersion` to `13.0` for generated Python frameworks.
* Pyodide 0.27.2
* Python 3.12.9

## 0.8.7

* Fixed: `xcframeworks` migration script didn't work for sub-directories.
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.7'
version '0.8.8'

def python_version = '3.12'

Expand Down
2 changes: 1 addition & 1 deletion src/serious_python_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: serious_python_android
description: Android implementation of the serious_python plugin
homepage: https://flet.dev
repository: https://github.com/flet-dev/serious-python
version: 0.8.7
version: 0.8.8

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down
6 changes: 6 additions & 0 deletions src/serious_python_darwin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.8.8

* Set `MinimumOSVersion` to `13.0` for generated Python frameworks.
* Pyodide 0.27.2
* Python 3.12.9

## 0.8.7

* Fixed: `xcframeworks` migration script didn't work for sub-directories.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'serious_python_darwin'
s.version = '0.8.7'
s.version = '0.8.8'
s.summary = 'A cross-platform plugin for adding embedded Python runtime to your Flutter apps.'
s.description = <<-DESC
A cross-platform plugin for adding embedded Python runtime to your Flutter apps.
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python_darwin/darwin/xcframework_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ create_plist() {
<string>iPhoneOS</string>
</array>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python_darwin/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: serious_python_darwin
description: iOS and macOS implementations of the serious_python plugin
homepage: https://flet.dev
repository: https://github.com/flet-dev/serious-python
version: 0.8.7
version: 0.8.8

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down
6 changes: 6 additions & 0 deletions src/serious_python_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.8.8

* Set `MinimumOSVersion` to `13.0` for generated Python frameworks.
* Pyodide 0.27.2
* Python 3.12.9

## 0.8.7

* Fixed: `xcframeworks` migration script didn't work for sub-directories.
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python_linux/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: serious_python_linux
description: Linux implementations of the serious_python plugin
homepage: https://flet.dev
repository: https://github.com/flet-dev/serious-python
version: 0.8.7
version: 0.8.8

environment:
sdk: '>=3.1.3 <4.0.0'
Expand Down
Loading