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
28 changes: 14 additions & 14 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,20 +194,20 @@ tasks:
name: "Default: Ubuntu, upcoming Bazel"
platform: ubuntu2204
bazel: last_rc
ubuntu_rolling:
name: "Default: Ubuntu, rolling Bazel"
platform: ubuntu2204
bazel: rolling
# This is an advisory job; doesn't block merges
soft_fail:
- exit_status: 1
- exit_status: 3
test_targets:
- "--"
- "//tests/..."
test_flags:
- "--keep_going"
- "--test_tag_filters=-integration-test"
##ubuntu_rolling:
## name: "Default: Ubuntu, rolling Bazel"
## platform: ubuntu2204
## bazel: rolling
## # This is an advisory job; doesn't block merges
## soft_fail:
## - exit_status: 1
## - exit_status: 3
## test_targets:
## - "--"
## - "//tests/..."
## test_flags:
## - "--keep_going"
## - "--test_tag_filters=-integration-test"
ubuntu_workspace:
<<: *reusable_config
<<: *common_workspace_flags
Expand Down
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": {}
}
23 changes: 23 additions & 0 deletions .bcr/sphinxdocs/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
bcr_test_module:
module_path: "integration_tests/bcr"
matrix:
platform: ["debian11", "macos", "ubuntu2204"]
bazel: [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//sphinxdocs:readthedocs.bzl", "readthedocs_install")
load("@sphinxdocs//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
load("@sphinxdocs//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("@sphinxdocs//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//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//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//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//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//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//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//sphinxdocs:extra_defines=version=$READTHEDOCS_VERSION" \
"${extra_env[@]}" \
//docs:readthedocs_install
7 changes: 3 additions & 4 deletions python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ load(":stamp.bzl", "stamp_build_setting")
load(":uncachable_version_file.bzl", "define_uncachable_version_file")

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

licenses(["notice"])
Expand Down Expand Up @@ -689,9 +691,6 @@ bzl_library(
bzl_library(
name = "util_bzl",
srcs = ["util.bzl"],
visibility = [
"//:__subpackages__",
],
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=sphinxdocs/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
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")
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("//sphinxdocs/private:sphinx.bzl", "repeated_string_list_flag")

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

# Additional -D values to add to every Sphinx build.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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("//sphinxdocs/private:util.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility

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

# We only build for Linux and Mac because:
# 1. The actual doc process only runs on Linux
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
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
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
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ In the example below, `npm` is used to install Bazelisk and a helper shell
script, `readthedocs_build.sh` is used to construct the Bazel invocation.

The key purpose of the shell script it to set the
`--@rules_python//sphinxdocs:extra_env` and
`--@rules_python//sphinxdocs:extra_defines` flags. These are used to communicate
`@sphinxdocs//sphinxdocs::extra_env` and
`@sphinxdocs//sphinxdocs::extra_defines` flags. These are used to communicate
`READTHEDOCS*` environment variables and settings to the Bazel invocation.

## BUILD config
Expand Down Expand Up @@ -73,7 +73,7 @@ build:
```
# File: docs/BUILD

load("@rules_python//sphinxdocs:readthedocs.bzl.bzl", "readthedocs_install")
load("//:readthedocs.bzl", "readthedocs_install")
readthedocs_install(
name = "readthedocs_install",
docs = [":docs"],
Expand All @@ -90,17 +90,17 @@ set -eou pipefail
declare -a extra_env
while IFS='=' read -r -d '' name value; do
if [[ "$name" == READTHEDOCS* ]]; then
extra_env+=("--@rules_python//sphinxdocs:extra_env=$name=$value")
extra_env+=("--@sphinxdocs//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+=("--@rules_python//sphinxdocs:extra_env=HOSTNAME=$HOSTNAME")
extra_env+=("--@sphinxdocs//sphinxdocs:extra_env=HOSTNAME=$HOSTNAME")

set -x
bazel run \
--stamp \
"--@rules_python//sphinxdocs:extra_defines=version=$READTHEDOCS_VERSION" \
"--@sphinxdocs//sphinxdocs:extra_defines=version=$READTHEDOCS_VERSION" \
"${extra_env[@]}" \
//docs:readthedocs_install
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ a well known target.
## Configuring Sphinx

To enable the plugin in Sphinx, depend on
`@rules_python//sphinxdocs/src/sphinx_bzl` and enable it in `conf.py`:
`//sphinxdocs/src/sphinx_bzl` and enable it in `conf.py`:

```
extensions = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ While the `sphinx_stardoc` rule doesn't require Sphinx itself, the source
it generates requires some additional Sphinx plugins and config settings.

When defining the `sphinx_build_binary` target, also depend on:
* `@rules_python//sphinxdocs/src/sphinx_bzl:sphinx_bzl`
* `//sphinxdocs/src/sphinx_bzl:sphinx_bzl`
* `myst_parser` (e.g. `@pypi//myst_parser`)
* `typing_extensions` (e.g. `@pypi//myst_parser`)

```
sphinx_build_binary(
name = "sphinx-build",
deps = [
"@rules_python//sphinxdocs/src/sphinx_bzl",
"//sphinxdocs/src/sphinx_bzl",
"@pypi//myst_parser",
"@pypi//typing_extensions",
...
Expand Down
Loading