mirror of https://github.com/astral-sh/uv
Disallow multiple pylock.toml files
This commit is contained in:
parent
2d8dda34b4
commit
25f0391bc7
|
|
@ -254,22 +254,19 @@ impl RequirementsSpecification {
|
||||||
.iter()
|
.iter()
|
||||||
.any(|source| matches!(source, RequirementsSource::PylockToml(..)))
|
.any(|source| matches!(source, RequirementsSource::PylockToml(..)))
|
||||||
{
|
{
|
||||||
if requirements
|
if requirements.len() > 1 {
|
||||||
.iter()
|
|
||||||
.any(|source| !matches!(source, RequirementsSource::PylockToml(..)))
|
|
||||||
{
|
|
||||||
return Err(anyhow::anyhow!(
|
return Err(anyhow::anyhow!(
|
||||||
"Cannot specify additional requirements alongside a `pylock.toml` file",
|
"Cannot specify additional requirements with a `pylock.toml` file",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if !constraints.is_empty() {
|
if !constraints.is_empty() {
|
||||||
return Err(anyhow::anyhow!(
|
return Err(anyhow::anyhow!(
|
||||||
"Cannot specify additional requirements with a `pylock.toml` file"
|
"Cannot specify constraints with a `pylock.toml` file"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if !overrides.is_empty() {
|
if !overrides.is_empty() {
|
||||||
return Err(anyhow::anyhow!(
|
return Err(anyhow::anyhow!(
|
||||||
"Cannot specify constraints with a `pylock.toml` file"
|
"Cannot specify overrides with a `pylock.toml` file"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if !groups.is_empty() {
|
if !groups.is_empty() {
|
||||||
|
|
|
||||||
|
|
@ -10730,6 +10730,64 @@ fn change_layout_custom_directory() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pep_751_reject_additional_requirements() -> Result<()> {
|
||||||
|
let context = TestContext::new("3.12");
|
||||||
|
|
||||||
|
context.temp_dir.child("pylock.toml").touch()?;
|
||||||
|
context.temp_dir.child("requirements.txt").touch()?;
|
||||||
|
|
||||||
|
// Disallow `pylock.toml` and `requirements.txt` in a single command.
|
||||||
|
uv_snapshot!(context.filters(), context.pip_install()
|
||||||
|
.arg("--preview")
|
||||||
|
.arg("-r")
|
||||||
|
.arg("pylock.toml")
|
||||||
|
.arg("-r")
|
||||||
|
.arg("requirements.txt"), @r"
|
||||||
|
success: false
|
||||||
|
exit_code: 2
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
error: Cannot specify additional requirements with a `pylock.toml` file
|
||||||
|
"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Disallow multiple `pylock.toml` files in a single command.
|
||||||
|
uv_snapshot!(context.filters(), context.pip_install()
|
||||||
|
.arg("--preview")
|
||||||
|
.arg("-r")
|
||||||
|
.arg("pylock.toml")
|
||||||
|
.arg("-r")
|
||||||
|
.arg("pylock.toml"), @r"
|
||||||
|
success: false
|
||||||
|
exit_code: 2
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
error: Cannot specify additional requirements with a `pylock.toml` file
|
||||||
|
"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Disallow `pylock.toml` and a constraint in a single command.
|
||||||
|
uv_snapshot!(context.filters(), context.pip_install()
|
||||||
|
.arg("--preview")
|
||||||
|
.arg("-r")
|
||||||
|
.arg("pylock.toml")
|
||||||
|
.arg("-c")
|
||||||
|
.arg("requirements.txt"), @r"
|
||||||
|
success: false
|
||||||
|
exit_code: 2
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
error: Cannot specify constraints with a `pylock.toml` file
|
||||||
|
"
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pep_751_install_registry_wheel() -> Result<()> {
|
fn pep_751_install_registry_wheel() -> Result<()> {
|
||||||
let context = TestContext::new("3.12");
|
let context = TestContext::new("3.12");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue