Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9119af7
fix(install): preview an SDK install without preparing Python
jussielo-amd Nov 5, 2026
e8a2922
fix(install): refuse a dry run for a managed Python the install would…
jussielo-amd Nov 5, 2026
1936bce
test(e2e): give runtime-22 and runtime-23 a cache folder of their own
jussielo-amd Nov 5, 2026
2b1fd04
fix(install): read every spelling of a managed Python version in a dr…
jussielo-amd Nov 5, 2026
794081a
test(e2e): present the uv log, not the cache folder, as runtime-22's …
jussielo-amd Nov 5, 2026
56179c6
Merge origin/main into fix-install-sdk-dry-run-without-side-effects
jussielo-amd Nov 5, 2026
87ea1ce
Merge origin/main into fix-install-sdk-dry-run-without-side-effects
jussielo-amd Nov 5, 2026
f342fce
Merge origin/main into fix-install-sdk-dry-run-without-side-effects
jussielo-amd Nov 5, 2026
1177a6b
fix(install): print a dry run's Python prediction only after the deci…
jussielo-amd Nov 5, 2026
72551d7
docs: limit the dry run's no-uv guarantee to the canonical layout
jussielo-amd Nov 5, 2026
4ef1703
docs(install): make python_tag_for_version's comment match what it reads
jussielo-amd Nov 6, 2026
148f9fb
refactor(install): word a preview's unchecked-tag caveat in one place
jussielo-amd Nov 6, 2026
c5ea04f
refactor(install): name a Python launcher's source with an enum
jussielo-amd Nov 6, 2026
41f30a1
refactor(install): let the Python resolver's environment carry the ma…
jussielo-amd Nov 6, 2026
8f93821
test(install): run the preview's Python decision on every platform
jussielo-amd Nov 6, 2026
869b8cb
refactor(install): name whether a preview could check a Python's whee…
jussielo-amd Nov 6, 2026
93c6908
test(install): pin the wording of the unusable-Python findings for an…
jussielo-amd Nov 6, 2026
6176347
refactor(install): print the unusable-Python findings from one place
jussielo-amd Nov 6, 2026
afbb38c
docs: say which lane covers the Windows preview and that the previewe…
jussielo-amd Nov 6, 2026
fc2fa6e
docs: wrap two over-long lines in the install sdk dry-run notes
jussielo-amd Nov 6, 2026
99b7ed5
ROCMAI-872: keep the update check from preparing a managed Python
jussielo-amd Nov 6, 2026
be3ae81
Merge origin/main into fix-update-check-prepares-no-python
jussielo-amd Nov 6, 2026
96f121a
ROCMAI-872: state what the update and SDK preview tools do and do not…
jussielo-amd Nov 6, 2026
cd2d258
Merge origin/main into fix-update-check-prepares-no-python
jussielo-amd Nov 6, 2026
77191ae
Merge origin/main into fix-update-check-prepares-no-python
jussielo-amd Nov 6, 2026
b5c49b2
ROCMAI-872: pin on every platform that a --dry-run takes the check an…
jussielo-amd Nov 9, 2026
9000afa
ROCMAI-872: say why a --apply --dry-run does not print the plan's pyt…
jussielo-amd Nov 9, 2026
1216573
ROCMAI-872: describe plan_python_launcher and the update note in the …
jussielo-amd Nov 9, 2026
5e630fc
ROCMAI-872: list RestoredEnv in the therock/test_support.rs architect…
jussielo-amd Nov 9, 2026
a623dc5
ROCMAI-872: describe the update check and its python_note in the upda…
jussielo-amd Nov 9, 2026
4cba499
Merge origin/main into fix-update-check-prepares-no-python
jussielo-amd Nov 9, 2026
8e499e6
Merge origin/main into fix-update-check-prepares-no-python
jussielo-amd Nov 9, 2026
cf785f1
ROCMAI-872: say what the update check does with uv and Python now tha…
jussielo-amd Nov 9, 2026
06a5edf
Merge origin/main into fix-update-check-prepares-no-python
jussielo-amd Nov 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/rocm/src/therock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ use self::source::{
requested_source_layout, select_source_layout,
};
pub(crate) use self::update::{
maybe_refresh_startup_update_check, render_update_json, render_update_report,
runtime_update_plan,
RuntimeUpdatePlan, maybe_refresh_startup_update_check, render_update_json,
render_update_report, runtime_update_check, runtime_update_plan,
};
pub(crate) use self::version::runtime_version_display;
use self::version::{
Expand Down
155 changes: 114 additions & 41 deletions apps/rocm/src/therock/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ pub(super) fn python_for_install(
Ok(python)
}

/// The interpreter a *preview* of the install reports, found without preparing
/// one.
/// The interpreter a *preview* of the install, or an update check, reports,
/// found without preparing one.
///
/// [`resolve_python_launcher`] ends by downloading a managed `uv`, having it
/// install Python, and saving that Python's path in the configuration when no
Expand All @@ -538,7 +538,10 @@ pub(super) fn python_for_install(
/// resolution raises before that step (an unusable `ROCM_CLI_PYTHON`, a
/// disabled managed bootstrap) is raised here too, so a preview never succeeds
/// on a host where the install would refuse.
fn plan_python_launcher(paths: &AppPaths, requirement: PythonRequirement) -> Result<PlannedPython> {
pub(super) fn plan_python_launcher(
paths: &AppPaths,
requirement: PythonRequirement,
) -> Result<PlannedPython> {
let env = python_resolver_env_override().unwrap_or_else(PythonResolverEnv::from_process_env);
plan_python_launcher_in(paths, &env, requirement)
}
Expand Down Expand Up @@ -655,6 +658,28 @@ impl PlannedPython {
}
}

/// The `python_note:` line of an update check, in the same terms as
/// [`Self::note`] but for the step an update would take. An update check
/// needs the interpreter's wheel tag to read the index, and a host with no
/// interpreter gets it from the one the layout requires, so this line is how
/// the check says it did not go and prepare one. Built from the decision, as
/// the preview's is.
pub(super) fn update_note(&self) -> Option<String> {
match self {
Self::Ready(_) => None,
Self::WouldPrepareManaged {
version,
requirement,
tag_check,
} => {
let unchecked = unchecked_tag_caveat(*tag_check, *requirement);
Some(format!(
"no usable Python was found; updating would use uv to install managed Python {version}{unchecked} and save its path in the configuration, which this check did not do"
))
}
}
}

/// The progress line that names the chosen interpreter: the one an install
/// goes on with, or, for a preview on a host with no usable Python, what a
/// real install would prepare. It is the only line that predicts the
Expand Down Expand Up @@ -988,7 +1013,7 @@ fn python_venv_probe_temp_root() -> Result<PathBuf> {
mod tests {
use super::*;
use crate::test_support::PROCESS_ENV_TEST_LOCK;
use crate::therock::test_support::test_paths;
use crate::therock::test_support::{RestoredEnv, test_paths};

#[cfg(unix)]
fn write_fake_python_with_venv(dir: &Path, name: &str) -> Result<PathBuf> {
Expand Down Expand Up @@ -1410,43 +1435,6 @@ exit 1

// ---- a dry run prepares no Python ----------------------------------------

/// Process environment variables set for one test and restored on drop.
/// Every caller holds `PROCESS_ENV_TEST_LOCK` for as long as it holds this.
struct RestoredEnv(Vec<(&'static str, Option<std::ffi::OsString>)>);

impl RestoredEnv {
#[allow(unsafe_code)] // std::env::set_var is unsafe in edition 2024
fn set(vars: &[(&'static str, Option<&Path>)]) -> Self {
let saved = vars
.iter()
.map(|(key, _)| (*key, std::env::var_os(key)))
.collect();
for (key, value) in vars {
unsafe {
match value {
Some(value) => std::env::set_var(key, value),
None => std::env::remove_var(key),
}
}
}
Self(saved)
}
}

impl Drop for RestoredEnv {
#[allow(unsafe_code)] // std::env::set_var is unsafe in edition 2024
fn drop(&mut self) {
for (key, value) in self.0.drain(..) {
unsafe {
match value {
Some(value) => std::env::set_var(key, value),
None => std::env::remove_var(key),
}
}
}
}
}

/// A `uv` that records its arguments in `marker` and then fails. A host that
/// reaches it has gone on to prepare a managed Python; failing keeps a test
/// that does reach it from going on to the network.
Expand Down Expand Up @@ -1541,6 +1529,16 @@ exit 1
)
}

/// What an update check goes on with, searching only this host's folder.
fn plan_for_update_check(&self) -> Result<PlannedPython> {
let _resolver = OverridePythonResolverEnv::new(PythonResolverEnv {
python_override: None,
search_dirs: vec![self.search_dir.clone()],
..PythonResolverEnv::from_process_env()
});
plan_python_launcher(&self.paths, python_requirement(SourceLayout::Canonical))
}

fn uv_was_run(&self) -> bool {
self.uv_marker.exists()
}
Expand Down Expand Up @@ -2300,6 +2298,81 @@ exit 1
Ok(())
}

/// An update check reads the index by the interpreter's wheel tag. On a host
/// with no interpreter that tag is the one the layout requires, which a real
/// update would prepare an interpreter to match, so the check needs nothing
/// prepared. The note it prints says so, and the folders agree; the same host
/// DOES reach `uv` for the install, so an unrun stand-in means the check
/// stayed out of it. The Gherkin scenario `update-09` drives the same case
/// through the built binary.
#[cfg(unix)]
#[test]
fn an_update_check_with_no_usable_python_reads_the_required_tag_and_prepares_nothing()
-> Result<()> {
if current_platform_wheel_tags().is_err() {
return Ok(());
}
let host = PythonHost::new("python-update-check-none")?;
let requirement = python_requirement(SourceLayout::Canonical);

let planned = host.plan_for_update_check()?;

let compatibility = planned.wheel_compatibility()?;
assert_eq!(compatibility.python_tag, requirement.tag);
assert!(!compatibility.platform_tags.is_empty());
assert_eq!(
planned.update_note().as_deref(),
Some(
"no usable Python was found; updating would use uv to install managed Python 3.12 and save its path in the configuration, which this check did not do"
)
);
assert!(!host.uv_was_run(), "the update check ran uv");
assert_eq!(
snapshot(&host.paths),
Vec::<PathBuf>::new(),
"the update check created files or folders under the config, data or cache folder"
);

// Control: the install on the same host does reach `uv`.
assert!(host.python_for_install(false).is_err());
assert!(
host.uv_was_run(),
"the stand-in uv is not reachable, so the checks above prove nothing"
);
Ok(())
}

/// A usable interpreter needs no note, and a managed Python whose tag cannot
/// be read off its version says so in the update note as in the preview's.
#[cfg(unix)]
#[test]
fn an_update_note_is_absent_for_a_usable_python_and_flags_an_unreadable_tag() -> Result<()> {
if current_platform_wheel_tags().is_err() {
return Ok(());
}
let host = PythonHost::new("python-update-note")?;
{
let _unreadable = RestoredEnv::set(&[(
"ROCM_CLI_MANAGED_PYTHON_VERSION",
Some(Path::new("pypy@3.10")),
)]);
let planned = host.plan_for_update_check()?;
let note = planned.update_note().expect("nothing was prepared");
assert!(
note.contains("managed Python pypy@3.10 (its wheel tag cannot be checked until it is installed; cp312 is required)")
&& note.ends_with("which this check did not do"),
"{note}"
);
}

write_fake_python_with_venv(&host.search_dir, "python3")?;
let planned = host.plan_for_update_check()?;
assert!(matches!(planned, PlannedPython::Ready(_)), "{planned:?}");
assert_eq!(planned.update_note(), None);
assert!(!host.uv_was_run());
Ok(())
}

/// The version-to-tag reading the preview's refusal rests on, and that it is
/// the same rule `python_launcher_install_ready` applies (same message).
#[test]
Expand Down
40 changes: 39 additions & 1 deletion apps/rocm/src/therock/test_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,45 @@ use crate::runtime_registry::{InstalledRuntimeManifest, runtime_manifest_path};
use anyhow::Result;
use rocm_core::AppPaths;
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};

/// Process environment variables set for one test and restored on drop. Every
/// caller holds `PROCESS_ENV_TEST_LOCK` for as long as it holds this.
pub(super) struct RestoredEnv(Vec<(&'static str, Option<std::ffi::OsString>)>);

impl RestoredEnv {
/// Sets (`Some`) or removes (`None`) each variable, remembering what it was.
#[allow(unsafe_code)] // std::env::set_var is unsafe in edition 2024
pub(super) fn set(vars: &[(&'static str, Option<&Path>)]) -> Self {
let saved = vars
.iter()
.map(|(key, _)| (*key, std::env::var_os(key)))
.collect();
for (key, value) in vars {
unsafe {
match value {
Some(value) => std::env::set_var(key, value),
None => std::env::remove_var(key),
}
}
}
Self(saved)
}
}

impl Drop for RestoredEnv {
#[allow(unsafe_code)] // std::env::set_var is unsafe in edition 2024
fn drop(&mut self) {
for (key, value) in self.0.drain(..) {
unsafe {
match value {
Some(value) => std::env::set_var(key, value),
None => std::env::remove_var(key),
}
}
}
}
}

pub(super) fn family_for_test(family: &str, raw_arch: Option<&str>) -> FamilyResolution {
FamilyResolution {
Expand Down
Loading
Loading