uv_build: Allow non-standard entrypoint names (#14867)

It seems that non-standard entrypoints are still widely used,
downgrading the error to a tracing warning.

Fixes #14442

---------

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
This commit is contained in:
konsti 2025-07-24 14:12:36 +02:00 committed by GitHub
parent 3b59515614
commit 1150de3fc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,7 +7,7 @@ use std::str::FromStr;
use itertools::Itertools;
use serde::Deserialize;
use tracing::{debug, trace};
use tracing::{debug, trace, warn};
use version_ranges::Ranges;
use walkdir::WalkDir;
@ -54,10 +54,6 @@ pub enum ValidationError {
"Entrypoint groups must consist of letters and numbers separated by dots, invalid group: `{0}`"
)]
InvalidGroup(String),
#[error(
"Entrypoint names must consist of letters, numbers, dots, underscores and dashes; invalid name: `{0}`"
)]
InvalidName(String),
#[error("Use `project.scripts` instead of `project.entry-points.console_scripts`")]
ReservedScripts,
#[error("Use `project.gui-scripts` instead of `project.entry-points.gui_scripts`")]
@ -620,12 +616,14 @@ impl PyProjectToml {
let _ = writeln!(writer, "[{group}]");
for (name, object_reference) in entries {
// More strict than the spec, we enforce the recommendation
if !name
.chars()
.all(|c| c.is_alphanumeric() || c == '.' || c == '-' || c == '_')
{
return Err(ValidationError::InvalidName(name.to_string()));
warn!(
"Entrypoint names should consist of letters, numbers, dots, underscores and \
dashes; non-compliant name: `{name}`"
);
}
// TODO(konsti): Validate that the object references are valid Python identifiers.
@ -1403,16 +1401,6 @@ mod tests {
assert_snapshot!(script_error(&contents), @"Entrypoint groups must consist of letters and numbers separated by dots, invalid group: `a@b`");
}
#[test]
fn invalid_entry_point_name() {
let contents = extend_project(indoc! {r#"
[project.scripts]
"a@b" = "bar"
"#
});
assert_snapshot!(script_error(&contents), @"Entrypoint names must consist of letters, numbers, dots, underscores and dashes; invalid name: `a@b`");
}
#[test]
fn invalid_entry_point_conflict_scripts() {
let contents = extend_project(indoc! {r#"