Skip to content

Commit

Permalink
fix: disable python extension on windows (#6879)
Browse files Browse the repository at this point in the history
### Changes are visible to end-users: yes

- Searched for relevant documentation and updated as needed: yes
- Breaking change (forces users to change their own code or config): no
- Suggested release notes appear below: yes

Disable python extension on windows

### Test plan

- Covered by existing test cases

GitOrigin-RevId: 631b85f43769ea877ebd14d6b4df7be48077dd64
  • Loading branch information
thesayyn authored and jbedard committed Sep 28, 2024
1 parent 9f78efe commit e6055ca
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
25 changes: 25 additions & 0 deletions gazelle/python/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

# gazelle:ignore
config_setting(
name = "windows",
constraint_values = ["@platforms//os:windows"],
)

go_library(
name = "python",
srcs = [
"unix.go",
"windows.go",
],
importpath = "aspect.build/cli/gazelle/python",
visibility = ["//visibility:public"],
deps = [
"@bazel_gazelle//language:go_default_library",
] + select({
":windows": [],
"//conditions:default": [
"@com_github_bazelbuild_rules_python_gazelle//python",
],
}),
)
13 changes: 13 additions & 0 deletions gazelle/python/unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build linux || darwin
// +build linux darwin

package python

import (
"github.com/bazelbuild/bazel-gazelle/language"
python "github.com/bazelbuild/rules_python/gazelle/python"
)

func NewLanguage() language.Language {
return python.NewLanguage()
}
15 changes: 15 additions & 0 deletions gazelle/python/windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build windows
// +build windows

package python

import (
"log"

"github.com/bazelbuild/bazel-gazelle/language"
)

func NewLanguage() language.Language {
log.Fatalln("Python extension is not supported on Windows.\nSee: https://github.com/aspect-build/aspect-cli/issues/747")
return nil
}
2 changes: 1 addition & 1 deletion pkg/aspect/configure/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ go_library(
"//gazelle/bzl",
"//gazelle/js",
"//gazelle/kotlin",
"//gazelle/python",
"//pkg/aspect/configure/internal/wspace",
"//pkg/aspecterrors",
"//pkg/ioutils",
Expand All @@ -33,7 +34,6 @@ go_library(
"@bazel_gazelle//rule:go_default_library",
"@bazel_gazelle//walk:go_default_library",
"@com_github_bazelbuild_buildtools//build:go_default_library",
"@com_github_bazelbuild_rules_python_gazelle//python",
"@com_github_pmezard_go_difflib//difflib",
"@com_github_spf13_cobra//:cobra",
"@com_github_spf13_viper//:viper",
Expand Down
2 changes: 1 addition & 1 deletion pkg/aspect/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
bzl "aspect.build/cli/gazelle/bzl"
js "aspect.build/cli/gazelle/js"
kotlin "aspect.build/cli/gazelle/kotlin"
python "aspect.build/cli/gazelle/python"
"aspect.build/cli/pkg/aspecterrors"
"aspect.build/cli/pkg/ioutils"
"github.com/bazelbuild/bazel-gazelle/language"
golang "github.com/bazelbuild/bazel-gazelle/language/go"
"github.com/bazelbuild/bazel-gazelle/language/proto"
python "github.com/bazelbuild/rules_python/gazelle/python"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down

0 comments on commit e6055ca

Please sign in to comment.