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
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 @@
## 5.0.0

* **Breaking (`package` command):** `--exclude`, `--cleanup-app-files` and `--cleanup-package-files` no longer split their values on commas, so paths containing `,` and brace globs such as `**/{tests,docs}` can be passed. Previously a hidden file named `.a,main.py` passed to `--exclude` became two exclusions, dropping `main.py`, and `**/{tests,docs}` was split into two broken globs. Pass each value as its own option: `--exclude build --exclude tests` instead of `--exclude build,tests`. A comma-separated value is now matched as a single path, so an unmigrated command packages the files it used to exclude without failing. The Dart API and runtime are unchanged. `flet build` pins serious_python exactly, so existing Flet releases are unaffected ([#253](https://github.com/flet-dev/serious-python/pull/253), [flet#6839](https://github.com/flet-dev/flet/issues/6839)).

## 4.7.2

* **Packaging:** report packaging exceptions on stderr and exit with status `1`, so CI and `flet build` stop on failure while temporary files are still cleaned up ([#252](https://github.com/flet-dev/serious-python/pull/252)).
Expand Down
20 changes: 19 additions & 1 deletion src/serious_python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,24 @@ identifiers assigned upstream. serious_python stages those byte-for-byte and nev
rewrites anything inside them — see [SDK-origin signatures](#sdk-origin-signatures)
below.

#### Excluding and cleaning up files

Exclude files and directories from the app package with `--exclude`. Each value is a path relative to the app directory, matched exactly (no globs); a matching directory is excluded with everything in it. Pass the option once per path:

```
dart run serious_python:main package app/src -p Darwin \
--exclude build --exclude tests --exclude src/.venv
```

`--cleanup-app` and `--cleanup-packages` (or `--cleanup` for both) delete known junk files (C sources and headers, type stubs, `__pycache__`, and so on) from the app and from the installed packages. Add your own globs with `--cleanup-app-files` and `--cleanup-package-files`, once per glob; they are only applied together with the matching cleanup flag:

```
dart run serious_python:main package app/src -p Android --cleanup-packages \
--cleanup-package-files '**/{tests,docs}' --cleanup-package-files '**.md'
```

> `--exclude`, `--cleanup-app-files` and `--cleanup-package-files` stopped splitting their values on commas in **5.0.0**, so paths containing `,` and brace globs such as `**/{tests,docs}` can be expressed. The comma-separated form (`--exclude build,tests`) now matches a single path named `build,tests`; pass each value as its own option instead.

## Python app structure

By default, embedded Python program is run in a separate thread, to avoid UI blocking. Your Flutter app is not supposed to directly call Python functions or modules, but instead it should communicate via some API provided by a Python app, such as: REST API, sockets, SQLite database, files, etc.
Expand Down Expand Up @@ -256,7 +274,7 @@ The on-disk layout differs per platform, mostly because each OS has different ru

### Your app program (all platforms)

`package` copies your Python sources into a temp dir (honoring `--exclude` globs, optionally compiling to `.pyc` with `--compile-app`). For **native** platforms it stages them to `SERIOUS_PYTHON_APP`, and the platform build drops them **unpacked into the bundle** next to the stdlib/site-packages — `<resourcePath>/app` (iOS/macOS), `<exe-dir>/app` (Windows/Linux). There's no first-launch extraction; `SeriousPython.prepareApp()` just returns that path. On **Android** the sources are zipped into a *stored* `app.zip` asset and unpacked once (version-keyed by your app version) to `<application-support>/flet/app` on the first launch after an install/update. On the **web** they're zipped into `app/app.zip` and loaded by Pyodide. Your app dir is placed first on `sys.path`; a sibling `__pypackages__/` is also added (so you can vendor pure-Python deps next to your code). At run time the current directory is set to a writable `<application-support>/data` (the app dir itself is read-only).
`package` copies your Python sources into a temp dir (skipping `--exclude` paths, optionally compiling to `.pyc` with `--compile-app`). For **native** platforms it stages them to `SERIOUS_PYTHON_APP`, and the platform build drops them **unpacked into the bundle** next to the stdlib/site-packages — `<resourcePath>/app` (iOS/macOS), `<exe-dir>/app` (Windows/Linux). There's no first-launch extraction; `SeriousPython.prepareApp()` just returns that path. On **Android** the sources are zipped into a *stored* `app.zip` asset and unpacked once (version-keyed by your app version) to `<application-support>/flet/app` on the first launch after an install/update. On the **web** they're zipped into `app/app.zip` and loaded by Pyodide. Your app dir is placed first on `sys.path`; a sibling `__pypackages__/` is also added (so you can vendor pure-Python deps next to your code). At run time the current directory is set to a writable `<application-support>/data` (the app dir itself is read-only).

`pip install` output goes to `build/site-packages` by default (override with the `SERIOUS_PYTHON_SITE_PACKAGES` env var). For mobile, packages are installed **per architecture** (a `sitecustomize.py` shim spoofs the wheel platform tag so the correct mobile wheels resolve), then merged or split per platform as shown above.

Expand Down
11 changes: 8 additions & 3 deletions src/serious_python/bin/package_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ class PackageCommand extends Command {
"Output asset path, relative to pubspec.yaml, to package Python program into.");
argParser.addMultiOption('exclude',
help:
"List of relative paths to exclude from app package, e.g. \"assets,build\".");
"Relative path to exclude from app package, e.g. \"build\"; can be used multiple times.",
splitCommas: false);
argParser.addFlag("skip-site-packages",
help: "Skip installation of site packages.", negatable: false);
argParser.addFlag("compile-app",
Expand All @@ -180,12 +181,16 @@ class PackageCommand extends Command {
help: "Cleanup app from unneccessary files and directories.",
negatable: false);
argParser.addMultiOption('cleanup-app-files',
help: "List of globs to delete extra app files and directories.");
help:
"Glob to delete extra app files and directories; can be used multiple times.",
splitCommas: false);
argParser.addFlag("cleanup-packages",
help: "Cleanup packages from unneccessary files and directories.",
negatable: false);
argParser.addMultiOption('cleanup-package-files',
help: "List of globs to delete extra packages files and directories.");
help:
"Glob to delete extra packages files and directories; can be used multiple times.",
splitCommas: false);
argParser.addFlag("verbose", help: "Verbose output.", negatable: false);
}

Expand Down
12 changes: 6 additions & 6 deletions src/serious_python/example/flask_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -361,42 +361,42 @@ packages:
path: "../.."
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_android:
dependency: transitive
description:
path: "../../../serious_python_android"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_darwin:
dependency: transitive
description:
path: "../../../serious_python_darwin"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_linux:
dependency: transitive
description:
path: "../../../serious_python_linux"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_platform_interface:
dependency: transitive
description:
path: "../../../serious_python_platform_interface"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_windows:
dependency: transitive
description:
path: "../../../serious_python_windows"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
shelf:
dependency: transitive
description:
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 @@ -384,42 +384,42 @@ packages:
path: "../.."
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_android:
dependency: transitive
description:
path: "../../../serious_python_android"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_darwin:
dependency: transitive
description:
path: "../../../serious_python_darwin"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_linux:
dependency: transitive
description:
path: "../../../serious_python_linux"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_platform_interface:
dependency: transitive
description:
path: "../../../serious_python_platform_interface"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
serious_python_windows:
dependency: transitive
description:
path: "../../../serious_python_windows"
relative: true
source: path
version: "4.7.2"
version: "5.0.0"
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: 4.7.2
version: 5.0.0

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 @@
## 5.0.0

* Align with the serious_python **5.0.0** release ([#253](https://github.com/flet-dev/serious-python/pull/253)).

## 4.7.2

* Align with the serious_python **4.7.2** release ([#252](https://github.com/flet-dev/serious-python/pull/252)).
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python_android/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
}

group = "com.flet.serious_python_android"
version = "4.7.2"
version = "5.0.0"

rootProject.allprojects {
repositories {
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: 4.7.2
version: 5.0.0

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

* Align with the serious_python **5.0.0** release ([#253](https://github.com/flet-dev/serious-python/pull/253)).

## 4.7.2

* **macOS:** fix App Store Connect error `90238` ("does not satisfy its designated Requirement") caused by linker-signed native modules ([#250](https://github.com/flet-dev/serious-python/issues/250), [#251](https://github.com/flet-dev/serious-python/pull/251)). Staging now replaces linker signatures on `.so` and `.dylib` files in the stdlib, site-packages and app with regular ad-hoc signatures. This preserves their signing identifiers when Xcode re-signs them for distribution, avoiding a mismatch with their designated requirements.
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 = '4.7.2'
s.version = '5.0.0'
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/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: 4.7.2
version: 5.0.0

environment:
# The Swift Package Manager build path needs Flutter 3.44 / Dart 3.11 (the
Expand Down
4 changes: 4 additions & 0 deletions src/serious_python_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.0.0

* Align with the serious_python **5.0.0** release ([#253](https://github.com/flet-dev/serious-python/pull/253)).

## 4.7.2

* Align with the serious_python **4.7.2** release ([#252](https://github.com/flet-dev/serious-python/pull/252)).
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: 4.7.2
version: 5.0.0

environment:
sdk: '>=3.1.3 <4.0.0'
Expand Down
4 changes: 4 additions & 0 deletions src/serious_python_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.0.0

* Align with the serious_python **5.0.0** release ([#253](https://github.com/flet-dev/serious-python/pull/253)).

## 4.7.2

* Align with the serious_python **4.7.2** release ([#252](https://github.com/flet-dev/serious-python/pull/252)).
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: serious_python_platform_interface
description: A common platform interface for the serious_python plugin.
homepage: https://flet.dev
repository: https://github.com/flet-dev/serious-python
version: 4.7.2
version: 5.0.0

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

* Align with the serious_python **5.0.0** release ([#253](https://github.com/flet-dev/serious-python/pull/253)).

## 4.7.2

* Align with the serious_python **4.7.2** release ([#252](https://github.com/flet-dev/serious-python/pull/252)).
Expand Down
2 changes: 1 addition & 1 deletion src/serious_python_windows/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: serious_python_windows
description: Windows implementations of the serious_python plugin
homepage: https://flet.dev
repository: https://github.com/flet-dev/serious-python
version: 4.7.2
version: 5.0.0

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