diff --git a/python/uv/private/lock.bzl b/python/uv/private/lock.bzl index 84e4cbbc12..ddb60d0006 100644 --- a/python/uv/private/lock.bzl +++ b/python/uv/private/lock.bzl @@ -131,7 +131,7 @@ def _up(x, directory, short_path = False): elif hasattr(x, "path"): x = x.path - if not directory: + if not directory or paths.is_absolute(x): return x prefix = "/".join([".."] * len(directory.split("/"))) diff --git a/tests/uv/lock/lock_tests.bzl b/tests/uv/lock/lock_tests.bzl index f14d784ebf..f1aee2fdb1 100644 --- a/tests/uv/lock/lock_tests.bzl +++ b/tests/uv/lock/lock_tests.bzl @@ -86,6 +86,20 @@ def _test_up(env): _basic_tests.append(_test_up) +def _test_up_absolute(env): + up = lock_testing.up + env.expect.that_str( + up("/usr/bin/python3", "dev"), + ).equals("/usr/bin/python3") + env.expect.that_str( + up("/usr/bin/python3", "a/b/c"), + ).equals("/usr/bin/python3") + env.expect.that_str( + up("C:/Python312/python.exe", "dev"), + ).equals("C:/Python312/python.exe") + +_basic_tests.append(_test_up_absolute) + def lock_test_suite(name): """The test suite with various lock-related integration tests