Skip to content

Commit

Permalink
fix(uv): lockfile translation with virtual tag introduced in uv 0.4.0
Browse files Browse the repository at this point in the history
also regenerate `uv.lock` for e2e-tests with the following command:
uvx --from="uv==0.4.0" uv lock
  • Loading branch information
betaboon committed Dec 8, 2024
1 parent cdb402d commit 47ba943
Show file tree
Hide file tree
Showing 11 changed files with 897 additions and 3 deletions.
7 changes: 7 additions & 0 deletions e2e/uv/always_build/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions e2e/uv/build_wheel/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions e2e/uv/local_wheel/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions e2e/uv/requirements/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions e2e/uv/vendored_lock_file_bzlmod/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions e2e/uv/vendored_lock_file_workspace/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pycross/private/tools/uv_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ def collect_and_process_packages(packages_list: list[Dict[str, Any]]) -> Dict[Pa

files = {parse_file_info(f) for f in files}

is_local = lock_pkg.get("source") == {"editable": "."} or lock_pkg.get("sdist") == {"path": "."}
is_local_sdist = lock_pkg.get("sdist") == {"path": "."}
is_local_editable = lock_pkg.get("source") == {"editable": "."}
is_local_virtual = lock_pkg.get("source") == {"virtual": "."}

is_local = is_local_sdist or is_local_editable or is_local_virtual

if not files and not is_local:
raise Exception(lock_pkg, is_local)
Expand Down
32 changes: 32 additions & 0 deletions pycross/tests/uv/lock_0_4_0_virtual/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
uv has introduced a special `virtual` tag for packages.
This change was introduced in the following PR:
https://github.com/astral-sh/uv/pull/6728
This PR was contained in the following release:
https://github.com/astral-sh/uv/releases/tag/0.4.0
"""

load("@aspect_bazel_lib//lib:testing.bzl", "assert_json_matches")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
load("//pycross:defs.bzl", "pycross_uv_lock_model")

pycross_uv_lock_model(
name = "lock",
lock_file = "uv.lock",
project_file = "pyproject.toml",
)

write_source_file(
name = "update_expected",
diff_test = False,
in_file = ":lock",
out_file = "expected.json",
)

assert_json_matches(
name = "test",
file1 = ":lock",
file2 = "expected.json",
)
Loading

0 comments on commit 47ba943

Please sign in to comment.