Add a FastAPI and PyScript Positron bootstrap.#4156
Draft
freakboy3742 wants to merge 16 commits intobeeware:mainfrom
Draft
Add a FastAPI and PyScript Positron bootstrap.#4156freakboy3742 wants to merge 16 commits intobeeware:mainfrom
freakboy3742 wants to merge 16 commits intobeeware:mainfrom
Conversation
Member
Author
|
In the current state, this can't deploy to iOS or Android; this is because Pydantic >= 2.0 is a hard requirement as of FastAPI 0.126.0; but even if you downgrade, uvicorn seems to use multiprocessing internally. I'm currently investigating options for this. |
rmartin16
reviewed
Feb 2, 2026
Member
Author
|
iOS and Android support has now been added. This requires pinning FastAPI to 0.125.0, as this is the last version that supports the use of Pydantic < 2. Pydantic 2 requires Pydantic-core, which is a Rust component; until we have a compiled version of that wheel available for iOS and Android, we can't upgrade. It also requires a small shim for iOS to work around multiprocessing not being present (see python/cpython#134634). |
rmartin16
reviewed
Feb 5, 2026
Co-authored-by: Russell Martin <russell@rjm.li>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PyScript backend is a FastAPI backend that has the "copy static content" function of the Static backend. FastAPI is used so that a web socket can be exposed; a draft of the coincident websocket FFI handler is included, but it won't work at present because the supporting code isn't present.
The "copy existing static web content" question will generate dummy content by default; it has placeholder support for "clone content from a live web server", but doesn't actually implement that.
Fixes #3327.
PR Checklist:
Testing guide
For anyone wanting to test this - here's a step by step guide.
Create a positron-test directory:
Create and activate a Python3 virtual environment. If you're on Linux, this will need to be the system default python3 interpreter:
Clone the Toga repo, and checkout the code for this PR. I'm using the
ghtool here; if you want to do it manually, you need thefastapibranch on my (@freakboy3742) fork of Toga:Install the checked-out version of Toga. If you're on macOS, use:
If you're on Linux, replace
./toga/cocoawith./toga/gtk. On Window, use./toga/winforms.Create a new Briefcase project:
Answer all the wizard questions with whatever answers you want. One of the last questions asks about your preferred GUI framework; select "Toga Positron (FastAPI server)" or "Toga Positron (PyScript app)" to test out the new options.
When you run the PyScript test, it will ask you for the location of existing web content - this should be a directory path relative to where you're running Briefcase. If you just press enter, you'll get a dummy PyScript app that is enough to show that PyScript runs.
Then run the app. If you've accepted the default "Hello World" app name, this will be:
If you chose any other name, the
briefcase newcommand should have shown you the commands to run.