Packages
Pywrangler ↗ is a CLI tool for managing packages and Python Workers. It is meant as a wrapper for wrangler that sets up a full environment for you, including bundling your packages into your worker bundle on deployment.
To get started, create a pyproject.toml file with the following contents:
[project]name = "YourProjectName"version = "0.1.0"description = "Add your description here"requires-python = ">=3.13"dependencies = [ "fastapi"]
[dependency-groups]dev = [ "workers-py", "workers-runtime-sdk"]The above will allow your worker to depend on the FastAPI ↗ package.
To run the worker locally:
uv run pywrangler devTo deploy your worker:
uv run pywrangler deployYour dependencies will get bundled with your worker automatically on deployment.
The pywrangler CLI also supports all commands supported by the wrangler tool, for the full list of commands run uv run pywrangler --help.
Python Workers support pure and PyEmscripten ↗ Python packages on PyPI ↗. Additionally, Python Workers support packages that are included in Pyodide ↗.
WebAssembly support for Python packages is still in early stages, and some packages may not yet be available as PyEmscripten wheels on PyPI. If a package you would like to use is not yet available, we encourage you to reach out to the package maintainers and request PyEmscripten wheels. You can also start a thread in the Python Packages Discussions ↗ on the Cloudflare Workers Runtime GitHub repository — we would be happy to help you communicate with package maintainers.
Only HTTP libraries that are able to make requests asynchronously are supported. Currently, these include aiohttp ↗ and httpx ↗. You can also use the fetch() API from JavaScript, using Python Workers' foreign function interface to make HTTP requests.