diff --git a/.github/workflows/pip-audit.yml b/.github/workflows/pip-audit.yml index 39cbb9c..3860538 100644 --- a/.github/workflows/pip-audit.yml +++ b/.github/workflows/pip-audit.yml @@ -26,7 +26,7 @@ jobs: python -m venv /tmp/pip-audit-env source /tmp/pip-audit-env/bin/activate - python -m pip install --upgrade pip + python -m pip install --upgrade pip setuptools wheel python -m pip install . diff --git a/setup.py b/setup.py index 48d2151..ffa5639 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ description="Manage multiple Solidity compiler versions.", url="https://github.com/crytic/solc-select", author="Trail of Bits", - version="1.0.2", + version="1.0.3", packages=find_packages(), python_requires=">=3.6", license="AGPL-3.0", diff --git a/solc_select/constants.py b/solc_select/constants.py index 5d7a238..5513306 100644 --- a/solc_select/constants.py +++ b/solc_select/constants.py @@ -20,3 +20,9 @@ WINDOWS_AMD64 = "windows-amd64" EARLIEST_RELEASE = {"macosx-amd64": "0.3.6", "linux-amd64": "0.4.0", "windows-amd64": "0.4.5"} + +# URL +CRYTIC_SOLC_ARTIFACTS = "https://raw.githubusercontent.com/crytic/solc/master/linux/amd64/" +CRYTIC_SOLC_JSON = ( + "https://raw.githubusercontent.com/crytic/solc/new-list-json/linux/amd64/list.json" +) diff --git a/solc_select/solc_select.py b/solc_select/solc_select.py index 649dfd5..930ec42 100644 --- a/solc_select/solc_select.py +++ b/solc_select/solc_select.py @@ -17,6 +17,8 @@ EARLIEST_RELEASE, SOLC_SELECT_DIR, ARTIFACTS_DIR, + CRYTIC_SOLC_ARTIFACTS, + CRYTIC_SOLC_JSON, ) Path.mkdir(ARTIFACTS_DIR, parents=True, exist_ok=True) @@ -44,22 +46,25 @@ def upgrade_architecture() -> None: def current_version() -> (str, str): - version = os.environ.get("SOLC_VERSION") source = "SOLC_VERSION" - if version: - if version not in installed_versions(): - raise argparse.ArgumentTypeError( - f"Version '{version}' not installed (set by {source}). Run `solc-select install {version}`." - ) - else: - source = SOLC_SELECT_DIR.joinpath("global-version") - if Path.is_file(source): - with open(source, encoding="utf-8") as f: + version = os.environ.get(source) + if not version: + source_path = SOLC_SELECT_DIR.joinpath("global-version") + source = source_path.as_posix() + if Path.is_file(source_path): + with open(source_path, encoding="utf-8") as f: version = f.read() else: raise argparse.ArgumentTypeError( "No solc version set. Run `solc-select use VERSION` or set SOLC_VERSION environment variable." ) + versions = installed_versions() + if version not in versions: + raise argparse.ArgumentTypeError( + f"\nVersion '{version}' not installed (set by {source})." + f"\nRun `solc-select install {version}`." + f"\nOr use one of the following versions: {versions}" + ) return version, source @@ -78,6 +83,11 @@ def install_artifacts(versions: [str]) -> bool: continue (url, _) = get_url(version, artifact) + + if is_linux_0818(version): + url = CRYTIC_SOLC_ARTIFACTS + artifact + print(url) + artifact_file_dir = ARTIFACTS_DIR.joinpath(f"solc-{version}") Path.mkdir(artifact_file_dir, parents=True, exist_ok=True) print(f"Installing '{version}'...") @@ -103,6 +113,10 @@ def is_older_linux(version: str) -> bool: return soliditylang_platform() == LINUX_AMD64 and Version(version) <= Version("0.4.10") +def is_linux_0818(version: str) -> bool: + return soliditylang_platform() == LINUX_AMD64 and Version(version) == Version("0.8.18") + + def is_older_windows(version: str) -> bool: return soliditylang_platform() == WINDOWS_AMD64 and Version(version) <= Version("0.7.1") @@ -148,8 +162,8 @@ def get_url(version: str = "", artifact: str = "") -> (str, str): if soliditylang_platform() == LINUX_AMD64: if version != "" and is_older_linux(version): return ( - f"https://raw.githubusercontent.com/crytic/solc/master/linux/amd64/{artifact}", - "https://raw.githubusercontent.com/crytic/solc/new-list-json/linux/amd64/list.json", + CRYTIC_SOLC_ARTIFACTS + artifact, + CRYTIC_SOLC_JSON, ) return ( f"https://binaries.soliditylang.org/{soliditylang_platform()}/{artifact}",