Skip to content

Commit 64801ce

Browse files
committed
fix: all path references should be relative to base_dir
1 parent cdaf841 commit 64801ce

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

ape_solidity/compiler.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ def get_import_remapping(self, base_path: Optional[Path] = None) -> Dict[str, st
222222

223223
# We use these helpers to transform the values configured
224224
# to values matching files in the compiler cache folder.
225-
builder = ImportRemappingBuilder(self.project_manager.compiler_cache_folder)
225+
builder = ImportRemappingBuilder(
226+
get_relative_path(self.project_manager.compiler_cache_folder, base_path)
227+
)
226228
packages_cache = self.config_manager.packages_folder
227229

228230
# Here we hash and validate if there were changes to remappings.
@@ -391,7 +393,10 @@ def get_compiler_settings(
391393
for solc_version, sources in files_by_solc_version.items():
392394
version_settings: Dict[str, Union[Any, List[Any]]] = {
393395
"optimizer": {"enabled": self.settings.optimize, "runs": DEFAULT_OPTIMIZATION_RUNS},
394-
"outputSelection": {str(p): {"*": OUTPUT_SELECTION, "": ["ast"]} for p in sources},
396+
"outputSelection": {
397+
str(get_relative_path(p, base_path)): {"*": OUTPUT_SELECTION, "": ["ast"]}
398+
for p in sources
399+
},
395400
}
396401
if remappings_used := self._get_used_remappings(
397402
sources, remappings=import_remappings, base_path=base_path
@@ -424,14 +429,16 @@ def _get_used_remappings(
424429
# No remappings used at all.
425430
return {}
426431

432+
relative_cache = get_relative_path(self.project_manager.compiler_cache_folder, base_path)
433+
427434
# Filter out unused import remapping.
428435
return {
429436
k: v
430437
for source in (
431438
x
432439
for sourceset in self.get_imports(list(sources), base_path=base_path).values()
433440
for x in sourceset
434-
if str(self.project_manager.compiler_cache_folder) in x
441+
if str(relative_cache) in x
435442
)
436443
for parent_key in (
437444
os.path.sep.join(source.split(os.path.sep)[:3]) for source in [source]
@@ -838,9 +845,7 @@ def _get_imported_source_paths(
838845
return set()
839846

840847
source_ids_checked.append(source_identifier)
841-
import_file_paths = [
842-
(base_path / i).resolve() for i in imports.get(source_identifier, []) if i
843-
]
848+
import_file_paths = [base_path / i for i in imports.get(source_identifier, []) if i]
844849
return_set = {i for i in import_file_paths}
845850
for import_path in import_file_paths:
846851
indirect_imports = self._get_imported_source_paths(

0 commit comments

Comments
 (0)