Skip to content

Commit 473b365

Browse files
committed
compiler version to use solc binary and gevent subprocess
1 parent dc581b9 commit 473b365

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

solc/main.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
is_solc_available = functools.partial(is_executable_available, SOLC_BINARY)
2828

2929

30-
def get_solc_version():
31-
stdoutdata, stderrdata = solc_wrapper(version=True)
30+
def get_solc_version(**kwargs):
31+
kwargs['version'] = True
32+
stdoutdata, stderrdata = solc_wrapper(**kwargs)
3233
version_match = version_regex.search(stdoutdata)
3334
if version_match is None:
3435
raise SolcError(
@@ -39,7 +40,7 @@ def get_solc_version():
3940
return version_match.groups()[0]
4041

4142

42-
def _parse_compiler_output(stdoutdata):
43+
def _parse_compiler_output(stdoutdata, compiler_version):
4344

4445
output = json.loads(stdoutdata)
4546

@@ -55,8 +56,6 @@ def _parse_compiler_output(stdoutdata):
5556

5657
sorted_contracts = sorted(contracts.items(), key=lambda c: c[0])
5758

58-
compiler_version = get_solc_version()
59-
6059
return {
6160
contract_name: {
6261
'abi': contract_data['abi'],
@@ -106,7 +105,9 @@ def compile_source(source, output_values=ALL_OUTPUT_VALUES, **kwargs):
106105
**kwargs
107106
)
108107

109-
contracts = _parse_compiler_output(stdoutdata)
108+
compiler_version = get_solc_version(version=True, **kwargs)
109+
110+
contracts = _parse_compiler_output(stdoutdata, compiler_version)
110111
return contracts
111112

112113

@@ -128,7 +129,9 @@ def compile_files(source_files, output_values=ALL_OUTPUT_VALUES, **kwargs):
128129
**kwargs
129130
)
130131

131-
contracts = _parse_compiler_output(stdoutdata)
132+
compiler_version = get_solc_version(version=True, **kwargs)
133+
134+
contracts = _parse_compiler_output(stdoutdata, compiler_version)
132135
return contracts
133136

134137

solc/wrapper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

3-
import subprocess
3+
from gevent import subprocess
4+
45
import textwrap
56

67
from .exceptions import (

0 commit comments

Comments
 (0)