8000 gh-96883: browser: include concurrent.futures (GH-96886) · python/cpython@0b62964 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b62964

Browse files
authored
gh-96883: browser: include concurrent.futures (GH-96886)
1 parent c00f2b1 commit 0b62964

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``wasm32-emscripten`` builds for browsers now include
2+
:mod:`concurrent.futures` for :mod:`asyncio` and :mod:`unittest.mock`.

Tools/wasm/wasm_assets.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
# Pure Python implementations of C extensions
5959
"_pydecimal.py",
6060
"_pyio.py",
61+
# concurrent threading
62+
"concurrent/futures/thread.py",
6163
# Misc unused or large files
6264
"pydoc_data/",
6365
"msilib/",
@@ -98,13 +100,12 @@
98100
"_dbm": ["dbm/ndbm.py"],
99101
"_gdbm": ["dbm/gnu.py"],
100102
"_json": ["json/"],
101-
"_multiprocessing": ["concurrent/", "multiprocessing/"],
103+
"_multiprocessing": ["concurrent/futures/process.py", "multiprocessing/"],
102104
"pyexpat": ["xml/", "xmlrpc/"],
103105
"readline": ["rlcompleter.py"],
104106
"_sqlite3": ["sqlite3/"],
105107
"_ssl": ["ssl.py"],
106108
"_tkinter": ["idlelib/", "tkinter/", "turtle.py", "turtledemo/"],
107-
108109
"_zoneinfo": ["zoneinfo/"],
109110
}
110111

@@ -117,21 +118,18 @@
117118

118119

119120
def get_builddir(args: argparse.Namespace) -> pathlib.Path:
120-
"""Get builddir path from pybuilddir.txt
121-
"""
121+
"""Get builddir path from pybuilddir.txt"""
122122
with open("pybuilddir.txt", encoding="utf-8") as f:
123123
builddir = f.read()
124124
return pathlib.Path(builddir)
125125

126126

127127
def get_sysconfigdata(args: argparse.Namespace) -> pathlib.Path:
128-
"""Get path to sysconfigdata relative to build root
129-
"""
128+
"""Get path to sysconfigdata relative to build root"""
130129
data_name = sysconfig._get_sysconfigdata_name()
131130
if not data_name.startswith(SYSCONFIG_NAMES):
132131
raise ValueError(
133-
f"Invalid sysconfig data name '{data_name}'.",
134-
SYSCONFIG_NAMES
132+
f"Invalid sysconfig data name '{data_name}'.", SYSCONFIG_NAMES
135133
)
136134
filename = data_name + ".py"
137135
return args.builddir / filename
@@ -142,20 +140,26 @@ def create_stdlib_zip(
142140
*,
143141
optimize: int = 0,
144142
) -> None:
143+
def filterfunc(filename: str) -> bool:
144+
pathname = pathlib.Path(filename).resolve()
145+
return pathname not in args.omit_files_absolute
146+
145147
with zipfile.PyZipFile(
146-
args.wasm_stdlib_zip, mode="w", compression=args.compression, optimize=optimize
148+
args.wasm_stdlib_zip,
149+
mode="w",
150+
compression=args.compression,
151+
optimize=optimize,
147152
) as pzf:
148153
if args.compresslevel is not None:
149154
pzf.compresslevel = args.compresslevel
150155
pzf.writepy(args.sysconfig_data)
151156
for entry in sorted(args.srcdir_lib.iterdir()):
157+
entry = entry.resolve()
152158
if entry.name == "__pycache__":
153159
continue
154-
if entry in args.omit_files_absolute:
155-
continue
156160
if entry.name.endswith(".py") or entry.is_dir():
157161
# writepy() writes .pyc files (bytecode).
158-
pzf.writepy(entry)
162+
pzf.writepy(entry, filterfunc=filterfunc)
159163

160164

161165
def detect_extension_modules(args: argparse.Namespace):
@@ -236,7 +240,9 @@ def main():
236240
if not extmods.get(modname):
237241
omit_files.extend(modfiles)
238242

239-
args.omit_files_absolute = {args.srcdir_lib / name for name in omit_files}
243+
args.omit_files_absolute = {
244+
(args.srcdir_lib / name).resolve() for name in omit_files
245+
}
240246

241247
# Empty, unused directory for dynamic libs, but required for site initialization.
242248
args.wasm_dynload.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)
0