Skip to content

Commit 934a106

Browse files
committed
test: add e2e regression case for rdflib-linux dependency group resolution
1 parent c81f76e commit 934a106

12 files changed

Lines changed: 241 additions & 0 deletions

e2e/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ write_source_files(
3636
name = "snapshots",
3737
testonly = True,
3838
files = {
39+
# @pypi_rdflib_linux — regression: hyphen/underscore normalization in dep_group names.
40+
# ----------------------------------------------------------------
41+
# The project is named "rdflib-linux" (hyphens, Python convention). uv_hub
42+
# currently emits config_setting(name = "rdflib-linux") using the raw name,
43+
# so dep_group = "rdflib_linux" (underscore, Bazel convention) never matches
44+
# → @@platforms//:incompatible. The fix must normalize the name to underscores.
45+
# This snapshot pins the DESIRED (fixed) state; it FAILS today and PASSES once
46+
# uv_hub normalises dep_group names via normalize_name().
47+
"snapshots/pypi_rdflib_linux.dep_group.BUILD.bazel": "@pypi_rdflib_linux//dep_group:BUILD.bazel",
48+
3949
# @pypi_multi (multi-project: alpha, beta, gamma)
4050
# ----------------------------------------------------------------
4151
# Per-package alias with multiple select arms. Catches regressions in

e2e/MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ include("//cases/freethreaded-805:setup.MODULE.bazel")
9898
include("//cases/multi-project-hub:setup.MODULE.bazel")
9999
include("//cases/oci:setup.MODULE.bazel")
100100
include("//cases/pth-namespace-547:setup.MODULE.bazel")
101+
include("//cases/rdflib-linux:setup.MODULE.bazel")
101102
include("//cases/pytest-main-867:setup.MODULE.bazel")
102103
include("//cases/pytest-mock-530:setup.MODULE.bazel")
103104
include("//cases/pytest-subdir-imports:setup.MODULE.bazel")

e2e/cases/rdflib-linux/BUILD.bazel

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Regression: pyproject.toml name = "rdflib-linux" (hyphens, standard Python convention)
2+
# causes uv_hub to emit config_setting(name = "rdflib-linux", ...) with the raw name.
3+
# A user writing dep_group = "rdflib_linux" (underscores, natural Bazel convention)
4+
# gets a mismatch: flag "rdflib_linux" ≠ config_setting "rdflib-linux", so
5+
# compatible_with() falls through to //conditions:default and emits
6+
# @@platforms//:incompatible for the entire rdflib alias.
7+
#
8+
# Fix: normalize dep_group names in uv_hub (replace "-" → "_") before emitting
9+
# config_setting targets and flag_values.
10+
load("@aspect_rules_py//py:defs.bzl", "py_test")
11+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
12+
13+
# This sh_test reads the hub's generated dep_group/BUILD.bazel via exports_files()
14+
# — a source-file target that carries NO target_compatible_with, so incompatibility
15+
# does NOT propagate here. The test runs in //... and FAILS while the bug exists.
16+
#
17+
# Root cause it checks: uv_hub emits config_setting(name = "rdflib-linux") using the
18+
# raw pyproject.toml [project].name. A user writing dep_group = "rdflib_linux"
19+
# (underscore, Bazel convention) gets no match → @@platforms//:incompatible.
20+
# Fix: normalize dep_group names with normalize_name() in uv_hub/repository.bzl.
21+
sh_test(
22+
name = "dep_group_names_normalized",
23+
srcs = ["check_dep_group_names.sh"],
24+
args = ["$(location @pypi_rdflib_linux//dep_group:BUILD.bazel)"],
25+
data = ["@pypi_rdflib_linux//dep_group:BUILD.bazel"],
26+
target_compatible_with = ["@platforms//os:linux"],
27+
)
28+
29+
# Vector 1: hyphen/underscore mismatch.
30+
# pyproject.toml name = "rdflib-linux" → hub config_setting = "rdflib-linux".
31+
# dep_group = "rdflib_linux" (underscore) doesn't match → @@platforms//:incompatible.
32+
py_test(
33+
name = "rdflib_linux",
34+
srcs = ["__test__.py"],
35+
dep_group = "rdflib_linux",
36+
main = "__test__.py",
37+
python_version = "3.11",
38+
target_compatible_with = ["@platforms//os:linux"],
39+
deps = [
40+
"@pypi_rdflib_linux//rdflib",
41+
],
42+
)
43+
44+
# Vector 2: multi-project hub, rdflib only in one project.
45+
# "other" project shares @pypi_rdflib_linux but has no rdflib dependency.
46+
# Building with dep_group = "other" → rdflib alias has no matching arm
47+
# for "other" → //conditions:default → @@platforms//:incompatible.
48+
py_test(
49+
name = "rdflib_wrong_dep_group",
50+
srcs = ["__test__.py"],
51+
dep_group = "other",
52+
main = "__test__.py",
53+
python_version = "3.11",
54+
target_compatible_with = ["@platforms//os:linux"],
55+
deps = [
56+
"@pypi_rdflib_linux//rdflib",
57+
],
58+
)

e2e/cases/rdflib-linux/__test__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Regression: rdflib must be importable on Linux.
2+
3+
Reported error:
4+
@@aspect_rules_py++uv+pypi//rdflib:rdflib (cae838)
5+
<-- target platform (...:linux_host_platform) didn't satisfy constraint
6+
@@platforms//:incompatible
7+
"""
8+
9+
import rdflib
10+
from rdflib import Graph
11+
12+
g = Graph()
13+
assert rdflib.__version__ == "7.1.1", rdflib.__version__
14+
print("rdflib", rdflib.__version__, "imported and Graph() constructed successfully")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
# Regression: dep_group config_setting names must be normalized (hyphens → underscores).
3+
# If the hub emits config_setting(name = "rdflib-linux"), then dep_group = "rdflib_linux"
4+
# never matches and every package in the hub becomes @@platforms//:incompatible.
5+
set -euo pipefail
6+
7+
BUILD_FILE="${1:?usage: check_dep_group_names.sh <dep_group/BUILD.bazel>}"
8+
9+
if grep -qF '"rdflib-linux"' "$BUILD_FILE"; then
10+
echo "FAIL: config_setting name contains hyphens: 'rdflib-linux'"
11+
echo " dep_group = \"rdflib_linux\" (underscore) will never match it."
12+
echo " uv_hub must normalize project names via normalize_name() before"
13+
echo " emitting config_setting targets and flag_values."
14+
echo ""
15+
grep '"rdflib-linux"' "$BUILD_FILE"
16+
exit 1
17+
fi
18+
19+
echo "PASS: all dep_group config_setting names are underscore-normalized"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
exports_files(
2+
["pyproject.toml", "uv.lock"],
3+
visibility = ["//:__subpackages__"],
4+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[project]
2+
name = "other"
3+
version = "0.0.0"
4+
authors = []
5+
requires-python = ">=3.11"
6+
dependencies = [
7+
"cowsay",
8+
]

e2e/cases/rdflib-linux/other/uv.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[project]
2+
name = "rdflib-linux"
3+
version = "0.0.0"
4+
authors = []
5+
requires-python = ">=3.11"
6+
dependencies = [
7+
"rdflib>=7.0.0",
8+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Two regression vectors for @@platforms//:incompatible on rdflib:
2+
#
3+
# 1. Hyphen/underscore mismatch: pyproject.toml name = "rdflib-linux" (hyphens).
4+
# uv_hub emits config_setting(name = "rdflib-linux") with the raw name.
5+
# dep_group = "rdflib_linux" (underscore) doesn't match → incompatible.
6+
#
7+
# 2. Multi-project hub: "other" project shares the hub but has no rdflib dep.
8+
# Building with dep_group = "other" causes rdflib alias to fall through to
9+
# //conditions:default → @@platforms//:incompatible.
10+
11+
uv = use_extension("@aspect_rules_py//uv:extensions.bzl", "uv")
12+
uv.declare_hub(hub_name = "pypi_rdflib_linux")
13+
uv.project(
14+
hub_name = "pypi_rdflib_linux",
15+
lock = "//cases/rdflib-linux:uv.lock",
16+
pyproject = "//cases/rdflib-linux:pyproject.toml",
17+
)
18+
uv.project(
19+
hub_name = "pypi_rdflib_linux",
20+
lock = "//cases/rdflib-linux/other:uv.lock",
21+
pyproject = "//cases/rdflib-linux/other:pyproject.toml",
22+
)
23+
use_repo(uv, "pypi_rdflib_linux")

0 commit comments

Comments
 (0)