From f42f0cd947486e1333c187d37927112624f27e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Tue, 31 Dec 2024 18:47:56 +0100 Subject: [PATCH 1/3] Replace `setup.py` with `pyproject.toml` Closes #186 --- pyproject.toml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 22 ---------------------- 2 files changed, 46 insertions(+), 22 deletions(-) delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml index e430d08..d09b2a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,49 @@ +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "solc-select" +version = "1.0.4" +dependencies = [ + "pycryptodome>=3.4.6", + "packaging", +] +requires-python = ">= 3.8" +authors = [ + {name = "Trail of Bits", email = "opensource@trailofbits.com"}, +] +maintainers = [ + {name = "Trail of Bits", email = "opensource@trailofbits.com"}, +] +description = "Manage multiple Solidity compiler versions." +readme = "README.md" +license = {file = "LICENSE"} +keywords = ["solc", "solidity", "ethereum", "compiler", "version manager"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Compilers", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] + +[project.urls] +Homepage = "https://github.com/crytic/solc-select" +Repository = "https://github.com/crytic/solc-select.git" +Issues = "https://github.com/crytic/solc-select/issues" + +[project.scripts] +solc-select = "solc_select.__main__:solc_select" +solc = "solc_select.__main__:solc" + [tool.black] target-version = ["py38"] line-length = 100 diff --git a/setup.py b/setup.py deleted file mode 100644 index 2fe3373..0000000 --- a/setup.py +++ /dev/null @@ -1,22 +0,0 @@ -from setuptools import find_packages, setup - -setup( - name="solc-select", - description="Manage multiple Solidity compiler versions.", - url="https://github.com/crytic/solc-select", - author="Trail of Bits", - version="1.0.4", - packages=find_packages(), - python_requires=">=3.8", - license="AGPL-3.0", - # pylint: disable=consider-using-with - long_description=open("README.md", encoding="utf8").read(), - long_description_content_type="text/markdown", - entry_points={ - "console_scripts": [ - "solc-select = solc_select.__main__:solc_select", - "solc = solc_select.__main__:solc", - ] - }, - install_requires=["pycryptodome>=3.4.6", "packaging"], -) From 9eaa8e2c604d68a5dbaf13a8b0d49d64dfff3837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Tue, 31 Dec 2024 18:51:48 +0100 Subject: [PATCH 2/3] Fix tests after `setup.py` removal --- scripts/test_linux.sh | 2 +- scripts/test_solc_upgrade.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/test_linux.sh b/scripts/test_linux.sh index ea9d6c9..85e2999 100644 --- a/scripts/test_linux.sh +++ b/scripts/test_linux.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -sudo python3 setup.py install +sudo pip3 install . solc-select install all use_version=$(solc-select use 0.4.0) diff --git a/scripts/test_solc_upgrade.sh b/scripts/test_solc_upgrade.sh index 2f3ff80..7eac93e 100644 --- a/scripts/test_solc_upgrade.sh +++ b/scripts/test_solc_upgrade.sh @@ -8,7 +8,7 @@ solc-select install 0.4.11 0.5.0 0.6.12 0.7.3 0.8.3 all_old_versions=$(solc-select versions) ### Install new version of solc -sudo python3 setup.py develop +sudo pip3 install -e . new_solc_version=$(solc --version) all_new_versions=$(solc-select versions) From ff28aa683ffba8243e9df4e5fdff3555a9b354ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Tue, 31 Dec 2024 18:56:19 +0100 Subject: [PATCH 3/3] Fix test failure checking --- scripts/test_linux.sh | 5 +++-- scripts/test_macos.sh | 5 +++-- scripts/test_solc.sh | 31 ++++++++++++++----------------- scripts/test_solc_upgrade.sh | 8 +++++--- scripts/test_windows.sh | 5 +++-- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/scripts/test_linux.sh b/scripts/test_linux.sh index 85e2999..6564bf1 100644 --- a/scripts/test_linux.sh +++ b/scripts/test_linux.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail sudo pip3 install . solc-select install all @@ -19,14 +20,14 @@ if [[ $use_version != "Switched global version to $latest_release" ]]; then fi echo "LINUX SUCCESS: maximum version" -use_version=$(solc-select use 0.3.9 2>&1) +use_version=$(solc-select use 0.3.9 2>&1 || true) if [[ $use_version != *"Invalid version - only solc versions above '0.4.0' are available"* ]]; then echo "LINUX FAILED: version too low" exit 255 fi echo "LINUX SUCCESS: version too low" -use_version=$(solc-select use 0.100.8 2>&1) +use_version=$(solc-select use 0.100.8 2>&1 || true) if [[ $use_version != *"Invalid version '$latest_release' is the latest available version"* ]]; then echo "LINUX FAILED: version too high" exit 255 diff --git a/scripts/test_macos.sh b/scripts/test_macos.sh index e1ad95b..232605e 100644 --- a/scripts/test_macos.sh +++ b/scripts/test_macos.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail use_version=$(solc-select use 0.3.6) if [[ $use_version != "Switched global version to 0.3.6"* ]]; then @@ -16,14 +17,14 @@ if [[ $use_version != "Switched global version to $latest_release" ]]; then fi echo "OS X SUCCESS: set maximum version" -use_version=$(solc-select use 0.3.5 2>&1) +use_version=$(solc-select use 0.3.5 2>&1 || true) if [[ $use_version != *"Invalid version - only solc versions above '0.3.6' are available"* ]]; then echo "OS X FAILED: version too low" exit 255 fi echo "OS X SUCCESS: version too low" -use_version=$(solc-select use 0.100.8 2>&1) +use_version=$(solc-select use 0.100.8 2>&1 || true) if [[ $use_version != *"Invalid version '$latest_release' is the latest available version"* ]]; then echo "OS X FAILED: version too high" exit 255 diff --git a/scripts/test_solc.sh b/scripts/test_solc.sh index 3b1f6c8..db20a04 100644 --- a/scripts/test_solc.sh +++ b/scripts/test_solc.sh @@ -1,3 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail + ## solc 0.4.5 ## solc-select use 0.4.5 &> /dev/null solc ./scripts/solidity_tests/solc045_success.sol @@ -8,7 +11,7 @@ if [[ $? != 0 ]]; then fi echo "SUCCESS: solc045_success" -execute=$(solc ./scripts/solidity_tests/solc045_fail_compile.sol 2>&1) +execute=$(solc ./scripts/solidity_tests/solc045_fail_compile.sol 2>&1 || true) if [[ "$execute" != *"Error: Expected token Semicolon got 'Function'"* ]]; then echo "FAILED: solc045_fail_compile" echo "$execute" @@ -26,7 +29,7 @@ if [[ $? != 0 ]]; then fi echo "SUCCESS: solc050_success" -execute=$(solc ./scripts/solidity_tests/solc050_fail_compile.sol 2>&1) +execute=$(solc ./scripts/solidity_tests/solc050_fail_compile.sol 2>&1 || true) if [[ "$execute" != *"Error: Functions are not allowed to have the same name as the contract."* ]]; then echo "FAILED: solc050_fail_compile" exit 255 @@ -35,17 +38,14 @@ echo "SUCCESS: solc050_fail_compile" ## solc 0.6.0 ## solc-select use 0.6.0 &> /dev/null -solc ./scripts/solidity_tests/solc060_success_trycatch.sol -if [[ $? != 0 ]]; then +if ! solc ./scripts/solidity_tests/solc060_success_trycatch.sol; then echo "FAILED: solc060_success_trycatch" $? exit 255 fi echo "SUCCESS: solc060_success_trycatch" -solc ./scripts/solidity_tests/solc060_success_receive.sol - -if [[ $? != 0 ]]; then +if ! solc ./scripts/solidity_tests/solc060_success_receive.sol; then echo "FAILED: solc060_success_receive" $? exit 255 fi @@ -54,16 +54,14 @@ echo "SUCCESS: solc060_success_receive" ## solc 0.7.0 ## solc-select use 0.7.0 &> /dev/null -execute=$(solc ./scripts/solidity_tests/solc070_fail_compile.sol 2>&1) +execute=$(solc ./scripts/solidity_tests/solc070_fail_compile.sol 2>&1 || true) if [[ "$execute" != *"\"now\" has been deprecated."* ]]; then echo "FAILED: solc070_fail_compile" "$execute" exit 255 fi echo "SUCCESS: solc070_fail_compile" -solc ./scripts/solidity_tests/solc070_success.sol - -if [[ $? != 0 ]]; then +if ! solc ./scripts/solidity_tests/solc070_success.sol; then echo "FAILED: solc070_success" $? exit 255 fi @@ -71,22 +69,21 @@ echo "SUCCESS: solc070_success" ## solc 0.8.0 ## solc-select use 0.8.0 &> /dev/null -solc ./scripts/solidity_tests/solc080_success.sol -if [[ $? != 0 ]]; then +if ! solc ./scripts/solidity_tests/solc080_success.sol; then echo "FAILED: solc080_success" $? exit 255 fi echo "SUCCESS: solc080_success" -execute=$(solc ./scripts/solidity_tests/solc080_success_warning.sol 2>&1) +execute=$(solc ./scripts/solidity_tests/solc080_success_warning.sol 2>&1 || true) if [[ "$execute" != *"Warning: Function state mutability can be restricted to pure"* ]]; then echo "FAILED: solc080_success_warning" exit 255 fi echo "SUCCESS: solc080_success_warning" -execute=$(solc ./scripts/solidity_tests/solc080_fail_compile.sol 2>&1) +execute=$(solc ./scripts/solidity_tests/solc080_fail_compile.sol 2>&1 || true) if [[ "$execute" != *"Error: Explicit type conversion not allowed"* ]]; then echo "FAILED: solc080_fail_compile" exit 255 @@ -100,11 +97,11 @@ if [[ "$execute" != *"Switched global version to 0.8.9"* ]]; then echo "FAILED: use - always install" exit 255 fi -echo "SUCCESS: use - always install" +echo "SUCCESS: use - always install" UNINSTALL_PATH=$HOME/.solc-select/artifacts/solc-0.8.1 rm -rf $UNINSTALL_PATH # uninstall solc 0.8.1 -execute=$(solc-select use 0.8.1 2>&1) +execute=$(solc-select use 0.8.1 2>&1 || true) if [[ $execute != *"'0.8.1' must be installed prior to use"* ]]; then echo "FAILED: use - no install" exit 255 diff --git a/scripts/test_solc_upgrade.sh b/scripts/test_solc_upgrade.sh index 7eac93e..de504d0 100644 --- a/scripts/test_solc_upgrade.sh +++ b/scripts/test_solc_upgrade.sh @@ -1,16 +1,18 @@ #!/usr/bin/env bash +set -euo pipefail ### Install old version of solc -sudo pip3 uninstall solc-select +sudo pip3 uninstall --yes solc-select sudo pip3 install solc-select +solc-select use 0.8.0 --always-install old_solc_version=$(solc --version) solc-select install 0.4.11 0.5.0 0.6.12 0.7.3 0.8.3 -all_old_versions=$(solc-select versions) +all_old_versions=$(solc-select versions | sort) ### Install new version of solc sudo pip3 install -e . new_solc_version=$(solc --version) -all_new_versions=$(solc-select versions) +all_new_versions=$(solc-select versions | sort) ### halt if solc version is accidentally changed if [ "$old_solc_version" != "$new_solc_version" ]; then diff --git a/scripts/test_windows.sh b/scripts/test_windows.sh index df24b12..acc284b 100644 --- a/scripts/test_windows.sh +++ b/scripts/test_windows.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail use_version=$(solc-select use 0.4.5) if [[ $use_version != "Switched global version to 0.4.5"* ]]; then @@ -16,14 +17,14 @@ if [[ $use_version != "Switched global version to $latest_release" ]]; then fi echo "WINDOWS SUCCESS: maximum version" -use_version=$(solc-select use 0.3.9 2>&1) +use_version=$(solc-select use 0.3.9 2>&1 || true) if [[ $use_version != *"Invalid version - only solc versions above '0.4.5' are available"* ]]; then echo "WINDOWS FAILED: version too low" exit 255 fi echo "WINDOWS SUCCESS: version too low" -use_version=$(solc-select use 0.100.8 2>&1) +use_version=$(solc-select use 0.100.8 2>&1 || true) if [[ $use_version != *"Invalid version '$latest_release' is the latest available version"* ]]; then echo "WINDOWS FAILED: version too high" exit 255