astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
24.47k stars 709 forks source link

Cryptic error for `python -m uv pip compile --python-version x.y.z` when using the Windows app store Python app #4522

Closed ncoghlan closed 4 months ago

ncoghlan commented 4 months ago

I am running the PSF's CPython build from the Windows app store in order to benefit from the automatic updates.

This build omits the Python launcher for Windows, so the py --list-paths command isn't available.

This results in a cryptic error when requesting transitive dependency resolution for a Python version other than the one used to invoke uv:

> python -m uv pip compile --python-version 3.11 requirements.in
error: The `py` launcher could not be found.

This arises even if source builds are disabled (so there shouldn't be any need to extract dynamic runtime dependency information from a source build):

> python -m uv pip compile --no-build --python-version 3.11 requirements.in
error: The `py` launcher could not be found.

The actual error in these commands was that the --python command line option to specify the target Python runtime was missing (I had been mislead by testing on Linux, which had used Fedora's python3.11 alternative Python install to satisfy the 3.11 version check - it would actually be handy if there was a --toolchain-preference only-specified option to keep uv from trying to autodiscover Python runtimes).

charliermarsh commented 4 months ago

This arises even if source builds are disabled (so there shouldn't be any need to extract dynamic runtime dependency information from a source build)

FWIW I don't think this part is that relevant -- we need to query the Python interpreter to extract the platform markers regardless.

charliermarsh commented 4 months ago

I'm guessing that should be non-fatal or something but defer to @zanieb who owns Python discovery.

ncoghlan commented 4 months ago

FWIW I don't think this part is that relevant -- we need to query the Python interpreter to extract the platform markers regardless.

That's a fair point, so I think that just becomes a small comment on the README.md text about Python discovery (it gives slightly misleading info on why uv needs a target Python with the right version available)

zanieb commented 4 months ago

We're in the process of rewriting all that documentation. I'll improve that and add more context to that error message, thanks!

zanieb commented 4 months ago

I put up a fix at #4620, let me know if you get a chance to test it.

@ncoghlan Regarding

--toolchain-preference only-specified option to keep uv from trying to autodiscover Python runtimes).

In this case, you'd expect us to error whenever --python wasn't included?