Repository navigation
Description
Summary
When using uv on an aarch64 host to target an armv7 Python, platform_machine markers always evaluate to aarch64 (from uname -m) rather than reflecting the target interpreter's architecture. This means marker-conditional dependencies for armv7 are never selected.
Reproduction
Save the following script and run on an aarch64 Linux host:
#!/usr/bin/env bash
set -euo pipefail
# Reproducer for uv cross-architecture marker evaluation bug.
# Run on an aarch64 Linux host.
echo "=== Environment ==="
uname -m
uv --version
echo ""
echo "=== Install armv7 Python ==="
uv python install 3.11-armv7-gnueabihf
echo ""
echo "=== Set up test project ==="
WORKDIR=$(mktemp -d)
trap 'rm -rf "$WORKDIR"' EXIT
cd "$WORKDIR"
uv init marker-test
cd marker-test
cat > pyproject.toml << 'PYPROJECT'
[project]
name = "marker-test"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
"onnx==1.17.0; platform_machine == 'armv7l' or platform_machine == 'armv8l'",
"onnx==1.18.0; platform_machine != 'armv7l' and platform_machine != 'armv8l'",
]
[tool.uv.sources]
onnx = { index = "piwheels", marker = "platform_machine == 'armv7l' or platform_machine == 'armv8l'" }
[[tool.uv.index]]
name = "piwheels"
url = "https://www.piwheels.org/simple"
explicit = true
PYPROJECT
echo ""
echo "=== Bug 1: platform_machine markers use uname -m, not target interpreter ==="
echo "The venv uses an armv7 interpreter, but platform_machine evaluates to aarch64."
export UV_PYTHON=3.11-linux-armv7-gnu
rm -rf .venv uv.lock
uv venv
echo "Interpreter: $(file "$(realpath .venv/bin/python3)")"
echo "uname -m: $(uname -m)"
echo "python platform.machine(): $(.venv/bin/python3 -c 'import platform; print(platform.machine())')"
timeout 15 uv sync --no-install-project 2>&1 | grep -i onnx || true
echo ""
echo "Expected: onnx==1.17.0 (armv7 interpreter)"
echo "Actual: onnx==1.18.0 (marker matched aarch64 from uname -m)"
echo ""
echo "=== Bug 2: naming inconsistency ==="
echo "uv classifies the installed armv7 interpreter as armv7-gnu, but cannot install by that name:"
uv python install 3.11-linux-armv7-gnu 2>&1 || trueHere's the result of running it on my Raspberry Pi:
halidenightly@arm64-linux-3:~/tmp$ ./uv-bug-repro.sh
=== Environment ===
aarch64
uv 0.10.4
=== Install armv7 Python ===
any-3.11-any-armv7-gnueabihf is already installed
=== Set up test project ===
Initialized project `marker-test` at `/tmp/tmp.zQVcaJOtiS/marker-test`
=== Bug 1: platform_machine markers use uname -m, not target interpreter ===
The venv uses an armv7 interpreter, but platform_machine evaluates to aarch64.
Using CPython 3.11.14 interpreter at: /home/halidenightly/.local/bin/python3.11
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
Interpreter: /home/halidenightly/.local/share/uv/python/cpython-3.11.14-linux-armv7-gnueabihf/bin/python3.11: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=fdd8b587b24d23536885c259c87c7861c68c3f42, not stripped
uname -m: aarch64
python platform.machine(): aarch64
Building onnx==1.18.0
Expected: onnx==1.17.0 (armv7 interpreter)
Actual: onnx==1.18.0 (marker matched aarch64 from uname -m)
=== Bug 2: naming inconsistency ===
uv classifies the installed armv7 interpreter as armv7-gnu, but cannot install by that name:
error: No download found for request: cpython-3.11-linux-armv7-gnuExpected behavior
uv sync should resolve onnx==1.17.0 because the target Python is an armv7 binary.
Actual behavior
uv sync resolves onnx==1.18.0 because it evaluates platform_machine from uname -m (aarch64), which reflects the host kernel, not the target interpreter.
Note: platform.machine() returns the kernel architecture even from a 32-bit binary (it calls uname), so the issue is that uv should infer the target platform from the interpreter's ABI tags or sysconfig data rather than querying platform.machine().
Secondary issue: naming inconsistency
uv python install 3.11-armv7-gnueabihf installs successfully, but uv classifies the same binary on PATH as armv7-gnu. Requesting by the classified name fails:
$ uv python install 3.11-linux-armv7-gnu
error: No download found for request: cpython-3.11-linux-armv7-gnu
Environment
- uv 0.10.4
- Host: Ubuntu 22.04, aarch64 kernel
- Target: cpython-3.11.14-linux-armv7-gnueabihf (uv-managed)
Activity
konstin commentedon Feb 22, 2026
Thank you for the annotated reproducer!
What stands out to me is this part:
I'm not sure we can this that easily. PEP 508 define
platform_machineas the valueplatform.machine(), so the rest of the Python stack expects them to be the same. Theplatform.machine()docs don't say anything about how this is implemented, this is arguably either a bug in CPython or in the emulation layer.More practically, I think the problem is that you're not doing a cross install (
--python-platform), instead,UV_PYTHONlooks like a native Python interpreter to uv, so uv uses the "real" values from querying that Python interpreter, instead hardcoded values for the target platform. There's currently only 64-bit support for arm in--python-platform, though it's possible to add more platforms to it.alexreinking commentedon Feb 22, 2026
You're welcome! I try to write the bug reports I hope to receive myself 🙂
Yeah, this is why I went down this road at all. Actually, a few times I swear I made it work but I can't reliably reproduce the circumstances under which it did. Maybe there's some race to populate the uv interpreter cache or something? I couldn't figure it out.
Anyway, it would be really great to get some broader support in
--python-platform. In my real, non-reproducer, case, I'm trying to get Halide working on an armv8l Raspberry Pi (though armv7l wheels work just fine).I'm not afraid to get my hands dirty here and contribute, but I can't say I know Rust, let alone uv's codebase, very well. Maybe to start, I could gather more information for you? What would be helpful?
alexreinking commentedon Feb 23, 2026
Here's some more vexing behavior. Normally one should be able to override the behavior of
uname -mwith thesetarchcommand. I'll start by creating a new virtual environment with3.11-armv7-gnueabihf:Now I'll go ahead and check to make sure that my Python is the architecture I expect:
Looks good. Now let's print the architecture as I did above:
Frustrating, but we have
setarchto help out:Hmm. Some progress, but this isn't quite the arch I asked for. Hopefully tooling is smart enough to know armv8l is backwards compatible with armv7l. Just in case, I'll set up a quick
requirements.txtfile that should be tolerant to both markers:Now let's ask
uvto install these requirements:That's not the most surprising thing since we know now that Python still sees
aarch64as itsplatform_machine. So let's see what happens when we run undersetarch:It's somehow ignoring the
setarchenvironment. Let me grep verbose output forplatform_machineoraarchSo the ResolverEnvironment still has
aarch64somehow. Will get to the bottom of how/why.alexreinking commentedon Feb 23, 2026
Okay, I think there is also a cache invalidation bug! I don't know how
uvcaches interpreter info, but if I now run this, look, it says it would installonnx==1.17.0:I opened #18163 to track this.