Skip to content

gh-127405: Remove dead code in sysconfig._get_pybuilddir() #131935

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

Closed
wants to merge 17 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Lib/sysconfig/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _print_config_dict(d, stream):

def _get_pybuilddir():
pybuilddir = f'build/lib.{get_platform()}-{get_python_version()}'
if get_config_var('Py_DEBUG') == '1':
if get_config_var('Py_DEBUG'):
pybuilddir += '-pydebug'
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any way for this to be called, but I note that this behavior is tied to

pydebug = lib_dir.endswith("-pydebug")

I think this aspect of the WASM build is broken, and if this code can be deleted then perhaps that trail can too.

return pybuilddir

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove dead code in function ``sysconfig._get_pybuilddir``. Patch by Xuehai Pan.
2 changes: 1 addition & 1 deletion Tools/wasm/wasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def main():
# Make sure the stack size will work for a pydebug
# build.
# Use 16 MiB stack.
"--wasm max-wasm-stack=16777216 "
"--wasm max-wasm-stack=33554432 "
# Enable thread support; causes use of preview1.
#"--wasm threads=y --wasi threads=y "
# Map the checkout to / to load the stdlib from /Lib.
Expand Down
11 changes: 9 additions & 2 deletions Tools/wasm/wasm_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,17 @@ def _check_wasi() -> None:
# workaround for https://github.com/python/cpython/issues/95952
"HOSTRUNNER": (
"wasmtime run "
"--wasm max-wasm-stack=16777216 "
"--wasm max-wasm-stack=33554432 "
"--wasi preview2 "
"--dir {srcdir}::/ "
"--env PYTHONPATH=/{relbuilddir}/build/lib.wasi-wasm32-{version}:/Lib"
"--env PYTHONPATH="
+ ":".join(
(
"/{relbuilddir}/build/lib.wasi-wasm32-{version}-pydebug",
"/{relbuilddir}/build/lib.wasi-wasm32-{version}",
"/Lib",
)
)
),
"PATH": [WASI_SDK_PATH / "bin", os.environ["PATH"]],
},
Expand Down
5 changes: 2 additions & 3 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ then
dnl TODO: support other WASI runtimes
dnl wasmtime starts the process with "/" as CWD. For OOT builds add the
dnl directory containing _sysconfigdata to PYTHONPATH.
[WASI], [HOSTRUNNER='wasmtime run --wasm max-wasm-stack=16777216 --wasi preview2=n --env PYTHONPATH=/$(shell realpath --relative-to $(abs_srcdir) $(abs_builddir))/$(shell cat pybuilddir.txt):/Lib --dir $(srcdir)::/'],
[WASI], [HOSTRUNNER='wasmtime run --wasm max-wasm-stack=33554432 --wasi preview2=n --env PYTHONPATH=/$(shell realpath --relative-to $(abs_srcdir) $(abs_builddir))/$(shell cat pybuilddir.txt):/Lib --dir $(srcdir)::/'],
[HOSTRUNNER='']
)
fi
Expand Down Expand Up @@ -2420,7 +2420,7 @@ AS_CASE([$ac_sys_system],
dnl gh-117645: Set the memory size to 40 MiB, the stack size to 16 MiB,
dnl and move the stack first.
dnl https://github.com/WebAssembly/wasi-libc/issues/233
AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=16777216 -Wl,--stack-first -Wl,--initial-memory=41943040"])
AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=33554432 -Wl,--stack-first -Wl,--initial-memory=41943040"])
]
)

Expand Down
Loading