workers-runtime-sdk 1.4.3__tar.gz → 1.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/CHANGELOG.md +29 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/PKG-INFO +1 -1
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/pyproject.toml +1 -1
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/workers/__init__.py +2 -1
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/workers/_workers.py +51 -32
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/uv.lock +1 -1
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/.gitignore +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/AGENTS.md +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/README.md +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/_cloudflare_compat_flags.pyi +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/_pyodide_entrypoint_helper.pyi +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/_workers_sdk_entropy_import_context.pth +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/_workers_sdk_entropy_import_context.py +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/_workers_sdk_entropy_import_context_loader.py +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/asgi.py +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/workers/py.typed +0 -0
- {workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/workers/workflows.py +0 -0
|
@@ -2,6 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- version list -->
|
|
4
4
|
|
|
5
|
+
## v1.5.1 (2026-06-29)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- Ensure self.env and top-level env uses a same class
|
|
10
|
+
([#136](https://github.com/cloudflare/workers-py/pull/136),
|
|
11
|
+
[`e627c11`](https://github.com/cloudflare/workers-py/commit/e627c11f58c572f6ee5df97e423928ee4423d2e9))
|
|
12
|
+
|
|
13
|
+
- Update FetchResponse.headers to return HTTPMessage
|
|
14
|
+
([#136](https://github.com/cloudflare/workers-py/pull/136),
|
|
15
|
+
[`e627c11`](https://github.com/cloudflare/workers-py/commit/e627c11f58c572f6ee5df97e423928ee4423d2e9))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## v1.5.0 (2026-06-23)
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- Apply bindings wrapper to AI bindings ([#130](https://github.com/cloudflare/workers-py/pull/130),
|
|
23
|
+
[`79eeaf9`](https://github.com/cloudflare/workers-py/commit/79eeaf94ab02e4208372a7d3f57ba34248421c93))
|
|
24
|
+
|
|
25
|
+
- Apply bindings wrapper to Images, RateLimit, and Analytics Engine
|
|
26
|
+
([#130](https://github.com/cloudflare/workers-py/pull/130),
|
|
27
|
+
[`79eeaf9`](https://github.com/cloudflare/workers-py/commit/79eeaf94ab02e4208372a7d3f57ba34248421c93))
|
|
28
|
+
|
|
29
|
+
- Wrap AI, Images, Analytics Engine, Vectorize and RateLimit Bindings to accept native Python
|
|
30
|
+
objects ([#130](https://github.com/cloudflare/workers-py/pull/130),
|
|
31
|
+
[`79eeaf9`](https://github.com/cloudflare/workers-py/commit/79eeaf94ab02e4208372a7d3f57ba34248421c93))
|
|
32
|
+
|
|
33
|
+
|
|
5
34
|
## v1.4.3 (2026-06-18)
|
|
6
35
|
|
|
7
36
|
### Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: workers-runtime-sdk
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.1
|
|
4
4
|
Summary: Python SDK for Cloudflare Workers
|
|
5
5
|
Project-URL: Homepage, https://github.com/cloudflare/workers-py
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/cloudflare/workers-py/issues
|
|
@@ -17,6 +17,7 @@ from ._workers import (
|
|
|
17
17
|
Response,
|
|
18
18
|
WorkerEntrypoint,
|
|
19
19
|
WorkflowEntrypoint,
|
|
20
|
+
_EnvWrapper,
|
|
20
21
|
fetch,
|
|
21
22
|
handler,
|
|
22
23
|
import_from_javascript,
|
|
@@ -59,7 +60,7 @@ __all__ = [
|
|
|
59
60
|
def __getattr__(key):
|
|
60
61
|
if key == "env":
|
|
61
62
|
cloudflare_workers = import_from_javascript("cloudflare:workers")
|
|
62
|
-
return cloudflare_workers.env
|
|
63
|
+
return _EnvWrapper(cloudflare_workers.env)
|
|
63
64
|
if key in ("wait_until", "waitUntil"):
|
|
64
65
|
cloudflare_workers = import_from_javascript("cloudflare:workers")
|
|
65
66
|
return cloudflare_workers.waitUntil
|
|
@@ -153,8 +153,45 @@ class FetchKwargs(TypedDict, total=False):
|
|
|
153
153
|
fetcher: type[pyfetch] | None
|
|
154
154
|
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
def _js_headers_to_http_message(
|
|
157
|
+
js_headers: dict[str, str],
|
|
158
|
+
):
|
|
159
|
+
# `http.client` is imported here because it costs a lot of CPU time when imported at the
|
|
160
|
+
# top-level. At least it does when we do so in our validator tests, doesn't seem to cause
|
|
161
|
+
# trouble in production. So as a workaround we do the import here.
|
|
162
|
+
#
|
|
163
|
+
# TODO(later): when dedicated snapshots are default we can move this import to the top-level.
|
|
164
|
+
import http.client
|
|
165
|
+
|
|
166
|
+
# Newer Pyodide versions already expose headers as an http.client.HTTPMessage,
|
|
167
|
+
# in which case there is nothing to convert.
|
|
168
|
+
if isinstance(js_headers, http.client.HTTPMessage):
|
|
169
|
+
return js_headers
|
|
170
|
+
|
|
171
|
+
result = http.client.HTTPMessage()
|
|
172
|
+
if not get_compat_flag("python_request_headers_preserve_commas"):
|
|
173
|
+
for key, val in js_headers:
|
|
174
|
+
result[key] = val.strip()
|
|
175
|
+
|
|
176
|
+
return result
|
|
177
|
+
|
|
178
|
+
# With the exception of Set-Cookie, duplicate headers can and are combined with a comma
|
|
179
|
+
# in the JS Headers API. We do the same when returning the headers to Python.
|
|
180
|
+
#
|
|
181
|
+
# See https://httpwg.org/specs/rfc9110.html#rfc.section.5.3.
|
|
182
|
+
set_cookie_headers = js_headers.getSetCookie()
|
|
183
|
+
if set_cookie_headers:
|
|
184
|
+
for value in set_cookie_headers:
|
|
185
|
+
result.add_header("Set-Cookie", value.strip())
|
|
186
|
+
|
|
187
|
+
for key, val in js_headers:
|
|
188
|
+
if key.lower() == "set-cookie":
|
|
189
|
+
continue
|
|
190
|
+
result.add_header(key, val.strip())
|
|
191
|
+
|
|
192
|
+
return result
|
|
193
|
+
|
|
194
|
+
|
|
158
195
|
class FetchResponse(pyodide.http.FetchResponse):
|
|
159
196
|
# TODO: Consider upstreaming the `body` attribute
|
|
160
197
|
# TODO: Behind a compat flag make this return a native stream (StreamReader?), or perhaps
|
|
@@ -170,6 +207,10 @@ class FetchResponse(pyodide.http.FetchResponse):
|
|
|
170
207
|
def js_object(self) -> "js.Response":
|
|
171
208
|
return self.js_response
|
|
172
209
|
|
|
210
|
+
@property
|
|
211
|
+
def headers(self):
|
|
212
|
+
return _js_headers_to_http_message(self.js_object.headers)
|
|
213
|
+
|
|
173
214
|
"""
|
|
174
215
|
Instance methods defined below.
|
|
175
216
|
|
|
@@ -813,36 +854,7 @@ class Request:
|
|
|
813
854
|
|
|
814
855
|
@property
|
|
815
856
|
def headers(self):
|
|
816
|
-
|
|
817
|
-
# At least it does when we do so in our validator tests, doesn't seem to cause trouble in
|
|
818
|
-
# production. So as a workaround we do the import here.
|
|
819
|
-
#
|
|
820
|
-
# TODO(later): when dedicated snapshots are default we can move this import to the top-level.
|
|
821
|
-
import http.client
|
|
822
|
-
|
|
823
|
-
result = http.client.HTTPMessage()
|
|
824
|
-
if not get_compat_flag("python_request_headers_preserve_commas"):
|
|
825
|
-
for key, val in self.js_object.headers:
|
|
826
|
-
result[key] = val.strip()
|
|
827
|
-
|
|
828
|
-
return result
|
|
829
|
-
|
|
830
|
-
# With the exception of Set-Cookie, duplicate headers can and are combined with a comma
|
|
831
|
-
# in the JS Headers API. We do the same when returning the headers to Python.
|
|
832
|
-
#
|
|
833
|
-
# See https://httpwg.org/specs/rfc9110.html#rfc.section.5.3.
|
|
834
|
-
js_headers = self.js_object.headers
|
|
835
|
-
set_cookie_headers = js_headers.getSetCookie()
|
|
836
|
-
if set_cookie_headers:
|
|
837
|
-
for value in set_cookie_headers:
|
|
838
|
-
result.add_header("Set-Cookie", value.strip())
|
|
839
|
-
|
|
840
|
-
for key, val in js_headers:
|
|
841
|
-
if key.lower() == "set-cookie":
|
|
842
|
-
continue
|
|
843
|
-
result.add_header(key, val.strip())
|
|
844
|
-
|
|
845
|
-
return result
|
|
857
|
+
return _js_headers_to_http_message(self.js_object.headers)
|
|
846
858
|
|
|
847
859
|
@property
|
|
848
860
|
def integrity(self) -> str:
|
|
@@ -1313,6 +1325,13 @@ class _EnvWrapper:
|
|
|
1313
1325
|
"R2Bucket",
|
|
1314
1326
|
"D1Database",
|
|
1315
1327
|
"WorkerQueue",
|
|
1328
|
+
"Ai",
|
|
1329
|
+
"VectorizeIndexImpl",
|
|
1330
|
+
"AnalyticsEngineDataset",
|
|
1331
|
+
"LocalAnalyticsEngineDataset",
|
|
1332
|
+
"ImagesBindingImpl",
|
|
1333
|
+
"HostedImagesBindingImpl",
|
|
1334
|
+
"Ratelimit",
|
|
1316
1335
|
}
|
|
1317
1336
|
|
|
1318
1337
|
def __init__(self, env: Any):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/_workers_sdk_entropy_import_context.pth
RENAMED
|
File without changes
|
{workers_runtime_sdk-1.4.3 → workers_runtime_sdk-1.5.1}/src/_workers_sdk_entropy_import_context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|