File tree 3 files changed +43
-1
lines changed
3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,21 @@ pip install py-solc
69
69
... " 606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273d3cda913deb6f67967b99d67acdfa1712c29360190630c55699c906064906000906004818660325a03f41560025750505056"
70
70
```
71
71
72
-
73
72
## Setting the path to the ` solc ` binary
74
73
75
74
You can use the environment variable ` SOLC_BINARY ` to set the path to your solc binary.
75
+
76
+ ## Import path remappings
77
+
78
+ ` solc ` provides path aliasing allow you to have more reusable project configurations.
79
+
80
+ You can use this like:
81
+
82
+ ```
83
+ from solc import compile_source, compile_files, link_code
84
+
85
+ compile_files([source_file_path], remappings=["zeppeling=/my-zeppelin-checkout-folder"])
86
+ ```
87
+
88
+ [ More information about solc import aliasing] ( http://solidity.readthedocs.io/en/develop/layout-of-source-files.html#paths )
89
+
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ def solc_wrapper(solc_binary=SOLC_BINARY,
29
29
gas = None ,
30
30
assemble = None ,
31
31
link = None ,
32
+ remappings = None ,
32
33
source_files = None ,
33
34
import_remappings = None ,
34
35
ast = None ,
Original file line number Diff line number Diff line change
1
+ import os
2
+
3
+ from solc import (
4
+ get_solc_version ,
5
+ compile_files ,
6
+ )
7
+
8
+
9
+ def test_remappings (contracts_dir ):
10
+ IMPORT_SOURCE = "contract Bar {}"
11
+ SOURCE = 'import "bar/moo.sol"; contract Foo is Bar { function Foo() {} function return13() returns (uint) { return 13; } }'
12
+
13
+ baz_path = os .path .abspath (os .path .join (contracts_dir , "baz" ))
14
+ os .makedirs (baz_path )
15
+
16
+ source_file_path = os .path .join (baz_path , 'Moo.sol' )
17
+ with open (source_file_path , 'w' ) as source_file :
18
+ source_file .write (IMPORT_SOURCE )
19
+
20
+ source_file_path = os .path .join (contracts_dir , 'Foo.sol' )
21
+ with open (source_file_path , 'w' ) as source_file :
22
+ source_file .write (SOURCE )
23
+
24
+ output = compile_files ([source_file_path ], remappings = ["bar={}" .format (baz_path )])
25
+
26
+ assert output
27
+ assert 'Foo' in output
You can’t perform that action at this time.
0 commit comments