fix: update gazelle to properly handle dot in package name. (#1083)

diff --git a/gazelle/pythonconfig/BUILD.bazel b/gazelle/pythonconfig/BUILD.bazel
index 79b5121..d0f1690 100644
--- a/gazelle/pythonconfig/BUILD.bazel
+++ b/gazelle/pythonconfig/BUILD.bazel
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
 
 go_library(
     name = "pythonconfig",
@@ -15,6 +15,12 @@
     ],
 )
 
+go_test(
+    name = "pythonconfig_test",
+    srcs = ["pythonconfig_test.go"],
+    deps = [":pythonconfig"],
+)
+
 filegroup(
     name = "distribution",
     srcs = glob(["**"]),
diff --git a/gazelle/pythonconfig/pythonconfig.go b/gazelle/pythonconfig/pythonconfig.go
index ea2ae65..c7cd7c1 100644
--- a/gazelle/pythonconfig/pythonconfig.go
+++ b/gazelle/pythonconfig/pythonconfig.go
@@ -90,6 +90,14 @@
 	"setup.py": {},
 }
 
+func SanitizeDistribution(distributionName string) string {
+	sanitizedDistribution := strings.ToLower(distributionName)
+	sanitizedDistribution = strings.ReplaceAll(sanitizedDistribution, "-", "_")
+	sanitizedDistribution = strings.ReplaceAll(sanitizedDistribution, ".", "_")
+
+	return sanitizedDistribution
+}
+
 // Configs is an extension of map[string]*Config. It provides finding methods
 // on top of the mapping.
 type Configs map[string]*Config
@@ -218,8 +226,7 @@
 				} else if gazelleManifest.PipRepository != nil {
 					distributionRepositoryName = gazelleManifest.PipRepository.Name
 				}
-				sanitizedDistribution := strings.ToLower(distributionName)
-				sanitizedDistribution = strings.ReplaceAll(sanitizedDistribution, "-", "_")
+				sanitizedDistribution := SanitizeDistribution(distributionName)
 
 				if gazelleManifest.PipRepository != nil && gazelleManifest.PipRepository.UsePipRepositoryAliases {
 					// @<repository_name>//<distribution_name>
diff --git a/gazelle/pythonconfig/pythonconfig_test.go b/gazelle/pythonconfig/pythonconfig_test.go
new file mode 100644
index 0000000..1512eb9
--- /dev/null
+++ b/gazelle/pythonconfig/pythonconfig_test.go
@@ -0,0 +1,28 @@
+package pythonconfig
+
+import (
+	"testing"
+
+	"github.com/bazelbuild/rules_python/gazelle/pythonconfig"
+)
+
+func TestDistributionSanitizing(t *testing.T) {
+	tests := map[string]struct {
+		input string
+		want  string
+	}{
+		"upper case": {input: "DistWithUpperCase", want: "distwithuppercase"},
+		"dashes":     {input: "dist-with-dashes", want: "dist_with_dashes"},
+		"dots":       {input: "dist.with.dots", want: "dist_with_dots"},
+		"mixed":      {input: "To-be.sanitized", want: "to_be_sanitized"},
+	}
+
+	for name, tc := range tests {
+		t.Run(name, func(t *testing.T) {
+			got := pythonconfig.SanitizeDistribution(tc.input)
+			if tc.want != got {
+				t.Fatalf("expected %q, got %q", tc.want, got)
+			}
+		})
+	}
+}