Skip to content

Commit

Permalink
osx support for import_installed_solc, raise on install 0.4.x in OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Apr 9, 2019
1 parent bf93157 commit 1c276ee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

- Fix "No input files given" bug in `solcx.compile_source()` on v0.5.x
- `install.py` - replace `os.path` with `pathlib.Path`
- Linux/OSX - copy from `which solc` path to save time installing solc
- Linux - copy from `which solc` path to save time installing solc
- OSX - copy solc versions from `usr/local/Cellar`, raise when attempting v0.4.x install

0.1.1
-----
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='py-solc-x',
version='0.1.1',
version='0.2.0',
description="""Python wrapper around the solc binary with 0.5.x support""",
long_description_markdown_filename='README.md',
author='Benjamin Hauser (forked from py-solc by Piper Merriam)',
Expand Down
25 changes: 17 additions & 8 deletions solcx/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ def get_solc_folder():


def import_installed_solc():
if sys.platform == "win32":
return
path = subprocess.check_output(['which','solc']).decode().strip()
if not path:
if sys.platform.startswith('linux'):
path_list = [subprocess.check_output(['which','solc']).decode().strip()]
if not path_list[0]:
return
elif sys.platform == 'darwin':
path_list = [str(i) for i in Path('/usr/local/Cellar').glob('solidity*/**/solc')]
else:
return
version = subprocess.check_output([path, '--version']).decode()
version = "v"+version[version.index("Version: ")+9:version.index('+')]
if version not in get_installed_solc_versions():
for path in path_list:
version = subprocess.check_output([path, '--version']).decode()
version = "v"+version[version.index("Version: ")+9:version.index('+')]
if version in get_installed_solc_versions():
continue
shutil.copy(path, str(get_solc_folder().joinpath("solc-" + version)))
return version


def get_executable(version=None):
Expand Down Expand Up @@ -139,6 +143,11 @@ def _install_solc_windows(version):


def _install_solc_osx(version):
if "v0.4" in version:
raise ValueError(
"Py-solc-x cannot build solc versions 0.4.x on OSX. If you install solc 0.4.x\n"
"using brew and reload solcx, the installed version will be available.\n\n"
"See https://github.com/ethereum/homebrew-ethereum for installation instructions.")
tar_path = get_solc_folder().joinpath("solc-{}.tar.gz".format(version))
source_folder = get_solc_folder().joinpath("solidity_" + version[1:])
download = DOWNLOAD_BASE.format(version, "solidity_{}.tar.gz".format(version[1:]))
Expand Down

0 comments on commit 1c276ee

Please sign in to comment.