build-backend: Allow overriding module names for editable builds (#12137)

## Summary

This PR enables module name overrides for editable installs. 

Builds upon https://github.com/astral-sh/uv/pull/11884. The
`tool.uv.build-backend.module-name` option is now respected during
editable build processes.

## Test Plan

Added a test.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
Ahmed Ilyas 2025-03-14 02:27:51 +01:00 committed by GitHub
parent 897508aeb0
commit f2ff218621
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 74 additions and 1 deletions

View file

@ -282,7 +282,17 @@ pub fn build_editable(
return Err(Error::AbsoluteModuleRoot(settings.module_root.clone()));
}
let src_root = source_tree.join(settings.module_root);
let module_root = src_root.join(pyproject_toml.name().as_dist_info_name().as_ref());
let module_name = if let Some(module_name) = settings.module_name {
module_name
} else {
// Should never error, the rules for package names (in dist-info formatting) are stricter
// than those for identifiers
Identifier::from_str(pyproject_toml.name().as_dist_info_name().as_ref())?
};
debug!("Module name: `{:?}`", module_name);
let module_root = src_root.join(module_name.as_ref());
if !module_root.join("__init__.py").is_file() {
return Err(Error::MissingModule(module_root));
}