Skip to content

download_binaries doesn't set exec bit on Linux/macOS binary #740

@waltsims

Description

@waltsims

Summary

kwave.download_binaries writes the downloaded binary via urlretrieve without setting the executable bit. On Linux / macOS pip installs, the binary lands at 0644 and kspaceFirstOrder-CUDA --version fails with Permission denied (exit 126).

This has likely been latently broken for a long time — masked by either (a) users hitting the _is_binary_present cache path from a prior install where perms got set by pip install itself extracting an executable from a wheel, or (b) typical end users never running the binary directly (the cpp backend goes through subprocess.run which exposes the failure).

Reproduction

Fresh venv on Linux (Colab, Ubuntu 22.04):

pip install -q "k-wave-python==<some version pinning Linux binaries>"
BIN=$(python -c 'import kwave, os; print(os.path.join(kwave.BINARY_PATH, "kspaceFirstOrder-CUDA"))')
$BIN --version
# bash: ...: Permission denied
# exit=126

ls -l $BIN shows -rw-r--r--.

Fix

In kwave/__init__.py download_binaries, after urlretrieve(url, binary_filepath):

import stat
if PLATFORM != "windows":
    current = os.stat(binary_filepath).st_mode
    os.chmod(binary_filepath, current | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)

Surfaced while validating v1.4.0 binaries for v0.6.2 release (#739); needs to land before tag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions