This is an example of a Python Worker that uses the FastAPI-MCP package.
Vendored packages are added to your source files and need to be installed in a special manner. The Python Workers team plans to make this process automatic in the future, but for now, manual steps need to be taken.
First, install Python3.12 and pip for Python 3.12.
Currently, other versions of Python will not work - use 3.12!
Then create a virtual environment and activate it from your shell:
python3.12 -m venv .venv
source .venv/bin/activateWithin our virtual environment, install the pyodide CLI:
.venv/bin/pip install pyodide-build
.venv/bin/pyodide venv .venv-pyodideLastly, download the vendored packages. For any additional packages, re-run this command.
.venv-pyodide/bin/pip install -t src/vendor -r vendor.txtTo develop your Worker, run npx wrangler@latest dev.
To deploy your Worker, run npx wrangler@latest deploy.