diff --git a/MODULE.bazel b/MODULE.bazel index 72e8ae14..81c88685 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -29,7 +29,7 @@ bazel_dep(name = "rules_pkg", version = "1.1.0") # Python version # ############################################################################### -bazel_dep(name = "rules_python", version = "1.4.1") +bazel_dep(name = "rules_python", version = "1.5.0") PYTHON_VERSION = "3.12" diff --git a/src/extensions/BUILD b/src/extensions/BUILD index d4db4293..77ab9c60 100644 --- a/src/extensions/BUILD +++ b/src/extensions/BUILD @@ -20,4 +20,8 @@ py_library( srcs = ["@score_docs_as_code//src/extensions:score_plantuml.py"], imports = ["."], visibility = ["//visibility:public"], + deps = [ + "@rules_python//python/runfiles", + "@score_docs_as_code//src:plantuml_for_python", + ], ) diff --git a/src/extensions/score_plantuml.py b/src/extensions/score_plantuml.py index c452315e..0e887e15 100644 --- a/src/extensions/score_plantuml.py +++ b/src/extensions/score_plantuml.py @@ -24,10 +24,10 @@ In addition it sets common PlantUML options, like output to svg_obj. """ -import os import sys from pathlib import Path +from python.runfiles import Runfiles from sphinx.application import Sphinx from sphinx.util import logging @@ -35,13 +35,13 @@ def get_runfiles_dir() -> Path: - if r := os.getenv("RUNFILES_DIR"): + if (r := Runfiles.Create()) and (rd := r.EnvVars().get("RUNFILES_DIR")): # Runfiles are only available when running in Bazel. # bazel build and bazel run are both supported. # i.e. `bazel build //:docs` and `bazel run //:docs`. logger.debug("Using runfiles to determine plantuml path.") - runfiles_dir = Path(r) + runfiles_dir = Path(rd) else: # The only way to land here is when running from within the virtual