Repository: eth-brownie/brownie
Issue: Cannot build solc on macOS

### Environment information

* `brownie` Version: 1.8.2
* `ganache-cli` Version: 6.9.1
* `solc` Version:  0.4.26+commit.4563c3fc.Darwin.appleclang
* Python Version: 3.8.2
* OS: osx

### What was wrong?
I'm trying to use Brownie on macOS Catalina 10.15.4, following this guide: https://medium.com/@iamdefinitelyahuman/ethereum-mainnet-testing-with-python-and-brownie-82a61dee0222

Unfortunately, when I try and construct a Contract it seems to fail to install solc, due to a limitation in py-solc-x. I already have solc version 0.4.26 installed via homebrew, so I'm not quite sure why brownie is trying to reinstall solc for me.

```
>>> address = "0xf79d6afbb6da890132f9d7c355e3015f15f3406f"
>>> oracle = Contract.from_explorer(address)

Fetching source of 0xF79D6aFBb6dA890132F9D7c355e3015f15F3406F from api.etherscan.io...
  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 630, in from_explorer
    build = compile_and_format(sources, solc_version=str(version), optimizer=optimizer)
  File "brownie/project/compiler/__init__.py", line 112, in compile_and_format
    set_solc_version(version)
  File "brownie/project/compiler/solidity.py", line 82, in set_solc_version
    install_solc(version)
  File "brownie/project/compiler/solidity.py", line 90, in install_solc
    solcx.install_solc(str(version), show_progress=True)
  File "solcx/install.py", line 229, in install_solc
    _install_solc_osx(version, allow_osx, show_progress, solcx_binary_path)
  File "solcx/install.py", line 332, in _install_solc_osx
    raise ValueError(
ValueError: Py-solc-x cannot build solc versions 0.4.x on OSX. If you install solc 0.4.x using brew and reload solcx, the installed version will be available. See https://github.com/ethereum/homebrew-ethereum for installation instructions.

To ignore this error, include 'allow_osx=True' when calling solcx.install_solc()
```

### How can it be fixed?

 I think probably there is a bug with detecting and using my installed version of `solc`. If it really does need to install a different version, then maybe try passing the `allow_osx=True` flag as suggested in the error message?


Changed files:
tests/network/contract/test_contract.py, brownie/network/contract.py

diff --git a/brownie/network/contract.py b/brownie/network/contract.py
index 54ad791c..588a59fb 100644
--- a/brownie/network/contract.py
+++ b/brownie/network/contract.py
@@ -3,6 +3,7 @@
 import json
 import os
 import re
+import sys
 import warnings
 from pathlib import Path
 from textwrap import TextWrapper
@@ -11,6 +12,7 @@ from urllib.parse import urlparse
 
 import eth_abi
 import requests
+import solcx
 from eth_utils import remove_0x_prefix
 from hexbytes import HexBytes
 from semantic_version import Version
@@ -618,7 +620,12 @@ class Contract(_DeployedContractBase):
             version = Version(data["result"][0]["CompilerVersion"].lstrip("v")).truncate()
         except Exception:
             version = Version("0.0.0")
-        if version < Version("0.4.22"):
+        if version < Version("0.4.22") or (
+            # special case for OSX because installing 0.4.x versions is problematic
+            sys.platform == "darwin"
+            and version < Version("0.5.0")
+            and f"v{version}" not in solcx.get_installed_solc_versions()
+        ):
             if not silent:
                 warnings.warn(
                     f"{address}: target compiler '{data['result'][0]['CompilerVersion']}' is "
diff --git a/tests/network/contract/test_contract.py b/tests/network/contract/test_contract.py
index 61ffa42b..1dc39c75 100644
--- a/tests/network/contract/test_contract.py
+++ b/tests/network/contract/test_contract.py
@@ -168,12 +168,24 @@ def test_from_explorer_only_abi(network):
 
 def test_from_explorer_pre_422(network):
     network.connect("mainnet")
-    contract = Contract.from_explorer("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2")
 
+    # MKR, compiler version 0.4.18
+    contract = Contract.from_explorer("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2")
     assert contract._name == "DSToken"
     assert "pcMap" not in contract._build
 
 
+def test_from_explorer_osx_pre_050(network, monkeypatch):
+    network.connect("mainnet")
+    monkeypatch.setattr("sys.platform", "darwin")
+    installed = ["v0.5.8", "v0.5.7"]
+    monkeypatch.setattr("solcx.get_installed_solc_versions", lambda: installed)
+
+    # chainlink, compiler version 0.4.24
+    contract = Contract.from_explorer("0xf79d6afbb6da890132f9d7c355e3015f15f3406f")
+    assert "pcMap" not in contract._build
+
+
 def test_from_explorer_vyper(network):
     network.connect("mainnet")
     contract = Contract.from_explorer("0x2157a7894439191e520825fe9399ab8655e0f708")