Skip to content

Commit 8cd891b

Browse files
authored
Explicitly configure uv to use hard links (#519)
Since in newer versions of uv (specifically uv 0.10.5+, which we haven't yet updated to) the default link mode has changed from `hardlink` to `clone` (aka reflink), and reflinks are slower in some environments (such as Heroku's build system). See: astral-sh/uv#18259 Even if the uv default ends up being changed back to hard links again, it seems worth us explicitly requesting that link mode, given that we know it's the best mode for our use-case. GUS-W-21429394.
1 parent 279e941 commit 8cd891b

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- Updated pip from 25.3 to 26.0.1. ([#508](https://github.com/heroku/buildpacks-python/pull/508))
13+
- Explicitly configured uv to use hard links to maintain the behaviour of previous versions. ([#519](https://github.com/heroku/buildpacks-python/pull/519))
1314

1415
## [5.1.0] - 2026-02-26
1516

src/layers/uv.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ pub(crate) fn install_uv(
3939
},
4040
)?;
4141

42-
// Prevent uv from downloading/using its own Python installation:
43-
// https://docs.astral.sh/uv/concepts/python-versions/#disabling-automatic-python-downloads
4442
let mut layer_env = LayerEnv::new()
43+
// Prevent uv from downloading/using its own Python installation:
44+
// https://docs.astral.sh/uv/concepts/python-versions/#disabling-automatic-python-downloads
4545
.chainable_insert(
4646
Scope::Build,
4747
ModificationBehavior::Override,
@@ -53,6 +53,14 @@ pub(crate) fn install_uv(
5353
ModificationBehavior::Override,
5454
"UV_PYTHON_DOWNLOADS",
5555
"never",
56+
)
57+
// Force uv to use hardlinks rather than the new default of reflinks, since the latter are
58+
// significantly slower in some environments: https://github.com/astral-sh/uv/issues/18259
59+
.chainable_insert(
60+
Scope::Build,
61+
ModificationBehavior::Override,
62+
"UV_LINK_MODE",
63+
"hardlink",
5664
);
5765

5866
match layer.state {

tests/uv_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fn uv_basic_install_and_cache_reuse() {
5050
PYTHONUNBUFFERED=1
5151
SOURCE_DATE_EPOCH=315532801
5252
UV_CACHE_DIR=/layers/heroku_python/uv-cache
53+
UV_LINK_MODE=hardlink
5354
UV_NO_MANAGED_PYTHON=1
5455
UV_PROJECT_ENVIRONMENT=/layers/heroku_python/venv
5556
UV_PYTHON_DOWNLOADS=never

0 commit comments

Comments
 (0)