diff --git a/.aspect/workflows/config.yaml b/.aspect/workflows/config.yaml
index cb4c85c6..da752786 100644
--- a/.aspect/workflows/config.yaml
+++ b/.aspect/workflows/config.yaml
@@ -1,7 +1,46 @@
# See https://docs.aspect.build/workflows/configuration
+---
+workspaces:
+ - .
+ - e2e/smoke
+ - e2e/repository-rule-deps
+ - e2e/system-interpreter
+ - examples/uv_pip_compile
+
tasks:
+ # TODO(reid): Rosetta doesn't like HEAD version strings seemingly
+ # - test:
+ # name: test-os:linux-bzl:head
+ # queue: aspect-default
+ # hooks:
+ # - type: before_task
+ # command: |
+ # rm .bazelversion
+ # echo "USE_BAZEL_VERSION=last_green" > .bazeliskrc
+
- test:
- - finalization:
- queue: aspect-small
-notifications:
- github: {}
+ name: test-os:linux-bzl:latest
+ queue: aspect-default
+ hooks:
+ - type: before_task
+ command: |
+ rm .bazelversion
+ echo "USE_BAZEL_VERSION=latest" > .bazeliskrc
+
+ - test:
+ name: test-os:linux-bzl:8
+ queue: aspect-default
+ hooks:
+ - type: before_task
+ command: |
+ rm .bazelversion
+ echo "USE_BAZEL_VERSION=8.2.1" > .bazeliskrc
+
+ - test:
+ name: test-os:linux-bzl:7
+ queue: aspect-default
+ hooks:
+ - type: before_task
+ command: |
+ rm .bazelversion
+ echo "USE_BAZEL_VERSION=7.6.1" > .bazeliskrc
diff --git a/.bazelrc b/.bazelrc
index 3cc4c9e5..cf9c54fe 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -5,15 +5,20 @@
test --test_output=errors
# TODO(alex): enable
-common --noenable_bzlmod
+common --enable_bzlmod
# Define value used by tests
build --define=SOME_VAR=SOME_VALUE
common --features=-libtool
common --incompatible_enable_cc_toolchain_resolution
+
+# Use prebuilt protoc
+common --incompatible_enable_proto_toolchain_resolution
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
+common --per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
+common --host_per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
# Use local rules_python
# Enable with --config=dev
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index e29aecf1..6d4c0cc9 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -22,23 +22,6 @@ concurrency:
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
- test:
- uses: bazel-contrib/.github/.github/workflows/bazel.yaml@646899086d7aaee8e532540480f3e91e00596234 # 11 Dec 2024
- with:
- # NB: the root folder is tested with Aspect Workflows on BuildKite, see /.aspect/workflows/config.yaml
- folders: '["e2e/smoke", "e2e/repository-rule-deps", "e2e/system-interpreter", "examples/uv_pip_compile"]'
- # TODO: Build Windows tools and add to toolchain
- # TODO(alex): switch the root folder to bzlmod
- # TODO: fix remaining folders on Bazel 8
- exclude: |
- [
- {"os": "windows-latest"},
- {"folder": "e2e/repository-rule-deps", "bzlmodEnabled": false},
- {"folder": "e2e/system-interpreter", "bzlmodEnabled": false},
- {"folder": "examples/uv_pip_compile", "bzlmodEnabled": false},
- {"folder": "e2e/smoke", "bazelversion": "8.0.0"}
- ]
-
pre-commit:
runs-on: ubuntu-latest
steps:
@@ -81,7 +64,6 @@ jobs:
# on "all matrix jobs were successful".
conclusion:
needs:
- - test
- verify-bcr-patches
- test-release
- pre-commit
diff --git a/MODULE.bazel b/MODULE.bazel
index 51cfce79..d01c9ac7 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -14,19 +14,56 @@ module(
# py_image_layer needs repo_mapping fix.
bazel_dep(name = "aspect_bazel_lib", version = "2.16.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
-bazel_dep(name = "rules_python", version = "0.29.0")
+
+bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)
+bazel_dep(name = "gazelle", version = "0.31.0", dev_dependency = True, repo_name = "bazel_gazelle")
+
bazel_dep(name = "platforms", version = "0.0.7")
+bazel_dep(name = "rules_python", version = "1.0.0")
+
+bazel_dep(name = "rules_python_gazelle_plugin", version = "1.0.0", dev_dependency = True)
+bazel_dep(name = "toolchains_musl", version = "0.1.20", dev_dependency = True)
+bazel_dep(name = "toolchains_llvm", version = "1.4.0", dev_dependency = True)
+bazel_dep(name = "toolchains_protoc", version = "0.4.3", dev_dependency = True)
+
+protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
+use_repo(protoc, "toolchains_protoc_hub")
+register_toolchains("@toolchains_protoc_hub//:all")
+
+single_version_override(
+ module_name = "rules_python",
+ patch_strip = 0,
+ patches = [
+ "//third_party/com.github/bazel-contrib/rules_python:dev_pip.patch",
+ ],
+ version = "1.0.0",
+)
bazel_lib = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains")
bazel_lib.expand_template()
+bazel_lib.tar()
+use_repo(bazel_lib, "bsd_tar_toolchains")
# Custom python version for testing only
python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)
python.toolchain(
- is_default = False,
- python_version = "3.9",
+ is_default = True,
+ python_version = "3.11",
)
+pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True)
+pip.parse(
+ hub_name = "pypi",
+ python_version = "3.11",
+ requirements_lock = "//:requirements.txt",
+)
+pip.parse(
+ hub_name = "django",
+ python_version = "3.11",
+ requirements_lock = "//py/tests/virtual/django:requirements.txt",
+)
+use_repo(pip, "django", "pypi", "pypi_311_pytest")
+
tools = use_extension("//py:extensions.bzl", "py_tools")
tools.rules_py_tools()
use_repo(tools, "rules_py_tools")
@@ -46,6 +83,100 @@ register_toolchains(
# NOTE: when publishing to BCR, we patch these to be dev_dependency, as we publish pre-built binaries
# along with our releases.
+release_tools = use_extension("//tools/release:fetch.bzl", "release_tools", dev_dependency = True)
+use_repo(
+ release_tools,
+ "musl_toolchains",
+ "org_chromium_sysroot_linux_arm64",
+ "org_chromium_sysroot_linux_x86_64",
+ "sysroot_darwin_universal",
+)
+
+llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
+
+inject_repo(
+ llvm,
+ org_chromium_sysroot_linux_arm64 = "org_chromium_sysroot_linux_arm64",
+ org_chromium_sysroot_linux_x86_64 = "org_chromium_sysroot_linux_x86_64",
+ sysroot_darwin_universal = "sysroot_darwin_universal",
+)
+
+llvm.toolchain(
+ name = "llvm_toolchain",
+ llvm_version = "17.0.2",
+)
+use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")
+
+register_toolchains("@llvm_toolchain//:all")
+
+llvm.toolchain(
+ name = "llvm_toolchain_linux_x86_64",
+ llvm_version = "17.0.2",
+)
+llvm.toolchain_root(
+ name = "llvm_toolchain_linux_x86_64",
+ label = "@llvm_toolchain_llvm//:BUILD",
+)
+llvm.sysroot(
+ name = "llvm_toolchain_linux_x86_64",
+ label = "@org_chromium_sysroot_linux_x86_64//:sysroot",
+ targets = ["linux-x86_64"],
+)
+use_repo(llvm, "llvm_toolchain_linux_x86_64")
+
+register_toolchains("@llvm_toolchain_linux_x86_64//:all")
+
+llvm.toolchain(
+ name = "llvm_toolchain_linux_aarch64",
+ llvm_version = "17.0.2",
+)
+llvm.toolchain_root(
+ name = "llvm_toolchain_linux_aarch64",
+ label = "@llvm_toolchain_llvm//:BUILD",
+)
+llvm.sysroot(
+ name = "llvm_toolchain_linux_aarch64",
+ label = "@org_chromium_sysroot_linux_arm64//:sysroot",
+ targets = ["linux-aarch64"],
+)
+use_repo(llvm, "llvm_toolchain_linux_aarch64")
+
+register_toolchains("@llvm_toolchain_linux_aarch64//:all")
+
+llvm.toolchain(
+ name = "llvm_toolchain_darwin_x86_64",
+ llvm_version = "17.0.2",
+)
+llvm.toolchain_root(
+ name = "llvm_toolchain_darwin_x86_64",
+ label = "@llvm_toolchain_llvm//:BUILD",
+)
+llvm.sysroot(
+ name = "llvm_toolchain_darwin_x86_64",
+ label = "@sysroot_darwin_universal//:sysroot",
+ targets = ["darwin-x86_64"],
+)
+use_repo(llvm, "llvm_toolchain_darwin_x86_64")
+
+register_toolchains("@llvm_toolchain_darwin_x86_64//:all")
+
+llvm.toolchain(
+ name = "llvm_toolchain_darwin_aarch64",
+ llvm_version = "17.0.2",
+)
+llvm.toolchain_root(
+ name = "llvm_toolchain_darwin_aarch64",
+ label = "@llvm_toolchain_llvm//:BUILD",
+)
+llvm.sysroot(
+ name = "llvm_toolchain_darwin_aarch64",
+ label = "@sysroot_darwin_universal//:sysroot",
+ targets = ["darwin-aarch64"],
+)
+use_repo(llvm, "llvm_toolchain_darwin_aarch64")
+
+register_toolchains("@llvm_toolchain_darwin_aarch64//:all")
+
bazel_dep(
name = "rules_rust",
version = "0.53.0",
@@ -59,6 +190,12 @@ rust = use_extension(
)
rust.toolchain(
edition = "2021",
+ extra_target_triples = [
+ "aarch64-apple-darwin",
+ "aarch64-unknown-linux-gnu",
+ "x86_64-apple-darwin",
+ "x86_64-unknown-linux-gnu",
+ ],
versions = ["1.81.0"],
)
use_repo(rust, "rust_toolchains")
@@ -110,3 +247,12 @@ oci.pull(
tag = "latest",
)
use_repo(oci, "ubuntu", "ubuntu_linux_amd64", "ubuntu_linux_arm64_v8")
+
+http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
+
+http_file(
+ name = "django_4_2_4",
+ downloaded_file_path = "Django-4.2.4-py3-none-any.whl",
+ sha256 = "860ae6a138a238fc4f22c99b52f3ead982bb4b1aad8c0122bcd8c8a3a02e409d",
+ urls = ["https://files.pythonhosted.org/packages/7f/9e/fc6bab255ae10bc57fa2f65646eace3d5405fbb7f5678b90140052d1db0f/Django-4.2.4-py3-none-any.whl"],
+)
diff --git a/WORKSPACE b/WORKSPACE
deleted file mode 100644
index 62677825..00000000
--- a/WORKSPACE
+++ /dev/null
@@ -1,318 +0,0 @@
-# Declare the local Bazel workspace.
-workspace(name = "aspect_rules_py")
-
-load("//tools/release:fetch.bzl", _release_deps = "fetch_deps")
-load(":internal_deps.bzl", "rules_py_internal_deps")
-
-# Fetch deps needed only locally for development
-rules_py_internal_deps()
-
-# Fetch deps needed only for a release.
-_release_deps()
-
-load("//py:repositories.bzl", "rules_py_dependencies")
-
-# Fetch dependencies which users need as well
-rules_py_dependencies()
-
-load("//py:toolchains.bzl", "rules_py_toolchains")
-
-rules_py_toolchains()
-
-load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
-
-python_register_toolchains(
- name = "python_toolchain_3_8",
- python_version = "3.8.12",
- # Setting `set_python_version_constraint` will set special constraints on the registered toolchain.
- # This means that this toolchain registration will only be selected for `py_binary` / `py_test` targets
- # that have the `python_version = "3.8.12"` attribute set. Targets that have no `python_attribute` will use
- # the default toolchain resolved which can be seen below.
- set_python_version_constraint = True,
-)
-
-# It is important to register the default toolchain at last as it will be selected for any
-# py_test/py_binary target even if it has python_version attribute set.
-python_register_toolchains(
- name = "python_toolchain",
- python_version = "3.9",
-)
-
-py_repositories()
-
-############################################
-# Aspect bazel-lib
-load("@aspect_bazel_lib//lib:repositories.bzl", "register_coreutils_toolchains", "register_expand_template_toolchains")
-
-register_coreutils_toolchains()
-
-register_expand_template_toolchains()
-
-load("@musl_toolchains//:repositories.bzl", "load_musl_toolchains")
-
-load_musl_toolchains(extra_target_compatible_with = ["@//tools/linkers:musl"])
-
-load("@musl_toolchains//:toolchains.bzl", "register_musl_toolchains")
-
-register_musl_toolchains()
-
-############################################
-## CC toolchain using llvm
-load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")
-
-bazel_toolchain_dependencies()
-
-load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")
-
-llvm_toolchain(
- name = "llvm_toolchain",
- llvm_version = "17.0.2",
- sha256 = {
- "darwin-aarch64": "bb5144516c94326981ec78c8b055c85b1f6780d345128cae55c5925eb65241ee",
- "darwin-x86_64": "800ec8401344a95f84588815e97523a0ed31fd05b6ffa9e1b58ce20abdcf69f1",
- "linux-aarch64": "49eec0202b8cd4be228c8e92878303317f660bc904cf6e6c08917a55a638917d",
- "linux-x86_64": "0c5096c157e196a04fc6ac58543266caef0da3e3c921414a7c279feacc2309d9",
- },
- sysroot = {
- "darwin-aarch64": "@sysroot_darwin_universal//:sysroot",
- "darwin-x86_64": "@sysroot_darwin_universal//:sysroot",
- "linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot",
- "linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot",
- },
- urls = {
- "darwin-aarch64": ["https://github.com/dzbarsky/static-clang/releases/download/v17.0.2-8/darwin_arm64_minimal.tar.xz"],
- "darwin-x86_64": ["https://github.com/dzbarsky/static-clang/releases/download/v17.0.2-8/darwin_amd64_minimal.tar.xz"],
- "linux-aarch64": ["https://github.com/dzbarsky/static-clang/releases/download/v17.0.2-8/linux_arm64_minimal.tar.xz"],
- "linux-x86_64": ["https://github.com/dzbarsky/static-clang/releases/download/v17.0.2-8/linux_amd64_minimal.tar.xz"],
- },
-)
-
-load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
-
-llvm_register_toolchains()
-
-############################################
-# Development dependencies from pypi
-load("@python_toolchain//:defs.bzl", "interpreter")
-load(":internal_python_deps.bzl", "rules_py_internal_pypi_deps")
-
-rules_py_internal_pypi_deps(
- interpreter = interpreter,
-)
-
-load("@pypi//:requirements.bzl", "install_deps")
-
-install_deps()
-
-load("@django//:requirements.bzl", install_django_deps = "install_deps")
-
-install_django_deps()
-
-################################
-# For running our own unit tests
-load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
-
-bazel_skylib_workspace()
-
-load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
-
-############################################
-# Gazelle, for generating bzl_library targets
-load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
-
-go_rules_dependencies()
-
-go_register_toolchains(version = "1.19.3")
-
-gazelle_dependencies()
-
-load("@rules_python//gazelle:deps.bzl", _py_gazelle_deps = "gazelle_deps")
-
-_py_gazelle_deps()
-
-load("@bazel_skylib_gazelle_plugin//:workspace.bzl", "bazel_skylib_gazelle_plugin_workspace")
-
-bazel_skylib_gazelle_plugin_workspace()
-
-load("@bazel_skylib_gazelle_plugin//:setup.bzl", "bazel_skylib_gazelle_plugin_setup")
-
-bazel_skylib_gazelle_plugin_setup(register_go_toolchains = False)
-
-############################################
-# rules_rust dependencies for building tools
-load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains", "rust_repository_set")
-
-rules_rust_dependencies()
-
-RUST_EDITION = "2021"
-
-RUST_VERSION = "1.81.0"
-
-# Declare cross-compilation toolchains
-rust_repository_set(
- name = "apple_darwin_aarch64",
- edition = RUST_EDITION,
- exec_triple = "aarch64-apple-darwin",
- # and cross-compile to these platforms:
- extra_target_triples = {
- "aarch64-apple-darwin": [
- "@platforms//cpu:arm64",
- "@platforms//os:macos",
- ],
- "aarch64-unknown-linux-musl": [
- "@platforms//cpu:arm64",
- "@platforms//os:linux",
- "@//tools/linkers:musl",
- ],
- "x86_64-apple-darwin": [
- "@platforms//cpu:x86_64",
- "@platforms//os:macos",
- ],
- "x86_64-unknown-linux-musl": [
- "@platforms//cpu:x86_64",
- "@platforms//os:linux",
- "@//tools/linkers:musl",
- ],
- },
- versions = [RUST_VERSION],
-)
-
-rust_repository_set(
- name = "apple_darwin_x86_64",
- edition = RUST_EDITION,
- exec_triple = "x86_64-apple-darwin",
- # and cross-compile to these platforms:
- extra_target_triples = {
- "aarch64-apple-darwin": [
- "@platforms//cpu:arm64",
- "@platforms//os:macos",
- ],
- "aarch64-unknown-linux-musl": [
- "@platforms//cpu:arm64",
- "@platforms//os:linux",
- "@//tools/linkers:musl",
- ],
- "x86_64-apple-darwin": [
- "@platforms//cpu:x86_64",
- "@platforms//os:macos",
- ],
- "x86_64-unknown-linux-musl": [
- "@platforms//cpu:x86_64",
- "@platforms//os:linux",
- "@//tools/linkers:musl",
- ],
- },
- versions = [RUST_VERSION],
-)
-
-rust_repository_set(
- name = "rust_linux_x86_64",
- edition = RUST_EDITION,
- exec_triple = "x86_64-unknown-linux-gnu",
- extra_target_triples = {
- "aarch64-unknown-linux-gnu": [
- "@platforms//cpu:arm64",
- "@platforms//os:linux",
- "@//tools/linkers:unknown",
- ],
- "aarch64-unknown-linux-musl": [
- "@platforms//cpu:arm64",
- "@platforms//os:linux",
- "@//tools/linkers:musl",
- ],
- "x86_64-unknown-linux-gnu": [
- "@platforms//cpu:x86_64",
- "@platforms//os:linux",
- "@//tools/linkers:unknown",
- ],
- "x86_64-unknown-linux-musl": [
- "@platforms//cpu:x86_64",
- "@platforms//os:linux",
- "@//tools/linkers:musl",
- ],
- },
- versions = [RUST_VERSION],
-)
-
-rust_repository_set(
- name = "rust_linux_aarch64",
- edition = RUST_EDITION,
- exec_triple = "aarch64-unknown-linux-gnu",
- extra_target_triples = {
- "aarch64-unknown-linux-gnu": [
- "@platforms//cpu:arm64",
- "@platforms//os:linux",
- "@//tools/linkers:unknown",
- ],
- "aarch64-unknown-linux-musl": [
- "@platforms//cpu:arm64",
- "@platforms//os:linux",
- "@//tools/linkers:musl",
- ],
- "x86_64-unknown-linux-gnu": [
- "@platforms//cpu:x86_64",
- "@platforms//os:linux",
- "@//tools/linkers:unknown",
- ],
- "x86_64-unknown-linux-musl": [
- "@platforms//cpu:x86_64",
- "@platforms//os:linux",
- "@//tools/linkers:musl",
- ],
- },
- versions = [RUST_VERSION],
-)
-
-rust_register_toolchains(
- edition = RUST_EDITION,
- versions = [RUST_VERSION],
-)
-
-load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
-
-crate_universe_dependencies()
-
-load("@rules_rust//crate_universe:defs.bzl", "crates_repository")
-
-crates_repository(
- name = "crate_index",
- cargo_lockfile = "//:Cargo.lock",
- lockfile = "//:Cargo.Bazel.lock",
- manifests = [
- "//:Cargo.toml",
- "//py/tools/py:Cargo.toml",
- "//py/tools/unpack_bin:Cargo.toml",
- "//py/tools/venv_bin:Cargo.toml",
- "//py/tools/venv_shim:Cargo.toml",
- ],
-)
-
-load("@crate_index//:defs.bzl", "crate_repositories")
-
-crate_repositories()
-
-load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
-
-rules_oci_dependencies()
-
-load("@rules_oci//oci:repositories.bzl", "oci_register_toolchains")
-
-oci_register_toolchains(name = "oci")
-
-# You can pull your base images using oci_pull like this:
-load("@rules_oci//oci:pull.bzl", "oci_pull")
-
-oci_pull(
- name = "ubuntu",
- digest = "sha256:b59d21599a2b151e23eea5f6602f4af4d7d31c4e236d22bf0b62b86d2e386b8f",
- image = "ubuntu",
- platforms = [
- "linux/arm64/v8",
- "linux/amd64",
- ],
- tag = "latest",
-)
-
-load("@container_structure_test//:repositories.bzl", "container_structure_test_register_toolchain")
-
-container_structure_test_register_toolchain(name = "cst")
diff --git a/docs/py_test.md b/docs/py_test.md
index ea1294df..b8532e41 100644
--- a/docs/py_test.md
+++ b/docs/py_test.md
@@ -84,7 +84,7 @@ py_pytest_main wraps the template rendering target and the final py_library.
| :------------- | :------------- | :------------- |
| name | The name of the runable target that updates the test entry file. | none |
| py_library | Use this attribute to override the default py_library rule. | <unknown object com.google.devtools.build.skydoc.fakebuildapi.FakeStarlarkRuleFunctionsApi$RuleDefinitionIdentifier>
|
-| deps | A list containing the pytest library target, e.g., @pypi_pytest//:pkg. | []
|
+| deps | A list containing the pytest library target, e.g., @pypi//pytest. | []
|
| data | A list of data dependencies to pass to the py_library target. | []
|
| testonly | A boolean indicating if the py_library target is testonly. | True
|
| kwargs | The extra arguments passed to the template rendering target. | none |
diff --git a/docs/virtual_deps.md b/docs/virtual_deps.md
index 01e2f459..b924da05 100644
--- a/docs/virtual_deps.md
+++ b/docs/virtual_deps.md
@@ -17,7 +17,7 @@ https://github.com/aspect-build/rules_py/issues/213
Simply move an element from the `deps` attribute to `virtual_deps`.
For example, instead of getting a specific version of Django from
-`deps = ["@pypi_django//:pkg"]` on a `py_library` target,
+`deps = ["@pypi//django"]` on a `py_library` target,
provide the package name with `virtual_deps = ["django"]`.
> Note that any `py_binary` or `py_test` transitively depending on this `py_library` must be loaded from `aspect_rules_py` rather than `rules_python`, as the latter does not have a feature of resolving the virtual dep.
diff --git a/examples/django/BUILD.bazel b/examples/django/BUILD.bazel
index c798f375..b6244516 100644
--- a/examples/django/BUILD.bazel
+++ b/examples/django/BUILD.bazel
@@ -5,6 +5,6 @@ py_binary(
srcs = ["manage.py"],
deps = [
"//examples/django/mysite",
- "@pypi_django//:pkg",
+ "@pypi//django",
],
)
diff --git a/examples/django/mysite/BUILD.bazel b/examples/django/mysite/BUILD.bazel
index 413c89e6..46238e55 100644
--- a/examples/django/mysite/BUILD.bazel
+++ b/examples/django/mysite/BUILD.bazel
@@ -11,6 +11,6 @@ py_library(
],
visibility = ["//examples/django:__pkg__"],
deps = [
- "@pypi_django//:pkg",
+ "@pypi//django",
],
)
diff --git a/examples/multi_version/BUILD.bazel b/examples/multi_version/BUILD.bazel
index 87eb71b2..138e6900 100644
--- a/examples/multi_version/BUILD.bazel
+++ b/examples/multi_version/BUILD.bazel
@@ -3,15 +3,15 @@ load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_pytest_main", "py_test")
py_binary(
name = "multi_version",
srcs = ["say.py"],
- python_version = "3.8.12",
+ python_version = "3.11.0",
deps = [
- "@pypi_cowsay//:pkg",
+ "@pypi//cowsay",
],
)
py_pytest_main(
name = "__test__",
- deps = ["@pypi_pytest//:pkg"],
+ deps = ["@pypi//pytest"],
)
py_test(
@@ -21,7 +21,7 @@ py_test(
":__test__",
],
main = ":__test__.py",
- python_version = "3.8.12",
+ python_version = "3.11.0",
deps = [
":__test__",
],
diff --git a/examples/py_binary/BUILD.bazel b/examples/py_binary/BUILD.bazel
index 23fd4bac..5a38499c 100644
--- a/examples/py_binary/BUILD.bazel
+++ b/examples/py_binary/BUILD.bazel
@@ -13,6 +13,6 @@ py_binary(
name = "py_binary",
srcs = [":stamped"],
deps = [
- "@pypi_cowsay//:pkg",
+ "@pypi//cowsay",
],
)
diff --git a/examples/py_pex_binary/BUILD.bazel b/examples/py_pex_binary/BUILD.bazel
index 1fb85906..64809b52 100644
--- a/examples/py_pex_binary/BUILD.bazel
+++ b/examples/py_pex_binary/BUILD.bazel
@@ -9,7 +9,7 @@ py_binary(
},
deps = [
"@bazel_tools//tools/python/runfiles",
- "@pypi_cowsay//:pkg",
+ "@pypi//cowsay",
],
)
diff --git a/examples/py_venv/BUILD.bazel b/examples/py_venv/BUILD.bazel
index ae0ee9a3..e28b5b7c 100644
--- a/examples/py_venv/BUILD.bazel
+++ b/examples/py_venv/BUILD.bazel
@@ -15,7 +15,7 @@ expand_template(
py_venv(
name = "venv",
deps = [
- "@pypi_cowsay//:pkg",
+ "@pypi//cowsay",
],
)
@@ -41,7 +41,7 @@ py_venv_binary(
],
main = ":stamped",
deps = [
- "@pypi_cowsay//:pkg",
+ "@pypi//cowsay",
],
)
diff --git a/examples/pytest/BUILD.bazel b/examples/pytest/BUILD.bazel
index 9256da54..adb7ca7b 100644
--- a/examples/pytest/BUILD.bazel
+++ b/examples/pytest/BUILD.bazel
@@ -21,10 +21,10 @@ py_test(
pytest_main = True,
deps = [
":lib",
- "@pypi_coverage//:pkg",
- "@pypi_ftfy//:pkg",
- "@pypi_neptune//:pkg",
- "@pypi_pytest//:pkg",
+ "@pypi//coverage",
+ "@pypi//ftfy",
+ "@pypi//neptune",
+ "@pypi//pytest",
],
)
@@ -36,5 +36,5 @@ py_test(
package_collisions = "warning",
pytest_main = True,
shard_count = 2,
- deps = ["@pypi_pytest//:pkg"],
+ deps = ["@pypi//pytest"],
)
diff --git a/examples/pytest/README.md b/examples/pytest/README.md
index 08b45c82..16b038b3 100644
--- a/examples/pytest/README.md
+++ b/examples/pytest/README.md
@@ -14,7 +14,7 @@ load("@aspect_rules_py//py:defs.bzl", "py_pytest_main")
py_pytest_main(
name = "__test__",
- deps = ["@pypi_pytest//:pkg"], # change this to the pytest target in your repo.
+ deps = ["@pypi//pytest"], # change this to the pytest target in your repo.
)
```
diff --git a/examples/virtual_deps/BUILD.bazel b/examples/virtual_deps/BUILD.bazel
index 6e34e56f..c1efef98 100644
--- a/examples/virtual_deps/BUILD.bazel
+++ b/examples/virtual_deps/BUILD.bazel
@@ -19,7 +19,7 @@ py_library(
py_binary(
name = "app",
srcs = ["main.py"],
- python_version = "3.8.12",
+ python_version = "3.11.0",
resolutions = resolutions.from_requirements(
[
"cowsay",
@@ -35,7 +35,7 @@ py_binary(
py_binary(
name = "app_snake",
srcs = ["main.py"],
- python_version = "3.8.12",
+ python_version = "3.11.0",
resolutions = resolutions.from_requirements(
[
"snakesay",
diff --git a/internal_python_deps.bzl b/internal_python_deps.bzl
deleted file mode 100644
index 0300dbe2..00000000
--- a/internal_python_deps.bzl
+++ /dev/null
@@ -1,23 +0,0 @@
-"""Our "development" Python dependencies
-
-Users should *not* need to install these. If users see a load()
-statement from these, that's a bug in our distribution.
-
-These happen after the regular internal dependencies loads as we need to reference the resolved interpreter
-"""
-
-load("@rules_python//python:pip.bzl", "pip_parse")
-
-# buildifier: disable=function-docstring
-def rules_py_internal_pypi_deps(interpreter):
- pip_parse(
- name = "pypi",
- python_interpreter_target = interpreter,
- requirements_lock = "//:requirements.txt",
- )
-
- pip_parse(
- name = "django",
- python_interpreter_target = interpreter,
- requirements_lock = "//py/tests/virtual/django:requirements.txt",
- )
diff --git a/py/private/py_pytest_main.bzl b/py/private/py_pytest_main.bzl
index 4ce6292a..d48935bd 100644
--- a/py/private/py_pytest_main.bzl
+++ b/py/private/py_pytest_main.bzl
@@ -64,7 +64,7 @@ def py_pytest_main(name, py_library = default_py_library, deps = [], data = [],
Args:
name: The name of the runable target that updates the test entry file.
py_library: Use this attribute to override the default py_library rule.
- deps: A list containing the pytest library target, e.g., @pypi_pytest//:pkg.
+ deps: A list containing the pytest library target, e.g., @pypi//pytest.
data: A list of data dependencies to pass to the py_library target.
testonly: A boolean indicating if the py_library target is testonly.
**kwargs: The extra arguments passed to the template rendering target.
diff --git a/py/repositories.bzl b/py/repositories.bzl
index 12b58e41..af056cc6 100644
--- a/py/repositories.bzl
+++ b/py/repositories.bzl
@@ -39,7 +39,7 @@ def rules_py_dependencies():
http_archive(
name = "rules_python",
- sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
- strip_prefix = "rules_python-0.31.0",
- url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz",
+ sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
+ strip_prefix = "rules_python-1.0.0",
+ url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
)
diff --git a/py/tests/external-deps/BUILD.bazel b/py/tests/external-deps/BUILD.bazel
index c2f3ad73..b2816fc2 100644
--- a/py/tests/external-deps/BUILD.bazel
+++ b/py/tests/external-deps/BUILD.bazel
@@ -6,7 +6,7 @@ py_library(
name = "lib",
srcs = ["lib.py"],
deps = [
- "@pypi_colorama//:pkg",
+ "@pypi//colorama",
],
)
@@ -15,7 +15,7 @@ py_binary(
srcs = ["//py/tests/external-deps/custom-macro:__main__.py"],
deps = [
# Referencing the external py_library rule generated by rules_python
- "@pypi_click//:pkg",
+ "@pypi//click",
],
)
diff --git a/py/tests/external-deps/custom-macro/macro.bzl b/py/tests/external-deps/custom-macro/macro.bzl
index d5377ca8..2737f0e6 100644
--- a/py/tests/external-deps/custom-macro/macro.bzl
+++ b/py/tests/external-deps/custom-macro/macro.bzl
@@ -14,7 +14,7 @@ def click_cli_binary(name, deps = [], **kwargs):
main = "//py/tests/external-deps/custom-macro:__main__.py",
deps = deps + [
name + "_lib",
- "@pypi_click//:pkg",
+ "@pypi//click",
],
**kwargs
)
diff --git a/py/tests/py-binary/BUILD.bazel b/py/tests/py-binary/BUILD.bazel
index a99d987e..e9be9183 100644
--- a/py/tests/py-binary/BUILD.bazel
+++ b/py/tests/py-binary/BUILD.bazel
@@ -10,10 +10,10 @@ load("//py:defs.bzl", "py_binary", "py_test")
# We happen to use pytest here only for convenience; it's a program already in our requirements.in.
py_binary(
name = "py_test_bin",
- srcs = ["@pypi_pytest//:rules_python_wheel_entry_point_pytest"],
+ srcs = ["@pypi_311_pytest//:rules_python_wheel_entry_point_pytest"],
# rules_python permits this label even though it's not a source file in this repository.
main = "rules_python_wheel_entry_point_pytest.py",
- deps = ["@pypi_pytest//:pkg"],
+ deps = ["@pypi//pytest"],
)
genrule(
diff --git a/py/tests/py-external-venv/BUILD.bazel b/py/tests/py-external-venv/BUILD.bazel
index 3f7ad6cf..be4134da 100644
--- a/py/tests/py-external-venv/BUILD.bazel
+++ b/py/tests/py-external-venv/BUILD.bazel
@@ -3,7 +3,7 @@ load("//py/private/py_venv:defs.bzl", "py_venv", "py_venv_test")
py_venv(
name = "venv",
deps = [
- "@pypi_cowsay//:pkg",
+ "@pypi//cowsay",
],
)
diff --git a/py/tests/py-internal-venv/BUILD.bazel b/py/tests/py-internal-venv/BUILD.bazel
index f6716781..017675de 100644
--- a/py/tests/py-internal-venv/BUILD.bazel
+++ b/py/tests/py-internal-venv/BUILD.bazel
@@ -10,6 +10,6 @@ py_venv_test(
],
main = "test.py",
deps = [
- "@pypi_cowsay//:pkg",
+ "@pypi//cowsay",
],
)
diff --git a/py/tests/py-pex-binary/BUILD.bazel b/py/tests/py-pex-binary/BUILD.bazel
index 3107a127..e70f14b6 100644
--- a/py/tests/py-pex-binary/BUILD.bazel
+++ b/py/tests/py-pex-binary/BUILD.bazel
@@ -8,8 +8,8 @@ py_binary(
data = ["data.txt"],
deps = [
"@bazel_tools//tools/python/runfiles",
- "@pypi_cowsay//:pkg",
- "@pypi_six//:pkg",
+ "@pypi//cowsay",
+ "@pypi//six",
],
)
diff --git a/py/tests/py_image_layer/BUILD.bazel b/py/tests/py_image_layer/BUILD.bazel
index a5a0cdfa..3d409c33 100644
--- a/py/tests/py_image_layer/BUILD.bazel
+++ b/py/tests/py_image_layer/BUILD.bazel
@@ -27,7 +27,7 @@ py_binary(
deps = [
"//py/tests/internal-deps/adder",
"//py/tests/py_image_layer/branding",
- "@pypi_colorama//:pkg",
+ "@pypi//colorama",
],
)
diff --git a/py/tests/py_venv_image_layer/BUILD.bazel b/py/tests/py_venv_image_layer/BUILD.bazel
index 61d89467..fcc6b42d 100644
--- a/py/tests/py_venv_image_layer/BUILD.bazel
+++ b/py/tests/py_venv_image_layer/BUILD.bazel
@@ -29,7 +29,7 @@ py_venv_binary(
deps = [
"//py/tests/internal-deps/adder",
"//py/tests/py_image_layer/branding",
- "@pypi_colorama//:pkg",
+ "@pypi//colorama",
],
)
diff --git a/third_party/com.github/bazel-contrib/rules_python/BUILD.bazel b/third_party/com.github/bazel-contrib/rules_python/BUILD.bazel
new file mode 100644
index 00000000..12615f55
--- /dev/null
+++ b/third_party/com.github/bazel-contrib/rules_python/BUILD.bazel
@@ -0,0 +1,4 @@
+exports_files(
+ ["dev_pip.patch"],
+ visibility = ["//visibility:public"],
+)
diff --git a/third_party/com.github/bazel-contrib/rules_python/dev_pip.patch b/third_party/com.github/bazel-contrib/rules_python/dev_pip.patch
new file mode 100644
index 00000000..e1431679
--- /dev/null
+++ b/third_party/com.github/bazel-contrib/rules_python/dev_pip.patch
@@ -0,0 +1,10 @@
+--- MODULE.bazel
++++ MODULE.bazel
+@@ -112,7 +112,6 @@ dev_pip = use_extension(
+ dev_pip = use_extension(
+ "//python/extensions:pip.bzl",
+ "pip",
+- dev_dependency = True,
+ )
+ dev_pip.parse(
+ download_only = True,
diff --git a/third_party/com.github/bazel-contrib/toolchains_llvm/clang_ldd.patch b/third_party/com.github/bazel-contrib/toolchains_llvm/clang_ldd.patch
index b3815010..064ed303 100644
--- a/third_party/com.github/bazel-contrib/toolchains_llvm/clang_ldd.patch
+++ b/third_party/com.github/bazel-contrib/toolchains_llvm/clang_ldd.patch
@@ -1,7 +1,5 @@
-diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl
-index b2aa92a..87c6614 100644
---- a/toolchain/cc_toolchain_config.bzl
-+++ b/toolchain/cc_toolchain_config.bzl
+--- toolchain/cc_toolchain_config.bzl
++++ toolchain/cc_toolchain_config.bzl
@@ -112,8 +112,6 @@ def cc_toolchain_config(
"-fdebug-prefix-map={}=__bazel_toolchain_llvm_repo__/".format(toolchain_path_prefix),
]
diff --git a/tools/release/fetch.bzl b/tools/release/fetch.bzl
index 787dcef1..3461e1b8 100644
--- a/tools/release/fetch.bzl
+++ b/tools/release/fetch.bzl
@@ -2,7 +2,7 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-_SYSROOT_LINUX_BUILD_FILE = """
+SYSROOT_LINUX_BUILD_FILE = """
filegroup(
name = "sysroot",
srcs = glob(["*/**"]),
@@ -10,7 +10,7 @@ filegroup(
)
"""
-_SYSROOT_DARWIN_BUILD_FILE = """
+SYSROOT_DARWIN_BUILD_FILE = """
filegroup(
name = "sysroot",
srcs = glob(
@@ -21,28 +21,20 @@ filegroup(
)
"""
-def fetch_deps():
+def _release_tools_impl(_module_ctx):
"""Fetch dependencies only needed for release builds used for the legacy WORKSPACE support."""
- http_archive(
- name = "toolchains_llvm",
- sha256 = "b7cd301ef7b0ece28d20d3e778697a5e3b81828393150bed04838c0c52963a01",
- strip_prefix = "toolchains_llvm-0.10.3",
- canonical_id = "0.10.3",
- url = "https://github.com/grailbio/bazel-toolchain/releases/download/0.10.3/toolchains_llvm-0.10.3.tar.gz",
- patches = ["//third_party/com.github/bazel-contrib/toolchains_llvm:clang_ldd.patch"],
- patch_args = ["-p1"],
- )
+ # FIXME: Replace this with the BCR release
http_archive(
name = "org_chromium_sysroot_linux_arm64",
- build_file_content = _SYSROOT_LINUX_BUILD_FILE,
+ build_file_content = SYSROOT_LINUX_BUILD_FILE,
sha256 = "b199942a0bd9c34800e8d7b669778ef45f2054b9f106039439383dd66efcef31",
urls = ["https://github.com/DavidZbarsky-at/sysroot-min/releases/download/v0.0.20/debian_bullseye_arm64_sysroot.tar.xz"],
)
http_archive(
name = "org_chromium_sysroot_linux_x86_64",
- build_file_content = _SYSROOT_LINUX_BUILD_FILE,
+ build_file_content = SYSROOT_LINUX_BUILD_FILE,
sha256 = "b279dd2926e7d3860bb4e134997a45df5106f680e160a959b945580ba4ec755f",
urls = ["https://github.com/DavidZbarsky-at/sysroot-min/releases/download/v0.0.20/debian_bullseye_amd64_sysroot.tar.xz"],
)
@@ -55,8 +47,12 @@ def fetch_deps():
http_archive(
name = "sysroot_darwin_universal",
- build_file_content = _SYSROOT_DARWIN_BUILD_FILE,
+ build_file_content = SYSROOT_DARWIN_BUILD_FILE,
sha256 = "11870a4a3d382b78349861081264921bb883440a7e0b3dd4a007373d87324a38",
strip_prefix = "sdk-macos-11.3-ccbaae84cc39469a6792108b24480a4806e09d59/root",
urls = ["https://github.com/hexops-graveyard/sdk-macos-11.3/archive/ccbaae84cc39469a6792108b24480a4806e09d59.tar.gz"],
)
+
+release_tools = module_extension(
+ implementation = _release_tools_impl,
+)