-
-
Notifications
You must be signed in to change notification settings - Fork 89
fix: normalize default dependency group name to underscores to prevent configuration mismatches #1077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: normalize default dependency group name to underscores to prevent configuration mismatches #1077
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| load("@aspect_rules_py//py:defs.bzl", "py_test") | ||
| load("@rules_shell//shell:sh_test.bzl", "sh_test") | ||
|
|
||
| # Regression: hyphenated [project].name caused config_setting names with hyphens, | ||
| # breaking dep_group = "rdflib_linux" (underscore) matching. Fix: normalize_name(). | ||
| sh_test( | ||
| name = "dep_group_names_normalized", | ||
| srcs = ["check_dep_group_names.sh"], | ||
| args = ["$(location @pypi_rdflib_linux//dep_group:BUILD.bazel)"], | ||
| data = ["@pypi_rdflib_linux//dep_group:BUILD.bazel"], | ||
| target_compatible_with = ["@platforms//os:linux"], | ||
| ) | ||
|
|
||
| py_test( | ||
| name = "rdflib_linux", | ||
| srcs = ["__test__.py"], | ||
| dep_group = "rdflib_linux", | ||
| main = "__test__.py", | ||
| python_version = "3.11", | ||
| target_compatible_with = ["@platforms//os:linux"], | ||
| deps = ["@pypi_rdflib_linux//rdflib"], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| """Regression: rdflib must be importable on Linux. | ||
|
|
||
| Reported error: | ||
| @@aspect_rules_py++uv+pypi//rdflib:rdflib (cae838) | ||
| <-- target platform (...:linux_host_platform) didn't satisfy constraint | ||
| @@platforms//:incompatible | ||
| """ | ||
|
|
||
| import rdflib | ||
| from rdflib import Graph | ||
|
|
||
| g = Graph() | ||
| assert rdflib.__version__ == "7.1.1", rdflib.__version__ | ||
| print("rdflib", rdflib.__version__, "imported and Graph() constructed successfully") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env bash | ||
| # Regression: dep_group config_setting names must be normalized (hyphens → underscores). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rdflib-linux is not enough bc instead of fail is skipped |
||
| # If the hub emits config_setting(name = "rdflib-linux"), then dep_group = "rdflib_linux" | ||
| # never matches and every package in the hub becomes @@platforms//:incompatible. | ||
| set -euo pipefail | ||
|
|
||
| BUILD_FILE="${1:?usage: check_dep_group_names.sh <dep_group/BUILD.bazel>}" | ||
|
|
||
| if grep -qF '"rdflib-linux"' "$BUILD_FILE"; then | ||
| echo "FAIL: config_setting name contains hyphens: 'rdflib-linux'" | ||
| echo " dep_group = \"rdflib_linux\" (underscore) will never match it." | ||
| echo " uv_hub must normalize project names via normalize_name() before" | ||
| echo " emitting config_setting targets and flag_values." | ||
| echo "" | ||
| grep '"rdflib-linux"' "$BUILD_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "PASS: all dep_group config_setting names are underscore-normalized" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [project] | ||
| name = "rdflib-linux" | ||
| version = "0.0.0" | ||
| authors = [] | ||
| requires-python = ">=3.11" | ||
| dependencies = [ | ||
| "rdflib>=7.0.0", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Regression: hyphenated [project].name → config_setting name mismatch → @@platforms//:incompatible. | ||
|
|
||
| uv = use_extension("@aspect_rules_py//uv:extensions.bzl", "uv") | ||
| uv.declare_hub(hub_name = "pypi_rdflib_linux") | ||
| uv.project( | ||
| hub_name = "pypi_rdflib_linux", | ||
| lock = "//cases/rdflib-linux:uv.lock", | ||
| pyproject = "//cases/rdflib-linux:pyproject.toml", | ||
| ) | ||
| use_repo(uv, "pypi_rdflib_linux") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| load("@rules_shell//shell:sh_test.bzl", "sh_test") | ||
|
|
||
| # Regression: packages must be isolated to the dep_group of the project that declares them. | ||
| # rdflib is in rdflib-project; other-project has cowsay only. The rdflib hub alias | ||
| # must not contain an other_project arm (cross-project contamination). | ||
| sh_test( | ||
| name = "cross_project_isolation", | ||
| srcs = ["check_cross_project_isolation.sh"], | ||
| args = ["$(location @pypi_cross_hub//rdflib:BUILD.bazel)"], | ||
| data = ["@pypi_cross_hub//rdflib:BUILD.bazel"], | ||
| target_compatible_with = ["@platforms//os:linux"], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| BUILD="${1:?}" | ||
|
|
||
| if grep -qF "other_project" "$BUILD"; then | ||
| echo "FAIL: rdflib alias contains other_project arm — cross-project contamination" | ||
| grep "other_project" "$BUILD" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! grep -qF "rdflib_project" "$BUILD"; then | ||
| echo "FAIL: rdflib alias missing rdflib_project arm" | ||
| cat "$BUILD" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "PASS: rdflib isolated to rdflib_project" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| exports_files( | ||
| [ | ||
| "pyproject.toml", | ||
| "uv.lock", | ||
| ], | ||
| visibility = ["//:__subpackages__"], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [project] | ||
| name = "other-project" | ||
| version = "0.0.0" | ||
| authors = [] | ||
| requires-python = ">=3.11" | ||
| dependencies = [ | ||
| "cowsay", | ||
| ] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [project] | ||
| name = "rdflib-project" | ||
| version = "0.0.0" | ||
| authors = [] | ||
| requires-python = ">=3.11" | ||
| dependencies = [ | ||
| "rdflib>=7.0.0", | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes this package unique that caused the bug? Outline it here...