Skip to content

Commit 54d372a

Browse files
rickeylevaignas
andauthored
chore: split sphinxdocs into its own module (bazel-contrib#3629)
Splitting sphinxdocs into its own module is desirable to reduce the dependency footprint of rules_python outside of development mode modules. Work towards bazel-contrib#2511 --------- Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>
1 parent 7df7bd5 commit 54d372a

80 files changed

Lines changed: 296 additions & 71 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bazelci/presubmit.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,23 @@ tasks:
174174
test_targets: ["//..."]
175175
working_directory: gazelle
176176

177+
sphinxdocs_ubuntu:
178+
name: "Sphinxdocs: Ubuntu"
179+
working_directory: "sphinxdocs"
180+
platform: ubuntu2204
181+
build_targets:
182+
- "//..."
183+
test_targets:
184+
- "//..."
185+
sphinxdocs_mac:
186+
name: "Sphinxdocs: Mac"
187+
working_directory: "sphinxdocs"
188+
platform: macos_arm64
189+
build_targets:
190+
- "//..."
191+
test_targets:
192+
- "//..."
193+
177194
ubuntu_min_workspace:
178195
<<: *minimum_supported_version
179196
<<: *reusable_config

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ gazelle/examples/bzlmod_build_file_generation/bazel-bin
2929
gazelle/examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
3030
gazelle/examples/bzlmod_build_file_generation/bazel-out
3131
gazelle/examples/bzlmod_build_file_generation/bazel-testlog
32+
sphinxdocs
3233
tests/integration/compile_pip_requirements/bazel-compile_pip_requirements
3334
tests/integration/local_toolchains/bazel-local_toolchains
3435
tests/integration/py_cc_toolchain_registered/bazel-py_cc_toolchain_registered

.bcr/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
moduleRoots: [".", "gazelle"]
15+
moduleRoots: [".", "gazelle", "sphinxdocs"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"homepage": "https://github.com/bazel-contrib/rules_python",
3+
"maintainers": [
4+
{
5+
"name": "Richard Levasseur",
6+
"email": "richardlev@gmail.com",
7+
"github": "rickeylev"
8+
},
9+
{
10+
"name": "Ignas Anikevicius",
11+
"email": "bcr-ignas@use.startmail.com",
12+
"github": "aignas"
13+
}
14+
],
15+
"repository": [
16+
"github:bazelbuild/rules_python",
17+
"github:bazel-contrib/rules_python"
18+
],
19+
"versions": [],
20+
"yanked_versions": {}
21+
}

.bcr/sphinxdocs/presubmit.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
bcr_test_module:
2+
module_path: "integration_tests/bcr"
3+
matrix:
4+
platform: ["debian11", "macos", "ubuntu2204"]
5+
bazel: [8.*, 9.*]
6+
tasks:
7+
run_tests:
8+
name: "Run test module"
9+
platform: ${{ platform }}
10+
bazel: ${{ bazel }}
11+
shell_commands:
12+
- "echo 'common --override_module=rules_python=' >> .bazelrc"
13+
batch_commands:
14+
- "echo common --override_module=rules_python= >> .bazelrc"
15+
test_flags:
16+
# Minimum bazel supported C++
17+
- "--keep_going"
18+
- '--cxxopt=-std=c++17'
19+
- '--host_cxxopt=-std=c++17'
20+
build_targets:
21+
- "//..."
22+
test_targets:
23+
- "//..."
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "",
3+
"strip_prefix": "{REPO}-{VERSION}/sphinxdocs",
4+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_python-{TAG}.tar.gz"
5+
}

MODULE.bazel

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,13 @@ pip.parse(
211211
)
212212
use_repo(pip, "rules_python_publish_deps")
213213

214-
# Not a dev dependency to allow usage of //sphinxdocs code, which refers to stardoc repos.
215-
bazel_dep(name = "stardoc", version = "0.7.2", repo_name = "io_bazel_stardoc")
216-
217214
# ===== DEV ONLY DEPS AND SETUP BELOW HERE =====
215+
bazel_dep(name = "sphinxdocs", version = "0.0.0", dev_dependency = True)
216+
local_path_override(
217+
module_name = "sphinxdocs",
218+
path = "sphinxdocs",
219+
)
220+
218221
bazel_dep(name = "rules_bazel_integration_test", version = "0.27.0", dev_dependency = True)
219222
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
220223
bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)

docs/BUILD.bazel

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
load("@bazel_skylib//rules:build_test.bzl", "build_test")
1616
load("@dev_pip//:requirements.bzl", "requirement")
17+
load("@sphinxdocs//sphinxdocs:readthedocs.bzl", "readthedocs_install")
18+
load("@sphinxdocs//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
19+
load("@sphinxdocs//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
20+
load("@sphinxdocs//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardoc", "sphinx_stardocs")
1721
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
1822
load("//python/private:common_labels.bzl", "labels") # buildifier: disable=bzl-visibility
1923
load("//python/uv:lock.bzl", "lock") # buildifier: disable=bzl-visibility
20-
load("//sphinxdocs:readthedocs.bzl", "readthedocs_install")
21-
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
22-
load("//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
23-
load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardoc", "sphinx_stardocs")
2424

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

@@ -63,7 +63,7 @@ sphinx_docs(
6363
renamed_srcs = {
6464
"//:CHANGELOG.md": "changelog.md",
6565
"//:CONTRIBUTING.md": "contributing.md",
66-
"//sphinxdocs/inventories:bazel_inventory": "bazel_inventory.inv",
66+
"@sphinxdocs//sphinxdocs/inventories:bazel_inventory": "bazel_inventory.inv",
6767
},
6868
sphinx = ":sphinx-build",
6969
strip_prefix = package_name() + "/",
@@ -73,7 +73,7 @@ sphinx_docs(
7373
":bzl_api_docs",
7474
":py_api_srcs",
7575
":py_runtime_pair",
76-
"//sphinxdocs/docs:docs_lib",
76+
"@sphinxdocs//sphinxdocs/docs:docs_lib",
7777
],
7878
)
7979

@@ -182,7 +182,7 @@ sphinx_build_binary(
182182
requirement("typing_extensions"),
183183
requirement("sphinx_autodoc2"),
184184
requirement("sphinx_reredirects"),
185-
"//sphinxdocs/src/sphinx_bzl",
185+
"@sphinxdocs//sphinxdocs/src/sphinx_bzl",
186186
],
187187
)
188188

docs/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
copyright = "2023, The Bazel Authors"
88
author = "Bazel"
99

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

@@ -139,7 +139,10 @@
139139

140140
# --- Extlinks configuration
141141
extlinks = {
142-
"gh-issue": (f"https://github.com/bazel-contrib/rules_python/issues/%s", "#%s issue"),
142+
"gh-issue": (
143+
f"https://github.com/bazel-contrib/rules_python/issues/%s",
144+
"#%s issue",
145+
),
143146
"gh-path": (f"https://github.com/bazel-contrib/rules_python/tree/main/%s", "%s"),
144147
"gh-pr": (f"https://github.com/bazel-contrib/rules_python/pull/%s", "#%s PR"),
145148
}

docs/readthedocs_build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ set -eou pipefail
55
declare -a extra_env
66
while IFS='=' read -r -d '' name value; do
77
if [[ "$name" == READTHEDOCS* ]]; then
8-
extra_env+=("--//sphinxdocs:extra_env=$name=$value")
8+
extra_env+=("--@sphinxdocs//sphinxdocs:extra_env=$name=$value")
99
fi
1010
done < <(env -0)
1111

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

1515
export RULES_PYTHON_ENABLE_PIPSTAR=1
1616

1717
set -x
1818
export RULES_PYTHON_ENABLE_PIPSTAR=1
1919
bazel run \
2020
--config=rtd \
21-
"--//sphinxdocs:extra_defines=version=$READTHEDOCS_VERSION" \
21+
"--@sphinxdocs//sphinxdocs:extra_defines=version=$READTHEDOCS_VERSION" \
2222
"${extra_env[@]}" \
2323
//docs:readthedocs_install

0 commit comments

Comments
 (0)