Skip to content

Commit b27f63b

Browse files
committed
Merge branch 'main' into emscripten-dependencies
2 parents 9fef69b + 91e1312 commit b27f63b

File tree

6 files changed

+43
-24
lines changed

6 files changed

+43
-24
lines changed

Doc/c-api/unicode.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ object.
18671867
On success, return ``0``.
18681868
On error, set an exception, leave the writer unchanged, and return ``-1``.
18691869
1870-
.. c:function:: int PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *writer, Py_UCS4 *str, Py_ssize_t size)
1870+
.. c:function:: int PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *writer, const Py_UCS4 *str, Py_ssize_t size)
18711871
18721872
Writer the UCS4 string *str* into *writer*.
18731873

Include/cpython/unicodeobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ PyAPI_FUNC(int) PyUnicodeWriter_WriteWideChar(
496496
Py_ssize_t size);
497497
PyAPI_FUNC(int) PyUnicodeWriter_WriteUCS4(
498498
PyUnicodeWriter *writer,
499-
Py_UCS4 *str,
499+
const Py_UCS4 *str,
500500
Py_ssize_t size);
501501

502502
PyAPI_FUNC(int) PyUnicodeWriter_WriteStr(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:c:func:`PyUnicodeWriter_WriteUCS4` now accepts a pointer to a constant buffer
2+
of ``Py_UCS4``.

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,7 @@ _PyUnicode_FromUCS4(const Py_UCS4 *u, Py_ssize_t size)
22242224

22252225
int
22262226
PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *pub_writer,
2227-
Py_UCS4 *str,
2227+
const Py_UCS4 *str,
22282228
Py_ssize_t size)
22292229
{
22302230
_PyUnicodeWriter *writer = (_PyUnicodeWriter*)pub_writer;

Platforms/emscripten/__main__.py

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -413,15 +413,46 @@ def make_mpdec(context, working_dir):
413413
write_library_config(prefix, "mpdec", mpdec_config, context.quiet)
414414

415415

416-
def make_dependencies(context, working_dir):
417-
make_emscripten_libffi(context, working_dir)
418-
make_mpdec(context, working_dir)
416+
def make_dependencies(context):
417+
make_emscripten_libffi(context)
418+
make_mpdec(context)
419+
420+
421+
def calculate_node_path():
422+
node_version = os.environ.get("PYTHON_NODE_VERSION", None)
423+
if node_version is None:
424+
node_version = load_config_toml()["node-version"]
425+
426+
subprocess.run(
427+
[
428+
"bash",
429+
"-c",
430+
f"source ~/.nvm/nvm.sh && nvm install {node_version}",
431+
],
432+
check=True,
433+
)
434+
435+
res = subprocess.run(
436+
[
437+
"bash",
438+
"-c",
439+
f"source ~/.nvm/nvm.sh && nvm which {node_version}",
440+
],
441+
text=True,
442+
capture_output=True,
443+
check=True,
444+
)
445+
return res.stdout.strip()
419446

420447

421448
@subdir("host_dir", clean_ok=True)
422449
def configure_emscripten_python(context, working_dir):
423450
"""Configure the emscripten/host build."""
424451
validate_emsdk_version(context.emsdk_cache)
452+
host_runner = context.host_runner
453+
if host_runner is None:
454+
host_runner = calculate_node_path()
455+
425456
paths = context.build_paths
426457
config_site = os.fsdecode(EMSCRIPTEN_DIR / "config.site-wasm32-emscripten")
427458

@@ -440,19 +471,6 @@ def configure_emscripten_python(context, working_dir):
440471
)
441472
if pydebug:
442473
sysconfig_data += "-pydebug"
443-
444-
host_runner = context.host_runner
445-
if node_version := os.environ.get("PYTHON_NODE_VERSION", None):
446-
res = subprocess.run(
447-
[
448-
"bash",
449-
"-c",
450-
f"source ~/.nvm/nvm.sh && nvm which {node_version}",
451-
],
452-
text=True,
453-
capture_output=True,
454-
)
455-
host_runner = res.stdout.strip()
456474
pkg_config_path_dir = (paths["prefix_dir"] / "lib/pkgconfig/").resolve()
457475
env_additions = {
458476
"CONFIG_SITE": config_site,
@@ -618,8 +636,6 @@ def add_cross_build_dir_option(subcommand):
618636

619637

620638
def main():
621-
default_host_runner = "node"
622-
623639
parser = argparse.ArgumentParser()
624640
subcommands = parser.add_subparsers(dest="subcommand")
625641

@@ -755,10 +771,10 @@ def main():
755771
subcommand.add_argument(
756772
"--host-runner",
757773
action="store",
758-
default=default_host_runner,
774+
default=None,
759775
dest="host_runner",
760-
help="Command template for running the emscripten host"
761-
f"`{default_host_runner}`)",
776+
help="Command template for running the emscripten host "
777+
"(default: use nvm to install the node version specified in config.toml)",
762778
)
763779

764780
context = parser.parse_args()

Platforms/emscripten/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This allows for blanket copying of the Emscripten build code between supported
33
# Python versions.
44
emscripten-version = "4.0.12"
5+
node-version = "24"
56

67
[libffi]
78
url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz"

0 commit comments

Comments
 (0)