Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ gazelle/examples/bzlmod_build_file_generation/bazel-bin
gazelle/examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
gazelle/examples/bzlmod_build_file_generation/bazel-out
gazelle/examples/bzlmod_build_file_generation/bazel-testlog
sphinxdocs
tests/integration/compile_pip_requirements/bazel-compile_pip_requirements
tests/integration/local_toolchains/bazel-local_toolchains
tests/integration/py_cc_toolchain_registered/bazel-py_cc_toolchain_registered
2 changes: 1 addition & 1 deletion .bcr/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

moduleRoots: [".", "gazelle"]
moduleRoots: [".", "gazelle", "sphinxdocs"]
21 changes: 21 additions & 0 deletions .bcr/sphinxdocs/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"homepage": "https://github.com/bazel-contrib/rules_python",
"maintainers": [
{
"name": "Richard Levasseur",
"email": "richardlev@gmail.com",
"github": "rickeylev"
},
{
"name": "Ignas Anikevicius",
"email": "bcr-ignas@use.startmail.com",
"github": "aignas"
}
],
"repository": [
"github:bazelbuild/rules_python",
"github:bazel-contrib/rules_python"
],
"versions": [],
"yanked_versions": {}
}
37 changes: 37 additions & 0 deletions .bcr/sphinxdocs/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

bcr_test_module:
module_path: "integration_tests/bcr"
matrix:
platform: ["debian11", "macos", "ubuntu2204"]
bazel: [7.*, 8.*, 9.*]
tasks:
run_tests:
name: "Run test module"
platform: ${{ platform }}
bazel: ${{ bazel }}
shell_commands:
- "echo 'common --override_module=rules_python=' >> .bazelrc"
batch_commands:
- "echo common --override_module=rules_python= >> .bazelrc"
test_flags:
# Minimum bazel supported C++
- "--keep_going"
- '--cxxopt=-std=c++17'
- '--host_cxxopt=-std=c++17'
build_targets:
- "//..."
test_targets:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/sphinxdocs/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "{REPO}-{VERSION}/sphinxdocs",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_python-{TAG}.tar.gz"
}
9 changes: 6 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,13 @@ pip.parse(
)
use_repo(pip, "rules_python_publish_deps")

# Not a dev dependency to allow usage of //sphinxdocs code, which refers to stardoc repos.
bazel_dep(name = "stardoc", version = "0.7.2", repo_name = "io_bazel_stardoc")

# ===== DEV ONLY DEPS AND SETUP BELOW HERE =====
bazel_dep(name = "sphinxdocs", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "sphinxdocs",
path = "sphinxdocs",
)

bazel_dep(name = "rules_bazel_integration_test", version = "0.27.0", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
Expand Down
14 changes: 7 additions & 7 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@dev_pip//:requirements.bzl", "requirement")
load("@sphinxdocs//:readthedocs.bzl", "readthedocs_install")
load("@sphinxdocs//:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
load("@sphinxdocs//:sphinx_docs_library.bzl", "sphinx_docs_library")
load("@sphinxdocs//:sphinx_stardoc.bzl", "sphinx_stardoc", "sphinx_stardocs")
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
load("//python/private:common_labels.bzl", "labels") # buildifier: disable=bzl-visibility
load("//python/uv:lock.bzl", "lock") # buildifier: disable=bzl-visibility
load("//sphinxdocs:readthedocs.bzl", "readthedocs_install")
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
load("//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardoc", "sphinx_stardocs")

package(default_visibility = ["//:__subpackages__"])

Expand Down Expand Up @@ -63,7 +63,7 @@ sphinx_docs(
renamed_srcs = {
"//:CHANGELOG.md": "changelog.md",
"//:CONTRIBUTING.md": "contributing.md",
"//sphinxdocs/inventories:bazel_inventory": "bazel_inventory.inv",
"@sphinxdocs//inventories:bazel_inventory": "bazel_inventory.inv",
},
sphinx = ":sphinx-build",
strip_prefix = package_name() + "/",
Expand All @@ -73,7 +73,7 @@ sphinx_docs(
":bzl_api_docs",
":py_api_srcs",
":py_runtime_pair",
"//sphinxdocs/docs:docs_lib",
"@sphinxdocs//docs:docs_lib",
],
)

Expand Down Expand Up @@ -182,7 +182,7 @@ sphinx_build_binary(
requirement("typing_extensions"),
requirement("sphinx_autodoc2"),
requirement("sphinx_reredirects"),
"//sphinxdocs/src/sphinx_bzl",
"@sphinxdocs//src/sphinx_bzl",
],
)

Expand Down
7 changes: 5 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
copyright = "2023, The Bazel Authors"
author = "Bazel"

# NOTE: These are overriden by -D flags via --//sphinxdocs:extra_defines
# NOTE: These are overriden by -D flags via --@sphinxdocs//:extra_defines
version = "0.0.0"
release = version

Expand Down Expand Up @@ -139,7 +139,10 @@

# --- Extlinks configuration
extlinks = {
"gh-issue": (f"https://github.com/bazel-contrib/rules_python/issues/%s", "#%s issue"),
"gh-issue": (
f"https://github.com/bazel-contrib/rules_python/issues/%s",
"#%s issue",
),
"gh-path": (f"https://github.com/bazel-contrib/rules_python/tree/main/%s", "%s"),
"gh-pr": (f"https://github.com/bazel-contrib/rules_python/pull/%s", "#%s PR"),
}
Expand Down
6 changes: 3 additions & 3 deletions docs/readthedocs_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ set -eou pipefail
declare -a extra_env
while IFS='=' read -r -d '' name value; do
if [[ "$name" == READTHEDOCS* ]]; then
extra_env+=("--//sphinxdocs:extra_env=$name=$value")
extra_env+=("--@sphinxdocs//:extra_env=$name=$value")
fi
done < <(env -0)

# In order to get the build number, we extract it from the host name
extra_env+=("--//sphinxdocs:extra_env=HOSTNAME=$HOSTNAME")
extra_env+=("--@sphinxdocs//:extra_env=HOSTNAME=$HOSTNAME")

export RULES_PYTHON_ENABLE_PIPSTAR=1

set -x
export RULES_PYTHON_ENABLE_PIPSTAR=1
bazel run \
--config=rtd \
"--//sphinxdocs:extra_defines=version=$READTHEDOCS_VERSION" \
"--@sphinxdocs//:extra_defines=version=$READTHEDOCS_VERSION" \
"${extra_env[@]}" \
//docs:readthedocs_install
9 changes: 5 additions & 4 deletions python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ load(":stamp.bzl", "stamp_build_setting")
load(":uncachable_version_file.bzl", "define_uncachable_version_file")

package(
default_visibility = ["//:__subpackages__"],
default_visibility = [
"//:__subpackages__",
"@sphinxdocs//:__subpackages__",
],
)

licenses(["notice"])
Expand Down Expand Up @@ -689,9 +692,7 @@ bzl_library(
bzl_library(
name = "util_bzl",
srcs = ["util.bzl"],
visibility = [
"//:__subpackages__",
],
visibility = ["//visibility:public"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

You're making util_bzl public here, but the sphinxdocs module is introducing its own copy of util.bzl instead of using this one. This leads to code duplication and is confusing. If the intent is to decouple sphinxdocs from rules_python's private implementation details (like PyInfo), it would be better to not make this target public and stick with the copied version in sphinxdocs. If this visibility change is no longer needed, please revert it to avoid confusion.

deps = [
":py_internal_bzl",
"@bazel_skylib//lib:types",
Expand Down
22 changes: 22 additions & 0 deletions sphinxdocs/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import %workspace%/.bazelrc.deleted_packages

test --test_output=errors

build --incompatible_default_to_explicit_init_py
build --@rules_python//python/config_settings:incompatible_default_to_explicit_init_py=True

# Ensure ongoing compatibility with this flag.
common --incompatible_disallow_struct_provider_syntax
# Makes Bazel 7 act more like Bazel 8
common --incompatible_use_plus_in_repo_names

# Explicitly enable for Windows
build --enable_runfiles

# Local disk cache greatly speeds up builds if the regular cache is lost
common --disk_cache=~/.cache/bazel/bazel-disk-cache

common --incompatible_python_disallow_native_rules
common --incompatible_no_implicit_file_export

build --lockfile_mode=update
1 change: 1 addition & 0 deletions sphinxdocs/.bazelrc.deleted_packages
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --deleted_packages=integration_tests/bcr
1 change: 1 addition & 0 deletions sphinxdocs/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.x
10 changes: 5 additions & 5 deletions sphinxdocs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("//sphinxdocs/private:sphinx.bzl", "repeated_string_list_flag")
load("//private:sphinx.bzl", "repeated_string_list_flag")

package(
default_visibility = ["//:__subpackages__"],
Expand Down Expand Up @@ -44,23 +44,23 @@ bool_flag(
bzl_library(
name = "sphinx_bzl",
srcs = ["sphinx.bzl"],
deps = ["//sphinxdocs/private:sphinx_bzl"],
deps = ["//private:sphinx_bzl"],
)

bzl_library(
name = "sphinx_docs_library_bzl",
srcs = ["sphinx_docs_library.bzl"],
deps = ["//sphinxdocs/private:sphinx_docs_library_macro_bzl"],
deps = ["//private:sphinx_docs_library_macro_bzl"],
)

bzl_library(
name = "sphinx_stardoc_bzl",
srcs = ["sphinx_stardoc.bzl"],
deps = ["//sphinxdocs/private:sphinx_stardoc_bzl"],
deps = ["//private:sphinx_stardoc_bzl"],
)

bzl_library(
name = "readthedocs_bzl",
srcs = ["readthedocs.bzl"],
deps = ["//sphinxdocs/private:readthedocs_bzl"],
deps = ["//private:readthedocs_bzl"],
)
27 changes: 27 additions & 0 deletions sphinxdocs/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module(
name = "sphinxdocs",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "stardoc", version = "0.7.2", repo_name = "io_bazel_stardoc")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "protobuf", version = "29.0-rc2", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_python", version = "0.0.0")
local_path_override(
module_name = "rules_python",
path = "..",
)

dev_pip = use_extension(
"@rules_python//python/extensions:pip.bzl",
"pip",
dev_dependency = True,
)
dev_pip.parse(
hub_name = "dev_pip",
python_version = "3.11",
requirements_lock = "@rules_python//docs:requirements.txt",
)
use_repo(dev_pip, "dev_pip")
19 changes: 10 additions & 9 deletions sphinxdocs/docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
load("//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardocs")
load("//:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//:sphinx_stardoc.bzl", "sphinx_stardocs")
load("//private:util.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility

package(default_visibility = ["//:__subpackages__"])

Expand All @@ -18,6 +18,7 @@ _TARGET_COMPATIBLE_WITH = select({

sphinx_docs_library(
name = "docs_lib",
visibility = ["//visibility:public"],
deps = [
":artisian_api_docs",
":bzl_docs",
Expand Down Expand Up @@ -47,18 +48,18 @@ sphinx_docs_library(
sphinx_stardocs(
name = "bzl_docs",
srcs = [
"//sphinxdocs:readthedocs_bzl",
"//sphinxdocs:sphinx_bzl",
"//sphinxdocs:sphinx_docs_library_bzl",
"//sphinxdocs:sphinx_stardoc_bzl",
"//sphinxdocs/private:sphinx_docs_library_bzl",
"//:readthedocs_bzl",
"//:sphinx_bzl",
"//:sphinx_docs_library_bzl",
"//:sphinx_stardoc_bzl",
"//private:sphinx_docs_library_bzl",
],
prefix = "api/sphinxdocs/",
target_compatible_with = _TARGET_COMPATIBLE_WITH,
)

sphinx_docs_library(
name = "py_api_srcs",
srcs = ["//sphinxdocs/src/sphinx_bzl"],
srcs = ["//src/sphinx_bzl"],
strip_prefix = "sphinxdocs/src/",
)
4 changes: 2 additions & 2 deletions sphinxdocs/docs/api/sphinxdocs/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:::{bzl:currentfile} //sphinxdocs:BUILD.bazel
:::{bzl:currentfile} //:BUILD.bazel
:::

# //sphinxdocs
# //

:::{bzl:flag} extra_defines
Additional `-D` values to add to every Sphinx build.
Expand Down
4 changes: 2 additions & 2 deletions sphinxdocs/docs/api/sphinxdocs/inventories/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:::{bzl:currentfile} //sphinxdocs/inventories:BUILD.bazel
:::{bzl:currentfile} //inventories:BUILD.bazel
:::

# //sphinxdocs/inventories
# //inventories

:::{bzl:target} bazel_inventory
A Sphinx inventory of Bazel objects.
Expand Down
Loading