Skip to content
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

Compatibility with rules_python_gazelle_plugin #100

Closed
wingsofovnia opened this issue May 28, 2024 · 10 comments · Fixed by #126
Closed

Compatibility with rules_python_gazelle_plugin #100

wingsofovnia opened this issue May 28, 2024 · 10 comments · Fixed by #126

Comments

@wingsofovnia
Copy link
Contributor

wingsofovnia commented May 28, 2024

I am currently replacing rules_python in a rules_python + rules_python_gazelle_plugin + rules_py setup with rules_pycross and found some challenges in making rules_python_gazelle_plugin work with rules_pycross.

With this improvement, pycross can be plugged in into Gazelle.

MODULE.bazel

lock_import = use_extension("@rules_pycross//pycross/extensions:lock_import.bzl", "lock_import")
lock_import.import_poetry(
    lock_file = "//:poetry.lock",
    project_file = "//:pyproject.toml",
    repo = "pip",
)

BUILD.bazel

load("@pip//:requirements.bzl", "all_whl_requirements")
load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@pip//:requirements.bzl", "all_whl_requirements")
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")

modules_mapping(
    name = "gazelle.metadata",
    tags = ["manual"],
    wheels = all_whl_requirements,
)

gazelle_python_manifest(
    name = "gazelle.mapping",
    modules_mapping = ":gazelle.metadata",
    pip_repository_name = "pip",
)

gazelle_binary(
    name = "gazelle_bin",
    languages = DEFAULT_LANGUAGES + [
        "@rules_python_gazelle_plugin//python",
    ],
)

gazelle(
    name = "gazelle.update",
    gazelle = ":gazelle_bin",
)

gazelle(
    name = "gazelle.check",
    args = ["-mode=diff"],
    gazelle = ":gazelle_bin",
)

The missing piece is that rules_pycross has whl targets structured differently than ones in rules_python, expected by Gazelle plugin.

deps = ["@pip//:flask"], # rules_pycross
deps = ["@pip//flask"],  # rules_python

There was an attempt to align pycross whl targets with ones in rules_python which was declined (for a good reason):

Essentially, we need to prefix with :. I was able to workaround this by simply putting a genrule in the middle doing exactly that:

load("@aspect_bazel_lib//lib:jq.bzl", "jq")

modules_mapping(
    name = "_gazelle.metadata",
    tags = ["manual"],
    wheels = all_whl_requirements,
)

jq(
    name = "gazelle.metadata",
    srcs = [":_gazelle.metadata"],
    filter = 'with_entries(.value |= ":\\(.)")',
)

gazelle_python_manifest(
    name = "gazelle.mapping",
    modules_mapping = ":gazelle.metadata",
    pip_repository_name = "pip",
    tags = ["manual"],
)

This might be a very optimistic look at that and only work with a small set of dependencies I tested in a PoC project. See the working example: https://github.com/wingsofovnia/bazel-pycross-poetry-gazelle-example

I decided to start this issue to outline issues, some workarounds and gather feedback on possible directions to improve the setup.

@ewianda for viz as you've been probably trying to achieve similar goal.

@jvolkman
Copy link
Owner

I provided some of my thoughts about the layout here. The other issue you'll run into is dashes vs. underscores. pycross uses the Python name normalization, whereas rules_python does its own stuff on top.

A few options:

  1. Update modules_mapping to somehow support multiple layout types
  2. Have pycross generate some sort of compatibility repo that has aliases to the real targets where gazelle expects.
  3. Add a build rule that does what your jq target does in the example above, but with all required steps.

I think 1 is the best option, but I don't know anything about its feasibility. 2 may be useful for other aspects of peoples' migrations. 3 I think is the most straightforward and self-contained option, and I'd probably start there.

@wingsofovnia
Copy link
Contributor Author

wingsofovnia commented Jun 3, 2024

I extended jq target to fully normalise names:

jq(
    name = "gazelle.metadata",
    srcs = [":__gazelle.metadata"],
    filter = 'with_entries(.value |= ":\\(. | gsub(\"[-_.]+\"; \"-\") | ascii_downcase)")',
)

and gazelle_python.yaml looked alright but it appears that Gazelle plugin itself does additional replacement and although gazelle_python.yaml is now valid, e.g.

manifest:
  modules_mapping:
    dateutil.relativedelta: :python-dateutil
  pip_repository:
    name: pip

but

> bazel run //:gazelle.check
--- app/BUILD.bazel	1970-01-01 00:00:00.000000001 +0000
+++ app/BUILD.bazel	1970-01-01 00:00:00.000000001 +0000
@@ -6,6 +6,7 @@
     visibility = ["//:__subpackages__"],
     deps = [
         "@pip//:flask",
+        "@pip//:python_dateutil",
     ],
 )

Which is very sad :(

Update: found the place where this happens.

@wingsofovnia
Copy link
Contributor Author

wingsofovnia commented Jun 17, 2024

After a discussion in bazelbuild/rules_python#1939, I contributed some directives that can change Gazelle plugin's label conventions and it works with rules_pycross now. It will land with bazelbuild/rules_python#1976 PR if accepted.

Until then, Bazel 7.2.0+ users can use the plugin revision from PR's repo:

bazel_dep(name = "rules_python_gazelle_plugin", version = "0.0.0")

git_override(
  module_name = "rules_python_gazelle_plugin",
  commit = "1cc0168b57fb88faa97711081edb071c6bd23260",
  remote = "https://github.com/wingsofovnia/rules_python",
  strip_prefix = "gazelle", # New to Bazel 7.2.0+
)

and apply in your BUILD.bazel:

# gazelle:python_label_convention :$distribution_name$
# gazelle:python_label_normalization pep503

I've also updated the example mentioned in the post to use this plugin's revision if anyone is interested:
https://github.com/wingsofovnia/bazel-pycross-poetry-gazelle-example (e832636). I would however recommend using pdm for new projects as its support seems to be more complete, see #34.

@jvolkman
Copy link
Owner

Thanks for working on that!

@ewianda
Copy link
Contributor

ewianda commented Jun 17, 2024

Very nice

@jvolkman
Copy link
Owner

Hi @wingsofovnia, can this be closed now?

@wingsofovnia
Copy link
Contributor Author

Yes, this has been resolved. Shall I update the README.md with a Gazelle how-to?

@jvolkman
Copy link
Owner

Yes, this has been resolved. Shall I update the README.md with a Gazelle how-to?

That would be great, thanks!

@blockjon-dd
Copy link

I'm failing to get gazelle to work as advertised. I get errors like Package ipython does not support Python version 3.8.12 even though I'm not using that version of Python.

MODULE.bazel

http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

# ---------
# Platforms
# ---------
bazel_dep(
    name = "platforms",
    version = "0.0.10",
)

# --
# Go
# --
bazel_dep(name = "rules_go", version = "0.50.1", repo_name = "io_bazel_rules_go")

go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.23.1")

bazel_dep(name = "gazelle", version = "0.39.0")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "go.mod")

# Expose the packages from go.mod into the bazel ecosystem.
use_repo(go_deps, "com_github_gorilla_mux", "com_github_gurkankaymak_hocon", "in_gopkg_yaml_v3", "org_golang_google_grpc", "org_golang_x_tools")

# Register Linter
go_sdk.nogo(nogo = "//:dd_nogo")

# ------
# Python
# ------
bazel_dep(name = "rules_python", version = "0.36.0")

# The following stanza defines the dependency rules_python_gazelle_plugin.
# For typical setups you set the version.
bazel_dep(name = "rules_python_gazelle_plugin", version = "0.36.0")

# Load the python extension from the @rules_python repository
python = use_extension("@rules_python//python/extensions:python.bzl", "python")

PYTHON_VERSION = "3.11.7"

# Define a default Python toolchain with version 3.11.7
python.toolchain(
    configure_coverage_tool = True,
    ignore_root_user_error = True,
    is_default = True,
    python_version = PYTHON_VERSION,
)

# Associate the python symbol with the python_versions repository
use_repo(python, "python_versions")

# -------------
# Rules pycross
# https://github.com/jvolkman/rules_pycross
# -------------
# Helps us do cross platform builds for Python
bazel_dep(name = "rules_pycross", version = "0.6.1")

environments = use_extension("@rules_pycross//pycross/extensions:environments.bzl", "environments")
use_repo(environments, "pycross_environments")

lock_import = use_extension("@rules_pycross//pycross/extensions:lock_import.bzl", "lock_import")
lock_import.import_poetry(
    lock_file = "//libraries/python/third_party:poetry.lock",
    project_file = "//libraries/python/third_party:pyproject.toml",
    repo = "pip",
)

lock_repos = use_extension("@rules_pycross//pycross/extensions:lock_repos.bzl", "lock_repos")
use_repo(lock_repos, "pip")

# ---------
# rules pkg
# ---------
bazel_dep(name = "rules_pkg", version = "0.10.1")

# ---------
# rules_oci
# ---------
bazel_dep(name = "rules_oci", version = "1.8.0")

# ------
# Aspect
# ------
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1")
bazel_dep(name = "aspect_rules_py", version = "0.7.4")

# ------
# Skylib
# ------
bazel_dep(name = "bazel_skylib", version = "1.6.1")

# --
# jq
# --
http_file(
    name = "jq_amd64",
    executable = True,
    sha256 = "af986793a515d500ab2d35f8d2aecd656e764504b789b66d7e1a0b727a124c44",
    urls = ["https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64"],
)

http_file(
    name = "jq_arm64",
    executable = True,
    sha256 = "4dd2d8a0661df0b22f1bb9a1f9830f06b6f3b8f7d91211a1ef5d7c4f06a8b4a5",
    urls = ["https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-arm64"],
)

# --
# yq
# --
http_file(
    name = "yq_amd64",
    executable = True,
    sha256 = "3800de63976a5d26e5207f37fd4ab824e0fff538eb3e2624e65542d4153dcfdf",
    urls = ["https://github.com/mikefarah/yq/releases/download/v4.12.2/yq_linux_amd64"],
)

http_file(
    name = "yq_arm64",
    executable = True,
    sha256 = "0af8cf9d83b1046a70fe496868437214ebc0debb1953803eb0d8df2e99733f09",
    urls = ["https://github.com/mikefarah/yq/releases/download/v4.12.2/yq_linux_arm64"],
)

# -----
# jfrog
# -----
http_file(
    name = "jfrog_cli_amd64_download",
    executable = True,
    sha256 = "6d80447e27491b96a103756225e49dc7f311b2bfc486c07ced227c6fb376bc69",
    urls = ["https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/2.56.0/jfrog-cli-linux-amd64/jf"],
)

http_file(
    name = "jfrog_cli_arm64_download",
    executable = True,
    sha256 = "0e0056b84b018b289d2e43b1c766f9feb97d7e15de486f2240548b93be1a2792",
    urls = ["https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/2.56.0/jfrog-cli-linux-arm64/jf"],
)

# ----
# helm
# ----
http_file(
    name = "helmv2_amd64_download",
    executable = True,
    sha256 = "02a4751586d6a80f6848b58e7f6bd6c973ffffadc52b4c06652db7def02773a1",
    urls = ["https://get.helm.sh/helm-v2.11.0-linux-amd64.tar.gz"],
)

http_file(
    name = "helmv2_arm64_download",
    executable = True,
    sha256 = "7b3532634fb98151af23d32583187064f7ad18df87f96c456a15bc4ed82ae00e",
    urls = ["https://get.helm.sh/helm-v2.11.0-linux-arm64.tar.gz"],
)

http_file(
    name = "helmv3_amd64_download",
    executable = True,
    sha256 = "fc75d62bafec2c3addc87b715ce2512820375ab812e6647dc724123b616586d6",
    urls = ["https://get.helm.sh/helm-v3.0.3-linux-amd64.tar.gz"],
)

http_file(
    name = "helmv3_arm64_download",
    executable = True,
    sha256 = "85e304eaa57d100c038eb362f129720d5e59b237b00fed2711fea4945b2069a3",
    urls = ["https://get.helm.sh/helm-v3.0.3-linux-arm64.tar.gz"],
)

http_file(
    name = "google_go_conatiner_registry_arm64",
    executable = True,
    sha256 = "aff0db48825124c9331ea310057214bd4e92c01aa2e414d539e9659841d9422a",
    urls = ["https://github.com/google/go-containerregistry/releases/download/v0.20.2/go-containerregistry_Linux_arm64.tar.gz"],
)

http_file(
    name = "gh_cli_arm64",
    sha256 = "3b15b92705f58a29bb59808fd72b78c6586cfd439b0baa297a1d924f7f016864",
    urls = ["https://github.com/cli/cli/releases/download/v2.56.0/gh_2.56.0_linux_arm64.tar.gz"],
)

# -----
# vault
# -----
http_file(
    name = "vault_amd64_download",
    executable = True,
    sha256 = "ca33d4adc55cc3ac37249198254f2a85fee5fb878b37bcf5e1f5535de82161d8",
    urls = ["https://releases.hashicorp.com/vault/1.16.3/vault_1.16.3_linux_amd64.zip"],
)

http_file(
    name = "vault_arm64_download",
    executable = True,
    sha256 = "d03a4b998d61c1434bc46e332b8b85bbad4d12bbfdbbb11ecff6561b0e2ff049",
    urls = ["https://releases.hashicorp.com/vault/1.16.3/vault_1.16.3_linux_arm64.zip"],
)

http_file(
    name = "codecov_cli_aarch64_download",
    executable = True,
    sha256 = "01d4130fbc9938ce70d8b0cd034ef99c298e4eb00a2455408de996de0ed9b3f2",
    urls = ["https://github.com/codecov/codecov-cli/releases/download/v0.7.5/codecovcli_linux_arm64"],
)

# ----------
# distroless: https://github.com/GoogleContainerTools/rules_distroless/blob/main/MODULE.bazel
# ----------

bazel_lib_toolchains = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains")
use_repo(bazel_lib_toolchains, "bsd_tar_toolchains")
use_repo(bazel_lib_toolchains, "yq_linux_amd64")
use_repo(bazel_lib_toolchains, "yq_linux_arm64")

# Tinder's bazel-diff (target determinator alternative)
http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
http_jar(
    name = "bazel_diff",
    urls = [
        "https://github.com/Tinder/bazel-diff/releases/download/7.0.0/bazel-diff_deploy.jar"
    ],
    sha256 = "0b9e32f9c20e570846b083743fe967ae54d13e2a1f7364983e0a7792979442be",
)
$ bazel run //:gazelle
INFO: Invocation ID: a07b6cc9-5b2b-4a6d-aed1-0e676463e270
Traceback (most recent call last):
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 580, in <module>
    main(parse_flags())
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 570, in main
    result = resolve(args)
             ^^^^^^^^^^^^^
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 428, in resolve
    context.check_package_compatibility(package)
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 91, in check_package_compatibility
    raise Exception(
Exception: Package ipython does not support Python version 3.8.12 in environment python_3.8.12_aarch64-apple-darwin
INFO: Repository rules_pycross~~lock_import~pip instantiated at:
  <builtin>: in <toplevel>
Repository rule resolved_lock_repo defined at:
  /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/resolved_lock_repo.bzl:67:37: in <toplevel>
ERROR: An error occurred during the fetch of repository 'rules_pycross~~lock_import~pip':
   Traceback (most recent call last):
	File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/resolved_lock_repo.bzl", line 64, column 24, in _resolved_lock_repo_impl
		_generate_lock_file(rctx)
	File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/resolved_lock_repo.bzl", line 51, column 23, in _generate_lock_file
		exec_internal_tool(
	File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/internal_repo.bzl", line 83, column 13, in exec_internal_tool
		fail("Internal command failed: {}\n{}".format(all_args, result.stderr))
Error in fail: Internal command failed: ["/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~pycross~rules_pycross_internal/exec_venv/bin/python", "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-unknown-linux-gnu.json", "--always-include-sdist", "--lock-model-file", "raw_lock.json", "--annotations-file", "annotations.json", "--output", "lock.json"]
Traceback (most recent call last):
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 580, in <module>
    main(parse_flags())
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 570, in main
    result = resolve(args)
             ^^^^^^^^^^^^^
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 428, in resolve
    context.check_package_compatibility(package)
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 91, in check_package_compatibility
    raise Exception(
Exception: Package ipython does not support Python version 3.8.12 in environment python_3.8.12_aarch64-apple-darwin
WARNING: Target pattern parsing failed.
ERROR: Skipping '//:gazelle': error loading package '': Encountered error while reading extension file 'requirements.bzl': no such package '@@rules_pycross~~lock_repos~pip//': no such package '@@rules_pycross~~lock_import~pip//': Internal command failed: ["/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~pycross~rules_pycross_internal/exec_venv/bin/python", "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-unknown-linux-gnu.json", "--always-include-sdist", "--lock-model-file", "raw_lock.json", "--annotations-file", "annotations.json", "--output", "lock.json"]
Traceback (most recent call last):
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 580, in <module>
    main(parse_flags())
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 570, in main
    result = resolve(args)
             ^^^^^^^^^^^^^
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 428, in resolve
    context.check_package_compatibility(package)
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 91, in check_package_compatibility
    raise Exception(
Exception: Package ipython does not support Python version 3.8.12 in environment python_3.8.12_aarch64-apple-darwin
ERROR: error loading package '': Encountered error while reading extension file 'requirements.bzl': no such package '@@rules_pycross~~lock_repos~pip//': no such package '@@rules_pycross~~lock_import~pip//': Internal command failed: ["/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~pycross~rules_pycross_internal/exec_venv/bin/python", "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11.7_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11.7_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.11_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.11_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_aarch64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_aarch64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_ppc64le-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_ppc64le-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_s390x-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_s390x-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.12_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.12_x86_64-unknown-linux-gnu.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_aarch64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_aarch64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-apple-darwin.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-apple-darwin.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-pc-windows-msvc.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-pc-windows-msvc.json", "--target-environment", /home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~~environments~pycross_environments/python_3.8.12_x86_64-unknown-linux-gnu.json, "@@rules_pycross~~environments~pycross_environments//:python_3.8.12_x86_64-unknown-linux-gnu.json", "--always-include-sdist", "--lock-model-file", "raw_lock.json", "--annotations-file", "annotations.json", "--output", "lock.json"]
Traceback (most recent call last):
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 580, in <module>
    main(parse_flags())
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 570, in main
    result = resolve(args)
             ^^^^^^^^^^^^^
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 428, in resolve
    context.check_package_compatibility(package)
  File "/home/dev/.cache/bazel/_bazel_dev/155bb1574771dc607335fbe8110386b4/external/rules_pycross~/pycross/private/tools/raw_lock_resolver.py", line 91, in check_package_compatibility
    raise Exception(
Exception: Package ipython does not support Python version 3.8.12 in environment python_3.8.12_aarch64-apple-darwin
INFO: Elapsed time: 2.962s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
FAILED:
    Fetching module extension lock_repos in @@rules_pycross~//pycross/extensions:lock_repos.bzl; starting

@ewianda
Copy link
Contributor

ewianda commented Oct 16, 2024

From the stack trace it doesn't look like a gazelle problem. The error seems to come from poetry resolver.

Can you run bazel build @pip//:ipython to validate that it is indeed an issue with the poetry resolver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants