mirror of https://github.com/astral-sh/uv
Re-compile when `--compile` is passed to an install operation (#9378)
## Summary Closes https://github.com/astral-sh/uv/issues/9377.
This commit is contained in:
parent
1343b167f9
commit
35ff802e3e
|
|
@ -440,7 +440,12 @@ pub(crate) async fn install(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
if remote.is_empty() && cached.is_empty() && reinstalls.is_empty() && extraneous.is_empty() {
|
if remote.is_empty()
|
||||||
|
&& cached.is_empty()
|
||||||
|
&& reinstalls.is_empty()
|
||||||
|
&& extraneous.is_empty()
|
||||||
|
&& !compile
|
||||||
|
{
|
||||||
logger.on_audit(resolution.len(), start, printer)?;
|
logger.on_audit(resolution.len(), start, printer)?;
|
||||||
return Ok(Changelog::default());
|
return Ok(Changelog::default());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3292,6 +3292,55 @@ fn compile() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Re-install with bytecode compilation.
|
||||||
|
#[test]
|
||||||
|
fn recompile() -> Result<()> {
|
||||||
|
let context = TestContext::new("3.12");
|
||||||
|
|
||||||
|
let requirements_txt = context.temp_dir.child("requirements.txt");
|
||||||
|
requirements_txt.write_str("MarkupSafe==2.1.3")?;
|
||||||
|
|
||||||
|
uv_snapshot!(context.pip_sync()
|
||||||
|
.arg("requirements.txt")
|
||||||
|
.arg("--strict"), @r###"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Resolved 1 package in [TIME]
|
||||||
|
Prepared 1 package in [TIME]
|
||||||
|
Installed 1 package in [TIME]
|
||||||
|
+ markupsafe==2.1.3
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
|
||||||
|
uv_snapshot!(context.pip_sync()
|
||||||
|
.arg("requirements.txt")
|
||||||
|
.arg("--compile")
|
||||||
|
.arg("--strict"), @r###"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Resolved 1 package in [TIME]
|
||||||
|
Bytecode compiled 3 files in [TIME]
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(context
|
||||||
|
.site_packages()
|
||||||
|
.join("markupsafe")
|
||||||
|
.join("__pycache__")
|
||||||
|
.join("__init__.cpython-312.pyc")
|
||||||
|
.exists());
|
||||||
|
|
||||||
|
context.assert_command("import markupsafe").success();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Raise an error when an editable's `Requires-Python` constraint is not met.
|
/// Raise an error when an editable's `Requires-Python` constraint is not met.
|
||||||
#[test]
|
#[test]
|
||||||
fn requires_python_editable() -> Result<()> {
|
fn requires_python_editable() -> Result<()> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue