diff --git a/CHANGELOG.md b/CHANGELOG.md index 40d1affe0f..0df0de8cee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -135,6 +135,8 @@ END_UNRELEASED_TEMPLATE * (gazelle) Fix `gazelle_python_manifest.test` so that it accesses manifest files via `runfile` path handling rather than directly ([#3397](https://github.com/bazel-contrib/rules_python/issues/3397)). * (core rules) For the system_python bootstrap, the runfiles root is added to sys.path. +* (sphinxdocs) The sphinxdocs `.serve` target is now compatible with Bazel's `--symlink_prefix` + flag ([#3410](https://github.com/bazel-contrib/rules_python/issues/3410)). {#v1-8-0-added} ### Added diff --git a/sphinxdocs/private/sphinx.bzl b/sphinxdocs/private/sphinx.bzl index e444429233..0efbc269c5 100644 --- a/sphinxdocs/private/sphinx.bzl +++ b/sphinxdocs/private/sphinx.bzl @@ -189,8 +189,9 @@ def sphinx_docs( srcs = [_SPHINX_SERVE_MAIN_SRC], main = _SPHINX_SERVE_MAIN_SRC, data = [html_name], + deps = [Label("//python/runfiles")], args = [ - "$(execpath {})".format(html_name), + "$(rlocationpath {})".format(html_name), ], **common_kwargs_with_manual_tag ) diff --git a/sphinxdocs/private/sphinx_server.py b/sphinxdocs/private/sphinx_server.py index 1f4fae86de..1bd6ee5550 100644 --- a/sphinxdocs/private/sphinx_server.py +++ b/sphinxdocs/private/sphinx_server.py @@ -5,11 +5,15 @@ import time from http import server +from python.runfiles import Runfiles + def main(argv): - build_workspace_directory = os.environ["BUILD_WORKSPACE_DIRECTORY"] - docs_directory = argv[1] - serve_directory = os.path.join(build_workspace_directory, docs_directory) + r = Runfiles.Create() + serve_directory = r.Rlocation(argv[1]) + if not serve_directory: + print(f"Error: could not find runfile for '{argv[1]}'", file=sys.stderr) + return 1 class DirectoryHandler(server.SimpleHTTPRequestHandler): def __init__(self, *args, **kwargs):