Skip to content

Commit 792379d

Browse files
Set MinimumOSVersion to 13.0 for generated Python frameworks (#136)
* MinimumOSVersion=13.0 * Version bumped to 0.8.8, changelog updated * Pyodide 0.27.2, Python 3.12.9 * Fix sitecustomize.py for Python 3.12.9 * Copy sysconfig on macOS only
1 parent cc17b54 commit 792379d

File tree

18 files changed

+145
-37
lines changed

18 files changed

+145
-37
lines changed

src/serious_python/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.8.8
2+
3+
* Set `MinimumOSVersion` to `13.0` for generated Python frameworks.
4+
* Pyodide 0.27.2
5+
* Python 3.12.9
6+
17
## 0.8.7
28

39
* Fixed: `xcframeworks` migration script didn't work for sub-directories.

src/serious_python/bin/package_command.dart

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import 'macos_utils.dart' as macos_utils;
1313
import 'sitecustomize.dart';
1414

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

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

512512
if (_verbose) {
513513
verbose(
@@ -523,13 +523,18 @@ class PackageCommand extends Command {
523523

524524
// extract Python from archive
525525
if (_verbose) {
526-
"Extracting Python distributive from $pythonArchivePath to ${_pythonDir!.path}";
526+
verbose(
527+
"Extracting Python distributive from $pythonArchivePath to ${_pythonDir!.path}");
527528
} else {
528529
stdout.writeln("Extracting Python distributive");
529530
}
530531

531532
await Process.run(
532533
'tar', ['-xzf', pythonArchivePath, '-C', _pythonDir!.path]);
534+
535+
if (Platform.isMacOS) {
536+
copySysconfigFiles(_pythonDir!.path);
537+
}
533538
}
534539
}
535540

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

550+
void copySysconfigFiles(String pythonDir) {
551+
final libPath = Directory(path.join(pythonDir, "python", "lib"));
552+
553+
// Find the Python version dynamically (e.g., python3.10, python3.11)
554+
if (!libPath.existsSync()) {
555+
stderr.writeln('Python lib directory not found: $libPath');
556+
exit(1);
557+
}
558+
559+
// Find the actual Python 3.x subdirectory
560+
final pythonSubDir = libPath
561+
.listSync()
562+
.whereType<Directory>()
563+
.firstWhere((dir) => RegExp(r'python3\.\d+').hasMatch(dir.path),
564+
orElse: () => throw Exception('No Python 3.x directory found'))
565+
.path;
566+
567+
final targetDir = Directory(pythonSubDir);
568+
569+
// Search for `_sysconfigdata__*.py` files
570+
final files = targetDir
571+
.listSync()
572+
.whereType<File>()
573+
.where((file) => RegExp(r'_sysconfigdata__.*\.py$').hasMatch(file.path))
574+
.toList();
575+
576+
if (files.isEmpty) {
577+
stderr.writeln('No matching _sysconfigdata__ files found in $targetDir');
578+
exit(1);
579+
}
580+
581+
for (final file in files) {
582+
final dir = file.parent.path;
583+
584+
// Define the new filenames
585+
final targets = [
586+
'_sysconfigdata__darwin_arm64_iphoneos.py',
587+
'_sysconfigdata__darwin_arm64_iphonesimulator.py',
588+
'_sysconfigdata__darwin_x86_64_iphonesimulator.py',
589+
];
590+
591+
for (final target in targets) {
592+
final targetPath = '$dir/$target';
593+
file.copySync(targetPath);
594+
if (_verbose) {
595+
verbose('Copied ${file.path} -> $targetPath');
596+
}
597+
}
598+
}
599+
}
600+
545601
Future<HttpServer> startSimpleServer() async {
546602
const htmlHeader = "<!DOCTYPE html><html><body>\n";
547603
const htmlFooter = "</body></html>\n";

src/serious_python/bin/sitecustomize.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ custom_system = "{platform}"
66
custom_platform = "{tag}"
77
custom_mac_ver = "{mac_ver}"
88
9+
import collections
910
import platform
1011
import sysconfig
12+
import sys
1113
1214
if custom_system:
1315
platform.system = lambda: custom_system
@@ -24,6 +26,20 @@ if custom_mac_ver:
2426
2527
platform.mac_ver = custom_mac_ver_impl
2628
29+
if custom_system == "iOS":
30+
IOSVersionInfo = collections.namedtuple(
31+
"IOSVersionInfo",
32+
["system", "release", "model", "is_simulator"]
33+
)
34+
35+
tag_parts = custom_platform.split("-")
36+
37+
def custom_ios_ver(system="", release="", model="", is_simulator=False):
38+
return IOSVersionInfo(custom_system, tag_parts[1], "iPhone", "simulator" in tag_parts[3])
39+
40+
platform.ios_ver = custom_ios_ver
41+
42+
sys.implementation._multiarch = f"{tag_parts[2]}_{tag_parts[3]}"
2743
2844
orig_platform_version = platform.version
2945
platform.version = lambda: orig_platform_version() + ";embedded"

src/serious_python/example/run_example/pubspec.lock

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ packages:
5353
dependency: transitive
5454
description:
5555
name: collection
56-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
56+
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
5757
url: "https://pub.dev"
5858
source: hosted
59-
version: "1.18.0"
59+
version: "1.19.0"
6060
crypto:
6161
dependency: transitive
6262
description:
@@ -150,18 +150,18 @@ packages:
150150
dependency: transitive
151151
description:
152152
name: leak_tracker
153-
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
153+
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
154154
url: "https://pub.dev"
155155
source: hosted
156-
version: "10.0.5"
156+
version: "10.0.7"
157157
leak_tracker_flutter_testing:
158158
dependency: transitive
159159
description:
160160
name: leak_tracker_flutter_testing
161-
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
161+
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
162162
url: "https://pub.dev"
163163
source: hosted
164-
version: "3.0.5"
164+
version: "3.0.8"
165165
leak_tracker_testing:
166166
dependency: transitive
167167
description:
@@ -296,42 +296,42 @@ packages:
296296
path: "../.."
297297
relative: true
298298
source: path
299-
version: "0.8.6"
299+
version: "0.8.8"
300300
serious_python_android:
301301
dependency: transitive
302302
description:
303303
path: "../../../serious_python_android"
304304
relative: true
305305
source: path
306-
version: "0.8.6"
306+
version: "0.8.8"
307307
serious_python_darwin:
308308
dependency: transitive
309309
description:
310310
path: "../../../serious_python_darwin"
311311
relative: true
312312
source: path
313-
version: "0.8.6"
313+
version: "0.8.8"
314314
serious_python_linux:
315315
dependency: transitive
316316
description:
317317
path: "../../../serious_python_linux"
318318
relative: true
319319
source: path
320-
version: "0.8.6"
320+
version: "0.8.8"
321321
serious_python_platform_interface:
322322
dependency: transitive
323323
description:
324324
path: "../../../serious_python_platform_interface"
325325
relative: true
326326
source: path
327-
version: "0.8.6"
327+
version: "0.8.8"
328328
serious_python_windows:
329329
dependency: transitive
330330
description:
331331
path: "../../../serious_python_windows"
332332
relative: true
333333
source: path
334-
version: "0.8.6"
334+
version: "0.8.8"
335335
shelf:
336336
dependency: transitive
337337
description:
@@ -344,7 +344,7 @@ packages:
344344
dependency: transitive
345345
description: flutter
346346
source: sdk
347-
version: "0.0.99"
347+
version: "0.0.0"
348348
source_span:
349349
dependency: transitive
350350
description:
@@ -357,10 +357,10 @@ packages:
357357
dependency: transitive
358358
description:
359359
name: stack_trace
360-
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
360+
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
361361
url: "https://pub.dev"
362362
source: hosted
363-
version: "1.11.1"
363+
version: "1.12.0"
364364
stream_channel:
365365
dependency: transitive
366366
description:
@@ -373,10 +373,10 @@ packages:
373373
dependency: transitive
374374
description:
375375
name: string_scanner
376-
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
376+
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
377377
url: "https://pub.dev"
378378
source: hosted
379-
version: "1.2.0"
379+
version: "1.3.0"
380380
sync_http:
381381
dependency: transitive
382382
description:
@@ -397,10 +397,10 @@ packages:
397397
dependency: transitive
398398
description:
399399
name: test_api
400-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
400+
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
401401
url: "https://pub.dev"
402402
source: hosted
403-
version: "0.7.2"
403+
version: "0.7.3"
404404
toml:
405405
dependency: transitive
406406
description:
@@ -429,10 +429,10 @@ packages:
429429
dependency: transitive
430430
description:
431431
name: vm_service
432-
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
432+
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
433433
url: "https://pub.dev"
434434
source: hosted
435-
version: "14.2.5"
435+
version: "14.3.0"
436436
web:
437437
dependency: transitive
438438
description:
@@ -445,10 +445,10 @@ packages:
445445
dependency: transitive
446446
description:
447447
name: webdriver
448-
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
448+
sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
449449
url: "https://pub.dev"
450450
source: hosted
451-
version: "3.0.3"
451+
version: "3.0.4"
452452
xdg_directories:
453453
dependency: transitive
454454
description:

src/serious_python/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: serious_python
22
description: A cross-platform plugin for adding embedded Python runtime to your Flutter apps.
33
homepage: https://flet.dev
44
repository: https://github.com/flet-dev/serious-python
5-
version: 0.8.7
5+
version: 0.8.8
66

77
platforms:
88
ios:

src/serious_python_android/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.8.8
2+
3+
* Set `MinimumOSVersion` to `13.0` for generated Python frameworks.
4+
* Pyodide 0.27.2
5+
* Python 3.12.9
6+
17
## 0.8.7
28

39
* Fixed: `xcframeworks` migration script didn't work for sub-directories.

src/serious_python_android/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.flet.serious_python_android'
2-
version '0.8.7'
2+
version '0.8.8'
33

44
def python_version = '3.12'
55

src/serious_python_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: serious_python_android
22
description: Android implementation of the serious_python plugin
33
homepage: https://flet.dev
44
repository: https://github.com/flet-dev/serious-python
5-
version: 0.8.7
5+
version: 0.8.8
66

77
environment:
88
sdk: ">=3.0.0 <4.0.0"

src/serious_python_darwin/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.8.8
2+
3+
* Set `MinimumOSVersion` to `13.0` for generated Python frameworks.
4+
* Pyodide 0.27.2
5+
* Python 3.12.9
6+
17
## 0.8.7
28

39
* Fixed: `xcframeworks` migration script didn't work for sub-directories.

src/serious_python_darwin/darwin/serious_python_darwin.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
Pod::Spec.new do |s|
66
s.name = 'serious_python_darwin'
7-
s.version = '0.8.7'
7+
s.version = '0.8.8'
88
s.summary = 'A cross-platform plugin for adding embedded Python runtime to your Flutter apps.'
99
s.description = <<-DESC
1010
A cross-platform plugin for adding embedded Python runtime to your Flutter apps.

0 commit comments

Comments
 (0)