Conversation
`gazelle/python/std_modules.go` previously used `//go:embed stdlib_list.txt`, where `stdlib_list.txt` only existed as a Bazel `copy_file` output from `@python_stdlib_list`. Building, listing, or testing `github.com/bazel-contrib/rules_python/gazelle/python` directly with standard Go tooling (`go build`, `go test`, `go list -deps`, or `go install` for standalone Gazelle binaries in pre-commit/prek hooks) failed with `pattern stdlib_list.txt: no matching files found`, and running `bazel run //:gazelle` inside `gazelle/` emitted a missing-file warning on `std_modules.go`. Check in the default standard library module list at `gazelle/python/stdlib_list/default.txt` (verified via `diff_test` against `@python_stdlib_list//:stdlib_list/lists/3.14.txt`), change the Bazel `copy_file` output to `stdlib_list/selected.txt`, and embed `stdlib_list/*.txt` via `embed.FS`. At initialization, `loadStdModules` prefers `stdlib_list/selected.txt` when present (preserving Bazel's `python_version` `select()` behavior) and falls back to `stdlib_list/default.txt` for non-Bazel Go builds. Fixes bazel-contrib#3821
|
827 lines of this huge looking PR is just the contents of the txt file. For prior art, https://github.com/EngFlow/gazelle_cc/blob/main/language/cc/bzldep-index.json checks-in a huge index json file |
What APIs are you using? What are you building? I would have thought that there would be very little need to do this. :) |
We want to run gazelle pre-push as a hook. We want to make sure people don't push code that doesn't adhere with gazelle. Currently the only way to do it is with |
gazelle/python/std_modules.gopreviously used//go:embed stdlib_list.txt, wherestdlib_list.txtonly existed as a Bazelcopy_fileoutput from@python_stdlib_list.Building, listing, or testing
github.com/bazel-contrib/rules_python/gazelle/pythondirectly with standard Go tooling (go build,go test,go list -deps, orgo installfor standalone Gazelle binaries in pre-commit hooks) failed withpattern stdlib_list.txt: no matching files found, and runningbazel run //:gazelleinsidegazelle/emitted a missing-file warning onstd_modules.go.Check in the default standard library module list at
gazelle/python/stdlib_list/default.txt(verified viadiff_testagainst@python_stdlib_list//:stdlib_list/lists/3.14.txt), change the Bazelcopy_fileoutput tostdlib_list/selected.txt, and embedstdlib_list/*.txtviaembed.FS.At initialization,
loadStdModulesprefersstdlib_list/selected.txtwhen present (preserving Bazel'spython_versionselect()behavior) and falls back tostdlib_list/default.txtfor non-Bazel Go builds.Fixes #3821