Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow self-depedencies in the dev section #7943

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions crates/uv/src/commands/project/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,13 @@ pub(crate) async fn add(
};

// If any of the requirements are self-dependencies, bail.
if matches!(
dependency_type,
DependencyType::Production | DependencyType::Dev
) {
if matches!(dependency_type, DependencyType::Production) {
if let Target::Project(project, _) = &target {
if let Some(project_name) = project.project_name() {
for requirement in &requirements {
if requirement.name == *project_name {
bail!(
"Requirement name `{}` matches project name `{}`, but self-dependencies are not permitted. If your project name (`{}`) is shadowing that of a third-party dependency, consider renaming the project.",
"Requirement name `{}` matches project name `{}`, but self-dependencies are not permitted without the `--dev` or `--optional` flags. If your project name (`{}`) is shadowing that of a third-party dependency, consider renaming the project.",
requirement.name.cyan(),
project_name.cyan(),
project_name.cyan(),
Expand Down
17 changes: 13 additions & 4 deletions crates/uv/tests/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4959,7 +4959,7 @@ fn add_self() -> Result<()> {
----- stdout -----

----- stderr -----
error: Requirement name `anyio` matches project name `anyio`, but self-dependencies are not permitted. If your project name (`anyio`) is shadowing that of a third-party dependency, consider renaming the project.
error: Requirement name `anyio` matches project name `anyio`, but self-dependencies are not permitted without the `--dev` or `--optional` flags. If your project name (`anyio`) is shadowing that of a third-party dependency, consider renaming the project.
"###);

let pyproject_toml = context.temp_dir.child("pyproject.toml");
Expand Down Expand Up @@ -5023,12 +5023,16 @@ fn add_self() -> Result<()> {

// And recursive development dependencies
uv_snapshot!(context.filters(), context.add().arg("anyio[types]").arg("--dev"), @r###"
success: false
exit_code: 2
success: true
exit_code: 0
----- stdout -----

----- stderr -----
error: Requirement name `anyio` matches project name `anyio`, but self-dependencies are not permitted. If your project name (`anyio`) is shadowing that of a third-party dependency, consider renaming the project.
Resolved 2 packages in [TIME]
Prepared 1 package in [TIME]
Uninstalled 1 package in [TIME]
Installed 1 package in [TIME]
~ anyio==0.1.0 (from file://[TEMP_DIR]/)
"###);

let pyproject_toml = context.read("pyproject.toml");
Expand All @@ -5054,6 +5058,11 @@ fn add_self() -> Result<()> {
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"

[tool.uv]
dev-dependencies = [
"anyio[types]",
]

[tool.uv.sources]
anyio = { workspace = true }
"###
Expand Down
Loading