diff --git a/CHANGELOG.md b/CHANGELOG.md index 96e86b97fb..31ec2af361 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,27 @@ BEGIN_UNRELEASED_TEMPLATE END_UNRELEASED_TEMPLATE --> +{#v0-0-0} +## Unreleased + +[0.0.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.0.0 + +{#v0-0-0-removed} +### Removed +* Nothing removed. + +{#v0-0-0-changed} +### Changed +* Nothing changed. + +{#v0-0-0-fixed} +### Fixed +* (bootstrap) Fixed incorrect runfiles path construction in bootstrap scripts when binary is defined in another bazel module + +{#v0-0-0-added} +### Added +* Nothing added. + {#v1-9-0} ## [1.9.0] - 2026-02-21 diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index 284aea6bff..495c7dddcf 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -510,10 +510,7 @@ def _create_zip_main(ctx, *, stage2_bootstrap, runtime_details, venv): substitutions = { "%python_binary%": python_binary, "%python_binary_actual%": python_binary_actual, - "%stage2_bootstrap%": "{}/{}".format( - ctx.workspace_name, - stage2_bootstrap.short_path, - ), + "%stage2_bootstrap%": runfiles_root_path(ctx, stage2_bootstrap.short_path), "%workspace_name%": ctx.workspace_name, }, ) @@ -616,7 +613,7 @@ def _create_venv(ctx, output_prefix, imports, runtime_details, add_runfiles_root "%add_runfiles_root_to_sys_path%": add_runfiles_root_to_sys_path, "%coverage_tool%": _get_coverage_tool_runfiles_path(ctx, runtime), "%import_all%": "True" if read_possibly_native_flag(ctx, "python_import_all_repositories") else "False", - "%site_init_runfiles_path%": "{}/{}".format(ctx.workspace_name, site_init.short_path), + "%site_init_runfiles_path%": runfiles_root_path(ctx, site_init.short_path), "%workspace_name%": ctx.workspace_name, }, computed_substitutions = computed_subs, @@ -671,10 +668,7 @@ def _get_coverage_tool_runfiles_path(ctx, runtime): if (ctx.configuration.coverage_enabled and runtime and runtime.coverage_tool): - return "{}/{}".format( - ctx.workspace_name, - runtime.coverage_tool.short_path, - ) + return runfiles_root_path(ctx, runtime.coverage_tool.short_path) else: return "" @@ -777,10 +771,7 @@ def _create_stage1_bootstrap( if (ctx.configuration.coverage_enabled and runtime and runtime.coverage_tool): - coverage_tool_runfiles_path = "{}/{}".format( - ctx.workspace_name, - runtime.coverage_tool.short_path, - ) + coverage_tool_runfiles_path = runfiles_root_path(ctx, runtime.coverage_tool.short_path) else: coverage_tool_runfiles_path = "" if runtime: @@ -793,7 +784,7 @@ def _create_stage1_bootstrap( subs["%coverage_tool%"] = coverage_tool_runfiles_path subs["%import_all%"] = ("True" if read_possibly_native_flag(ctx, "python_import_all_repositories") else "False") subs["%imports%"] = ":".join(imports.to_list()) - subs["%main%"] = "{}/{}".format(ctx.workspace_name, main_py.short_path) + subs["%main%"] = runfiles_root_path(ctx, main_py.short_path) ctx.actions.expand_template( template = template,