Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pip-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions solc_select/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
38 changes: 26 additions & 12 deletions solc_select/solc_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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


Expand All @@ -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}'...")
Expand All @@ -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")

Expand Down Expand Up @@ -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}",
Expand Down