|
8 | 8 |
|
9 | 9 | import { Render } from "~/components"; |
10 | 10 |
|
11 | | -<Render file="python-workers-beta-packages" product="workers" /> |
| 11 | +[Pywrangler](https://github.com/cloudflare/workers-py?tab=readme-ov-file#pywrangler) is a CLI tool for managing packages and Python Workers. |
| 12 | +It is meant as a wrapper for wrangler that sets up a full environment for you, including bundling your packages into |
| 13 | +your worker bundle on deployment. |
| 14 | + |
| 15 | +To get started, create a pyproject.toml file with the following contents: |
| 16 | + |
| 17 | +```toml |
| 18 | +[project] |
| 19 | +name = "YourProjectName" |
| 20 | +version = "0.1.0" |
| 21 | +description = "Add your description here" |
| 22 | +requires-python = ">=3.12" |
| 23 | +dependencies = [ |
| 24 | + "fastapi" |
| 25 | +] |
| 26 | + |
| 27 | +[dependency-groups] |
| 28 | +dev = ["workers-py"] |
| 29 | +``` |
12 | 30 |
|
13 | | -To import a Python package, add the package name to the `requirements.txt` file within the same directory as your [Wrangler configuration file](/workers/wrangler/configuration/). |
| 31 | +The above will allow your worker to depend on the [FastAPI](https://fastapi.tiangolo.com/) package. |
14 | 32 |
|
15 | | -For example, if your Worker depends on [FastAPI](https://fastapi.tiangolo.com/), you would add the following: |
| 33 | +To run the worker locally: |
16 | 34 |
|
17 | 35 | ``` |
18 | | -fastapi |
| 36 | +uv run pywrangler dev |
19 | 37 | ``` |
20 | 38 |
|
21 | | -## Package versioning |
22 | | - |
23 | | -In the example above, you likely noticed that there is no explicit version of the Python package declared in `requirements.txt`. |
24 | | - |
25 | | -In Workers, Python package versions are set via [Compatibility Dates](/workers/configuration/compatibility-dates/) and [Compatibility Flags](/workers/configuration/compatibility-flags/). Given a particular compatibility date, a specific version of the [Pyodide Python runtime](https://pyodide.org/en/stable/project/changelog.html) is provided to your Worker, providing a specific set of Python packages pinned to specific versions. |
26 | | - |
27 | | -As new versions of Pyodide and additional Python packages become available in Workers, we will publish compatibility flags and their associated compatibility dates here on this page. |
| 39 | +To deploy your worker: |
28 | 40 |
|
29 | | -## Supported Packages |
30 | | - |
31 | | -A subset of the [Python packages that Pyodide supports](https://pyodide.org/en/latest/usage/packages-in-pyodide.html) are provided directly by the Workers runtime: |
| 41 | +``` |
| 42 | +uv run pywrangler deploy |
| 43 | +``` |
32 | 44 |
|
33 | | -- aiohttp: 3.9.3 |
34 | | -- aiohttp-tests: 3.9.3 |
35 | | -- aiosignal: 1.3.1 |
36 | | -- annotated-types: 0.6.0 |
37 | | -- annotated-types-tests: 0.6.0 |
38 | | -- anyio: 4.2.0 |
39 | | -- async-timeout: 4.0.3 |
40 | | -- attrs: 23.2.0 |
41 | | -- certifi: 2024.2.2 |
42 | | -- charset-normalizer: 3.3.2 |
43 | | -- distro: 1.9.0 |
44 | | -- [fastapi](/workers/languages/python/packages/fastapi): 0.110.0 |
45 | | -- frozenlist: 1.4.1 |
46 | | -- h11: 0.14.0 |
47 | | -- h11-tests: 0.14.0 |
48 | | -- hashlib: 1.0.0 |
49 | | -- httpcore: 1.0.4 |
50 | | -- httpx: 0.27.0 |
51 | | -- idna: 3.6 |
52 | | -- jsonpatch: 1.33 |
53 | | -- jsonpointer: 2.4 |
54 | | -- langchain: 0.1.8 |
55 | | -- langchain-core: 0.1.25 |
56 | | -- langchain-openai: 0.0.6 |
57 | | -- langsmith: 0.1.5 |
58 | | -- lzma: 1.0.0 |
59 | | -- micropip: 0.6.0 |
60 | | -- multidict: 6.0.5 |
61 | | -- numpy: 1.26.4 |
62 | | -- numpy-tests: 1.26.4 |
63 | | -- openai: 1.12.0 |
64 | | -- openssl: 1.1.1n |
65 | | -- packaging: 23.2 |
66 | | -- pydantic: 2.6.1 |
67 | | -- pydantic-core: 2.16.2 |
68 | | -- pydecimal: 1.0.0 |
69 | | -- pydoc-data: 1.0.0 |
70 | | -- pyyaml: 6.0.1 |
71 | | -- regex: 2023.12.25 |
72 | | -- regex-tests: 2023.12.25 |
73 | | -- requests: 2.31.0 |
74 | | -- six: 1.16.0 |
75 | | -- sniffio: 1.3.0 |
76 | | -- sniffio-tests: 1.3.0 |
77 | | -- sqlite3: 1.0.0 |
78 | | -- ssl: 1.0.0 |
79 | | -- starlette: 0.36.3 |
| 45 | +Your dependencies will get bundled with your worker automatically on deployment. |
80 | 46 |
|
81 | | -Looking for a package not listed here? Tell us what you'd like us to support by [opening a discussion on Github](https://github.com/cloudflare/workerd/discussions/new?category=python-packages). |
| 47 | +The `pywrangler` CLI also supports all commands supported by the `wrangler` tool, for the full list of commands run `uv run pywrangler --help`. |
82 | 48 |
|
83 | 49 | ## HTTP Client Libraries |
84 | 50 |
|
|
0 commit comments