@@ -97,7 +97,7 @@ def _resolve_virtuals(ctx, ignore_missing = False):
9797 missing = missing ,
9898 )
9999
100- def _make_import_path (label , workspace , base , imp ):
100+ def _make_import_path (label , workspace , imp ):
101101 if imp .startswith ("/" ):
102102 fail (
103103 "Import path '{imp}' on target {target} is invalid. Absolute paths are not supported." .format (
@@ -106,7 +106,7 @@ def _make_import_path(label, workspace, base, imp):
106106 ),
107107 )
108108
109- base_segments = base .split ("/" )
109+ base_segments = label . package .split ("/" )
110110 path_segments = imp .split ("/" )
111111
112112 relative_segments = 0
@@ -130,12 +130,11 @@ def _make_import_path(label, workspace, base, imp):
130130 if imp .startswith (".." ):
131131 return paths .normalize (paths .join (workspace , * (base_segments [0 :- relative_segments ] + path_segments [relative_segments :])))
132132 else :
133- return paths .normalize (paths .join (workspace , base , imp ))
133+ return paths .normalize (paths .join (workspace , label . package , imp ))
134134
135135def _make_imports_depset (ctx , imports = [], extra_imports_depsets = []):
136- base = paths .dirname (ctx .build_file_path )
137136 import_paths = [
138- _make_import_path (ctx .label , ctx .label .workspace_name or ctx .workspace_name , base , im )
137+ _make_import_path (ctx .label , ctx .label .workspace_name or ctx .workspace_name , im )
139138 for im in getattr (ctx .attr , "imports" , imports )
140139 ] + [
141140 # Add the workspace name in the imports such that repo-relative imports work.
0 commit comments