Skip to content

Build backend: Case sensitive module discovery#13468

Merged
konstin merged 5 commits intomainfrom
konsti/build-backend-path-casing
May 16, 2025
Merged

Build backend: Case sensitive module discovery#13468
konstin merged 5 commits intomainfrom
konsti/build-backend-path-casing

Conversation

@konstin
Copy link
Member

@konstin konstin commented May 15, 2025

We may run on case-sensitive file systems (Linux, generally) or on case-insensitive file systems (Windows, generally), while modules in Python may be lower or upper case. For robustness over filesystem casing, we require an explicit module name for modules with upper case letters.

Fixes #13419

@konstin konstin added the bug Something isn't working label May 15, 2025
Ok(GlobBuilder::new(glob)
.literal_separator(true)
// We support case-insensitive file systems.
.case_insensitive(true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core change, the other changes are in support of that.

Comment on lines 233 to 243
let module_name = if let Some(module_name) = module_name {
module_name.to_string().to_lowercase()
} else {
// Should never error, the rules for package names (in dist-info formatting) are stricter
// than those for identifiers
let module_name = Identifier::from_str(package_name.as_dist_info_name().as_ref())?;
module_name.to_string().to_lowercase()
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Centralized here for normalization

@konstin konstin force-pushed the konsti/build-backend-path-casing branch from 6e7906d to e160db8 Compare May 15, 2025 14:01
@konstin konstin requested a review from BurntSushi May 15, 2025 14:01
Base automatically changed from konsti/normalize-build-backend-glob-paths to main May 15, 2025 15:19
@astral-sh astral-sh deleted a comment from followheart26 May 15, 2025
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this LGTM, but my main concern here is doing case insensitive globbing on all file systems. Couldn't that be unexpected behavior?

To try and answer my own question, I think the idea is that you want the build backend to match the same set of files regardless of platform, so that you get consistency. To that end, always doing case insensitive globbing means you fall to the lowest common denominator, so to speak. With that said, couldn't this be quite surprising for users on file systems that are case sensitive?

And should this behavior be documented somewhere?

@konstin
Copy link
Member Author

konstin commented May 15, 2025

To try and answer my own question, I think the idea is that you want the build backend to match the same set of files regardless of platform, so that you get consistency. To that end, always doing case insensitive globbing means you fall to the lowest common denominator, so to speak. With that said, couldn't this be quite surprising for users on file systems that are case sensitive?

Are there alternatives that have good behavior across platforms? My primary example would be a module called PIL, and I want to build that on Linux, Windows and Mac. Are there any behaviors that can reliably expect across platforms? Part of the problem is that I'm trying to match a path in a directory, instead of opening it; this allows pil to automatically find PIL, because the user may have set the package name to Pil and we normalized it away. Maybe we shouldn't do that and always force configuration for names with uppercase letters?

And should this behavior be documented somewhere?

Will do.

@konstin konstin force-pushed the konsti/build-backend-path-casing branch 2 times, most recently from 32ecb82 to 24fc9a2 Compare May 15, 2025 18:51
@konstin konstin force-pushed the konsti/build-backend-path-casing branch from 97cc8ee to 1dcb902 Compare May 16, 2025 08:37
@konstin
Copy link
Member Author

konstin commented May 16, 2025

I switched strategies, uppercase names need to be declared explicitly in tool.uv.module-name.

used for the build backend as for the uv process. Other build frontends, such as `python -m build`,
will choose the latest compatible `uv_build` version.

## Modules
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section will become "Modules and Namespaces" once implemented.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I think this seems better to me.

@konstin konstin changed the title Build backend: Case insensitive module discovery Build backend: Case sensitive module discovery May 16, 2025
@konstin konstin merged commit 77268ee into main May 16, 2025
86 checks passed
@konstin konstin deleted the konsti/build-backend-path-casing branch May 16, 2025 12:25
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request May 18, 2025
## 0.7.5

### Bug fixes

- Support case-sensitive module discovery in the build backend ([#13468](astral-sh/uv#13468))
- Bump Simple cache bucket to v16 ([#13498](astral-sh/uv#13498))
- Don't error when the script is too short for the buffer ([#13488](astral-sh/uv#13488))
- Add missing word in "script not supported" error ([#13483](astral-sh/uv#13483))

## 0.7.4

### Enhancements

- Add more context to external errors ([#13351](astral-sh/uv#13351))
- Align indentation of long arguments ([#13394](astral-sh/uv#13394))
- Preserve order of dependencies which are sorted naively ([#13334](astral-sh/uv#13334))
- Align progress bars by largest name length ([#13266](astral-sh/uv#13266))
- Reinstall local packages in `uv add` ([#13462](astral-sh/uv#13462))
- Rename `--raw-sources` to `--raw` ([#13348](astral-sh/uv#13348))
- Show 'Downgraded' when `self update` is used to install an older version ([#13340](astral-sh/uv#13340))
- Suggest `uv self update` if required uv version is newer ([#13305](astral-sh/uv#13305))
- Add 3.14 beta images to uv Docker images ([#13390](astral-sh/uv#13390))
- Add comma after "i.e." in Conda environment error ([#13423](astral-sh/uv#13423))
- Be more precise in unpinned packages warning ([#13426](astral-sh/uv#13426))
- Fix detection of sorted dependencies when include-group is used ([#13354](astral-sh/uv#13354))
- Fix display of HTTP responses in trace logs for retry of errors ([#13339](astral-sh/uv#13339))
- Log skip reasons during Python installation key interpreter match checks ([#13472](astral-sh/uv#13472))
- Redact credentials when displaying URLs ([#13333](astral-sh/uv#13333))

### Bug fixes

- Avoid erroring on `pylock.toml` dependency entries ([#13384](astral-sh/uv#13384))
- Avoid panics for cannot-be-a-base URLs ([#13406](astral-sh/uv#13406))
- Ensure cached realm credentials are applied if no password is found for index URL ([#13463](astral-sh/uv#13463))
- Fix `.tgz` parsing to respect true extension ([#13382](astral-sh/uv#13382))
- Fix double self-dependency ([#13366](astral-sh/uv#13366))
- Reject `pylock.toml` in `uv add -r` ([#13421](astral-sh/uv#13421))
- Retain dot-separated wheel tags during cache prune ([#13379](astral-sh/uv#13379))
- Retain trailing comments after PEP 723 metadata block ([#13460](astral-sh/uv#13460))

### Documentation

- Use "export" instead of "install" in `uv export` arguments ([#13430](astral-sh/uv#13430))
- Remove extra newline ([#13461](astral-sh/uv#13461))

### Preview features

- Build backend: Normalize glob paths ([#13465](astral-sh/uv#13465))
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 19, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.7.3` -> `0.7.5` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.7.5`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#075)

[Compare Source](astral-sh/uv@0.7.4...0.7.5)

##### Bug fixes

-   Support case-sensitive module discovery in the build backend ([#&#8203;13468](astral-sh/uv#13468))
-   Bump Simple cache bucket to v16 ([#&#8203;13498](astral-sh/uv#13498))
-   Don't error when the script is too short for the buffer ([#&#8203;13488](astral-sh/uv#13488))
-   Add missing word in "script not supported" error ([#&#8203;13483](astral-sh/uv#13483))

### [`v0.7.4`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#074)

[Compare Source](astral-sh/uv@0.7.3...0.7.4)

##### Enhancements

-   Add more context to external errors ([#&#8203;13351](astral-sh/uv#13351))
-   Align indentation of long arguments ([#&#8203;13394](astral-sh/uv#13394))
-   Preserve order of dependencies which are sorted naively ([#&#8203;13334](astral-sh/uv#13334))
-   Align progress bars by largest name length ([#&#8203;13266](astral-sh/uv#13266))
-   Reinstall local packages in `uv add` ([#&#8203;13462](astral-sh/uv#13462))
-   Rename `--raw-sources` to `--raw` ([#&#8203;13348](astral-sh/uv#13348))
-   Show 'Downgraded' when `self update` is used to install an older version ([#&#8203;13340](astral-sh/uv#13340))
-   Suggest `uv self update` if required uv version is newer ([#&#8203;13305](astral-sh/uv#13305))
-   Add 3.14 beta images to uv Docker images ([#&#8203;13390](astral-sh/uv#13390))
-   Add comma after "i.e." in Conda environment error ([#&#8203;13423](astral-sh/uv#13423))
-   Be more precise in unpinned packages warning ([#&#8203;13426](astral-sh/uv#13426))
-   Fix detection of sorted dependencies when include-group is used ([#&#8203;13354](astral-sh/uv#13354))
-   Fix display of HTTP responses in trace logs for retry of errors ([#&#8203;13339](astral-sh/uv#13339))
-   Log skip reasons during Python installation key interpreter match checks ([#&#8203;13472](astral-sh/uv#13472))
-   Redact credentials when displaying URLs ([#&#8203;13333](astral-sh/uv#13333))

##### Bug fixes

-   Avoid erroring on `pylock.toml` dependency entries ([#&#8203;13384](astral-sh/uv#13384))
-   Avoid panics for cannot-be-a-base URLs ([#&#8203;13406](astral-sh/uv#13406))
-   Ensure cached realm credentials are applied if no password is found for index URL ([#&#8203;13463](astral-sh/uv#13463))
-   Fix `.tgz` parsing to respect true extension ([#&#8203;13382](astral-sh/uv#13382))
-   Fix double self-dependency ([#&#8203;13366](astral-sh/uv#13366))
-   Reject `pylock.toml` in `uv add -r` ([#&#8203;13421](astral-sh/uv#13421))
-   Retain dot-separated wheel tags during cache prune ([#&#8203;13379](astral-sh/uv#13379))
-   Retain trailing comments after PEP 723 metadata block ([#&#8203;13460](astral-sh/uv#13460))

##### Documentation

-   Use "export" instead of "install" in `uv export` arguments ([#&#8203;13430](astral-sh/uv#13430))
-   Remove extra newline ([#&#8203;13461](astral-sh/uv#13461))

##### Preview features

-   Build backend: Normalize glob paths ([#&#8203;13465](astral-sh/uv#13465))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xMS4xOSIsInVwZGF0ZWRJblZlciI6IjQwLjEzLjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbIlJlbm92YXRlIEJvdCJdfQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build backend: Capital letter are not supported

2 participants