Add a FastAPI Positron bootstrap.#4156
Conversation
|
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. |
|
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). |
Co-authored-by: Russell Martin <[email protected]>
|
I've backed the PyScript code out of this branch so we can land the FastAPI bootstrap. The PyScript plugin has some experimental components that aren't quite ready for prime time; see #4296 for progress there. |
kattni
left a comment
There was a problem hiding this comment.
Tested successfully. Looks good to me!
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)" to test out the new option.
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.