uv/crates/puffin-interpreter/src
Charlie Marsh 6e18e56789
Adjust markers to match target Python version (#909)
## Summary

This PR ensures that when the user passes in `--python-version`, we
adjust the _markers_ to match the target version, thus forcing us to
select compatible wheels for the `--python-version`, rather than the
installed version.

## Context

Let's call Python 3.10 the "installed" environment and Python 3.12 the
"target" environment. For each version, we have _both_ a Python version
(to match against `Requires-Python`) and a set of tags (to match against
wheels).

The rules for resolution are as follows...

- For each package, for each version, we try to find the "best
candidate" for resolution and installation.
- We first look for a wheel that's compatible with the _target_
environment. This requires testing against both the `Requires-Python`
and the markers. (We won't have to build or run this code, so the
_installed_ version is irrelevant.) **(This PR corrects _this_ bullet --
previously, we validated against the _installed_ markers, rather than
the target markers.)**
- If we can't find a compatible wheel, we accept any _incompatible_
wheel as long as there's a source distribution. The source distribution
_must_ be compatible with the target environment. (We won't have to
build or run this code, so the _installed_ version is irrelevant.)
- If there are no wheels, then the source distribution must be
compatible with _both_ the installed and target environments, since we
need to build it.

This is all true for the top-level resolution. When we perform a
sub-resolution (when resolving the build dependencies of a source
distribution), we should _only_ use the installed environment, and
ignore the target environment, since we assume that the dependencies
will be the same in both environments once built -- so our goal is
"just" to build the distribution, without concern for which build
dependencies it uses.

Closes https://github.com/astral-sh/puffin/issues/883.
2024-01-14 15:39:15 +00:00
..
cfg.rs Preserve seed packages for non-Puffin-created virtualenvs (#535) 2023-12-04 09:31:00 -05:00
get_interpreter_info.py Use `sys.executable` as python root path (#431) 2023-11-16 12:16:49 +01:00
interpreter.rs Adjust markers to match target Python version (#909) 2024-01-14 15:39:15 +00:00
lib.rs Cleanup deps and docs (#882) 2024-01-11 10:43:40 +00:00
python_platform.rs Unify python interpreter abstractions (#178) 2023-10-25 20:11:36 +00:00
python_version.rs Adjust markers to match target Python version (#909) 2024-01-14 15:39:15 +00:00
virtual_env.rs Cache `Tags` on `Interpreter` (#726) 2023-12-25 13:41:10 +00:00