@@ -13,11 +13,11 @@ import 'macos_utils.dart' as macos_utils;
1313import 'sitecustomize.dart' ;
1414
1515const 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" ;
1717const 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 " ;
2121const defaultSitePackagesDir = "__pypackages__" ;
2222const sitePackagesEnvironmentVariable = "SERIOUS_PYTHON_SITE_PACKAGES" ;
2323const 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 " ;
0 commit comments