Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pyodide to 0.25.0 #1576

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ http_archive(

http_archive(
name = "pyodide",
sha256 = "9136265cb046e4dea12a38a19afc154ddc6c525b6a96632c63c3192bff2d6839",
type = "tar.bz2",
urls = ["https://github.com/pyodide/pyodide/releases/download/0.25.0a2/pyodide-core-0.25.0a2.tar.bz2"],
build_file = "//:build/BUILD.pyodide",
sha256 = "ebe015d9e0c766af3679378699ac145f0fc320a49213b4734fd30bc28c68c360",
type = "tar.bz2",
urls = ["https://github.com/pyodide/pyodide/releases/download/0.25.0/pyodide-core-0.25.0.tar.bz2"],
)

http_archive(
Expand Down
19 changes: 18 additions & 1 deletion build/wd_js_bundle.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@capnp-cpp//src/capnp:cc_capnp_library.bzl", "cc_capnp_library")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@capnp-cpp//src/capnp:cc_capnp_library.bzl", "cc_capnp_library")

CAPNP_TEMPLATE = """@{schema_id};

Expand Down Expand Up @@ -64,6 +64,10 @@ def _gen_api_bundle_capnpn_impl(ctx):
_render_module(ctx.attr.internal_data_modules[m], m.label, "data", "internal")
for m in ctx.attr.internal_data_modules
]
modules += [
_render_module(ctx.attr.internal_json_modules[m], m.label, "json", "internal")
for m in ctx.attr.internal_json_modules
]

content = CAPNP_TEMPLATE.format(
schema_id = ctx.attr.schema_id,
Expand All @@ -81,6 +85,7 @@ gen_api_bundle_capnpn = rule(
"internal_modules": attr.label_keyed_string_dict(allow_files = True),
"internal_wasm_modules": attr.label_keyed_string_dict(allow_files = True),
"internal_data_modules": attr.label_keyed_string_dict(allow_files = True),
"internal_json_modules": attr.label_keyed_string_dict(allow_files = True),
"declarations": attr.string_dict(),
"data": attr.label_list(allow_files = True),
"const_name": attr.string(mandatory = True),
Expand Down Expand Up @@ -117,6 +122,7 @@ def wd_js_bundle(
internal_modules = [],
internal_wasm_modules = [],
internal_data_modules = [],
internal_json_modules = [],
declarations = [],
deps = []):
"""Generate cc capnp library with js api bundle.
Expand All @@ -137,6 +143,7 @@ def wd_js_bundle(
internal_modules: list of js source files for internal modules
internal_wasm_modules: list of wasm source files
internal_data_modules: list of data source files
internal_json_modules: list of json source files
declarations: d.ts label set
deps: dependency list
"""
Expand All @@ -156,6 +163,10 @@ def wd_js_bundle(
m: "{}-internal:{}".format(import_name, m.removeprefix("internal/"))
for m in internal_data_modules
}
internal_json_modules_dict = {
m: "{}-internal:{}".format(import_name, m.removeprefix("internal/"))
for m in internal_json_modules
}

builtin_modules_dict, builtin_declarations = _copy_modules(
builtin_modules_dict,
Expand All @@ -173,12 +184,17 @@ def wd_js_bundle(
internal_data_modules_dict,
declarations,
)
internal_json_modules_dict, _ = _copy_modules(
internal_json_modules_dict,
declarations,
)

data = (
list(builtin_modules_dict) +
list(internal_modules_dict) +
list(internal_wasm_modules_dict) +
list(internal_data_modules_dict) +
list(internal_json_modules_dict) +
list(builtin_declarations.values()) +
list(internal_declarations.values())
)
Expand All @@ -192,6 +208,7 @@ def wd_js_bundle(
internal_modules = internal_modules_dict,
internal_wasm_modules = internal_wasm_modules_dict,
internal_data_modules = internal_data_modules_dict,
internal_json_modules = internal_json_modules_dict,
declarations = builtin_declarations | internal_declarations,
data = data,
deps = deps,
Expand Down
9 changes: 8 additions & 1 deletion src/pyodide/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ copy_file(
out = "generated/python_stdlib.zip",
)

copy_file(
name = "pyodide-lock.js@rule",
src = "@pyodide//:pyodide/pyodide-lock.json",
out = "generated/pyodide-lock.json",
)

PRELUDE = """
import { newWasmModule, monotonicDateNow, wasmInstantiate } from "pyodide-internal:builtin_wrappers";

Expand Down Expand Up @@ -97,9 +103,9 @@ wd_js_bundle(
"internal/*.py",
"internal/patches/*.py",
]),
internal_json_modules = ["generated/pyodide-lock.json"],
internal_modules = [
"generated/pyodide.asm.js",
"internal/pyodide-lock.js",
] + glob([
"internal/*.js",
]),
Expand All @@ -108,6 +114,7 @@ wd_js_bundle(
deps = [
"pyodide.asm.js@rule",
"pyodide.asm.wasm@rule",
"pyodide-lock.js@rule",
"python_stdlib.zip@rule",
],
)
4 changes: 2 additions & 2 deletions src/pyodide/internal/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def request_to_scope(req, ws=False):

headers = [tuple(x) for x in req.headers]
url = URL.new(req.url)
assert url.protocol[-1] == ':'
assert url.protocol[-1] == ":"
scheme = url.protocol[:-1]
path = url.pathname
assert url.search[0] == '?'
assert "?".startswith(url.search[0:1])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious about this, the former is far clearer, why the change?

Copy link
Contributor Author

@hoodmane hoodmane Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url.search can also be empty, the previous assert would throw an error in this case. Probably saying

not url.search or url.search[0] == "?"

is clearer

query_string = url.search[1:].encode()
if ws:
ty = "websocket"
Expand Down
Loading
Loading