astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.6k stars 466 forks source link

Respect `.python-version` in Rye builds #1250

Closed charliermarsh closed 2 months ago

charliermarsh commented 2 months ago

Summary

Today, rye build uses the bootstrapped (or "self") environment, which means built wheels reflect the version from the bootstrapped environment, rather than the user's Python preference.

This PR changes build to instead create an ephemeral build environment based on the requested Python version (then install and run build in that environment).

Creating and populating that ephemeral build environment is extremely fast with uv; there's virtually no overhead.

Closes https://github.com/astral-sh/rye/issues/1152. Closes https://github.com/astral-sh/rye/issues/1248.

Test Plan

b0o commented 2 months ago

Awesome! Seems to be working as expected.