From 99b0bc880bbd1ed536c8af0f631b94c35e474e77 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 9 Dec 2024 16:03:47 -0700 Subject: [PATCH] document uniqueness requirement for app names ...and provide a friendlier diagnostic when there's a conflict. Fixes #131 Signed-off-by: Joel Dice --- src/command.rs | 6 +++++- src/lib.rs | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/command.rs b/src/command.rs index 51516d0..88e5524 100644 --- a/src/command.rs +++ b/src/command.rs @@ -79,7 +79,11 @@ pub enum Command { #[derive(clap::Args, Debug)] pub struct Componentize { - /// The name of a Python module containing the app to wrap + /// The name of a Python module containing the app to wrap. + /// + /// Note that this should not match (any of) the world name(s) you are targeting since `componentize-py` will + /// generate code using those name(s), and Python doesn't know how to load two top-level modules with the same + /// name. pub app_name: String, /// Specify a directory containing the app and/or its dependencies. May be specified more than once. diff --git a/src/lib.rs b/src/lib.rs index 144b27a..5c30d6b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -312,6 +312,13 @@ pub async fn componentize( .chain(main_world) .collect::>(); + if worlds + .iter() + .any(|&id| app_name == resolve.worlds[id].name.to_snake_case().escape()) + { + bail!("App name `{app_name}` conflicts with world name; please rename your application module."); + } + let summary = Summary::try_new( &resolve, &worlds,