def test_environment_var_path(monkeypatch, tmp_path): install_folder = solcx.get_solc_folder() monkeypatch.setenv("SOLCX_BINARY_PATH", tmp_path.as_posix()) assert solcx.get_solc_folder() != install_folder monkeypatch.undo() assert solcx.get_solc_folder() == install_folder
def compile_solfiles(files, proj_dir, solc_version=None, output_values=OUTPUT_VALUES): remappings = [] node_modules_dir = find_node_modules_dir(proj_dir) if node_modules_dir is not None: zeppelin_path = os.path.abspath(os.path.join( node_modules_dir, 'zeppelin-solidity')) open_zeppelin_path = os.path.abspath( os.path.join(node_modules_dir, 'openzeppelin-solidity')) if os.path.isdir(zeppelin_path): remappings.append(f'zeppelin-solidity={zeppelin_path}') if os.path.isdir(open_zeppelin_path): remappings.append(f'openzeppelin-solidity={open_zeppelin_path}') if solc_version is None: solc_version = min(map(parse_version, files), key=_version_to_tuple) binary = os.path.join(get_solc_folder(), f'solc-v{solc_version}') combined_json = ','.join(output_values) compiler_kwargs = {'import_remappings': remappings, 'allow_paths': proj_dir, 'source_files': files, 'solc_binary': binary, 'combined_json': combined_json} try: stdoutdata, _, _, _ = solc_wrapper(**compiler_kwargs) return _parse_compiler_output(stdoutdata) except SolcError as e: raise SolidityCompilationException(e, files)
def _get_binary(solc_version): """Returns the binary for some version of solc. """ binary = os.path.join(get_solc_folder(), f'solc-v{solc_version}') if not os.path.exists(binary): raise AssertionError(f'solc binary not found for version: {solc_version}') return binary
def _get_binary(solc_version): """Returns the binary for some version of solc. """ binary = os.path.join(get_solc_folder(), f'solc-v{solc_version}') assert os.path.exists(binary), 'solc binary not found' return binary