4848 "filter_to_py_srcs" ,
4949 "get_imports" ,
5050 "is_bool" ,
51+ "runfiles_root_path" ,
5152 "target_platform_has_any_constraint" ,
5253 "union_attrs" ,
5354)
@@ -447,7 +448,7 @@ def _create_executable(
447448 )
448449
449450def _create_zip_main (ctx , * , stage2_bootstrap , runtime_details , venv ):
450- python_binary = _runfiles_root_path (ctx , venv .interpreter .short_path )
451+ python_binary = runfiles_root_path (ctx , venv .interpreter .short_path )
451452 python_binary_actual = venv .interpreter_actual_path
452453
453454 # The location of this file doesn't really matter. It's added to
@@ -522,7 +523,7 @@ def _create_venv(ctx, output_prefix, imports, runtime_details):
522523
523524 if not venvs_use_declare_symlink_enabled :
524525 if runtime .interpreter :
525- interpreter_actual_path = _runfiles_root_path (ctx , runtime .interpreter .short_path )
526+ interpreter_actual_path = runfiles_root_path (ctx , runtime .interpreter .short_path )
526527 else :
527528 interpreter_actual_path = runtime .interpreter_path
528529
@@ -543,11 +544,11 @@ def _create_venv(ctx, output_prefix, imports, runtime_details):
543544 # may choose to write what symlink() points to instead.
544545 interpreter = ctx .actions .declare_symlink ("{}/bin/{}" .format (venv , py_exe_basename ))
545546
546- interpreter_actual_path = _runfiles_root_path (ctx , runtime .interpreter .short_path )
547+ interpreter_actual_path = runfiles_root_path (ctx , runtime .interpreter .short_path )
547548 rel_path = relative_path (
548549 # dirname is necessary because a relative symlink is relative to
549550 # the directory the symlink resides within.
550- from_ = paths .dirname (_runfiles_root_path (ctx , interpreter .short_path )),
551+ from_ = paths .dirname (runfiles_root_path (ctx , interpreter .short_path )),
551552 to = interpreter_actual_path ,
552553 )
553554
@@ -646,23 +647,6 @@ def _create_stage2_bootstrap(
646647 )
647648 return output
648649
649- def _runfiles_root_path (ctx , short_path ):
650- """Compute a runfiles-root relative path from `File.short_path`
651-
652- Args:
653- ctx: current target ctx
654- short_path: str, a main-repo relative path from `File.short_path`
655-
656- Returns:
657- {type}`str`, a runflies-root relative path
658- """
659-
660- # The ../ comes from short_path is for files in other repos.
661- if short_path .startswith ("../" ):
662- return short_path [3 :]
663- else :
664- return "{}/{}" .format (ctx .workspace_name , short_path )
665-
666650def _create_stage1_bootstrap (
667651 ctx ,
668652 * ,
@@ -676,7 +660,7 @@ def _create_stage1_bootstrap(
676660 runtime = runtime_details .effective_runtime
677661
678662 if venv :
679- python_binary_path = _runfiles_root_path (ctx , venv .interpreter .short_path )
663+ python_binary_path = runfiles_root_path (ctx , venv .interpreter .short_path )
680664 else :
681665 python_binary_path = runtime_details .executable_interpreter_path
682666
0 commit comments