@@ -444,7 +444,7 @@ def _build_options(compiler_version: CompilerVersion, force_legacy_json: bool) -
444
444
return "abi,ast,bin,bin-runtime,srcmap,srcmap-runtime,userdoc,devdoc,hashes"
445
445
446
446
447
- # pylint: disable=too-many-arguments,too-many-locals,too-many-branches
447
+ # pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
448
448
def _run_solc (
449
449
compilation_unit : "CompilationUnit" ,
450
450
filename : str ,
@@ -521,15 +521,21 @@ def _run_solc(
521
521
if not compiler_version .version in [f"0.4.{ x } " for x in range (0 , 11 )]:
522
522
# Add . as default allowed path
523
523
if "--allow-paths" not in cmd :
524
- relative_filepath = filename
525
-
526
- if not working_dir :
527
- working_dir = os .getcwd ()
528
-
529
- if relative_filepath .startswith (str (working_dir )):
530
- relative_filepath = relative_filepath [len (str (working_dir )) + 1 :]
524
+ file_dir_start = os .path .normpath (os .path .dirname (filename ))
525
+ file_dir = os .path .abspath (file_dir_start )
526
+ if "," in file_dir :
527
+ try :
528
+ file_dir = os .path .relpath (file_dir_start )
529
+ except ValueError :
530
+ pass
531
+
532
+ if "," not in file_dir :
533
+ cmd += ["--allow-paths" , ".," + file_dir ]
534
+ else :
535
+ LOGGER .warning (
536
+ "Solc filepath contains a comma; omitting the --allow-paths argument. This may result in failed imports.\n "
537
+ )
531
538
532
- cmd += ["--allow-paths" , "." , relative_filepath ]
533
539
try :
534
540
LOGGER .info (
535
541
"'%s' running" ,
0 commit comments