Skip to content

Commit 8387448

Browse files
committed
Adds docs for python_module_excludes.
1 parent c6639da commit 8387448

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/content/docs/workers/wrangler/configuration.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,27 @@ Any files that match `rules` will also be included as unbundled, external module
11281128

11291129
See https://developers.cloudflare.com/workers/wrangler/bundling/ for more details and examples.
11301130

1131+
### Python Workers
1132+
1133+
By default, Python Workers bundle the files and folders in `python_modules` at the root of your Worker (alongside your wrangler config file).
1134+
The files in this directory represent your vendored packages and is where the pywrangler tool copies packages into. In some cases, you
1135+
may find that the files in this folder are too large and if your worker doesn't require them then they just grow your bundle size for
1136+
no reason.
1137+
1138+
To fix this, you can exclude certain files from being included. To do this use the `python_modules_excludes` option, for example:
1139+
1140+
<WranglerConfig>
1141+
1142+
```toml title="wrangler.toml"
1143+
python_modules_excludes = ["**/*.pyc", "**/__pycache__"]
1144+
```
1145+
1146+
</WranglerConfig>
1147+
1148+
This will exclude any .pyc files and `__pycache__` directories inside any subdirectory in `python_modules`.
1149+
1150+
By default, `python_modules_excludes` is set to `["**/*.pyc"]`, so be sure to include this when setting it to a different value.
1151+
11311152
## Local development settings
11321153

11331154
:::note

0 commit comments

Comments
 (0)