Skip to content

Commit

Permalink
Support for 0.4.12 and installation of solc by version
Browse files Browse the repository at this point in the history
  • Loading branch information
pipermerriam committed Jul 4, 2017
1 parent 4a69acd commit 3a6de35
Show file tree
Hide file tree
Showing 9 changed files with 626 additions and 50 deletions.
21 changes: 18 additions & 3 deletions .travis.yml
@@ -1,11 +1,19 @@
language: python
python:
- "3.5"
os:
- linux
#- osx
dist: trusty
sudo: required
env:
global:
- SOLC_BASE_INSTALL_PATH=$TRAVIS_BUILD_DIR
matrix:
# Installation Tests
- TOX_ENV=py27-installation SOLC_RUN_INSTALL_TESTS=enabled
- TOX_ENV=py34-installation SOLC_RUN_INSTALL_TESTS=enabled
- TOX_ENV=py35-installation SOLC_RUN_INSTALL_TESTS=enabled
# Standard Library
# py27
- TOX_ENV=py27-stdlib SOLC_VERSION=v0.4.1
Expand All @@ -15,6 +23,7 @@ env:
- TOX_ENV=py27-stdlib SOLC_VERSION=v0.4.8
- TOX_ENV=py27-stdlib SOLC_VERSION=v0.4.9
- TOX_ENV=py27-stdlib SOLC_VERSION=v0.4.11
- TOX_ENV=py27-stdlib SOLC_VERSION=v0.4.12
# py34
- TOX_ENV=py34-stdlib SOLC_VERSION=v0.4.1
- TOX_ENV=py34-stdlib SOLC_VERSION=v0.4.2
Expand All @@ -23,6 +32,7 @@ env:
- TOX_ENV=py34-stdlib SOLC_VERSION=v0.4.8
- TOX_ENV=py34-stdlib SOLC_VERSION=v0.4.9
- TOX_ENV=py34-stdlib SOLC_VERSION=v0.4.11
- TOX_ENV=py34-stdlib SOLC_VERSION=v0.4.12
# py35
- TOX_ENV=py35-stdlib SOLC_VERSION=v0.4.1
- TOX_ENV=py35-stdlib SOLC_VERSION=v0.4.2
Expand All @@ -31,6 +41,7 @@ env:
- TOX_ENV=py35-stdlib SOLC_VERSION=v0.4.8
- TOX_ENV=py35-stdlib SOLC_VERSION=v0.4.9
- TOX_ENV=py35-stdlib SOLC_VERSION=v0.4.11
- TOX_ENV=py35-stdlib SOLC_VERSION=v0.4.12
# Gevent
# py27
- TOX_ENV=py27-gevent SOLC_VERSION=v0.4.1
Expand All @@ -40,6 +51,7 @@ env:
- TOX_ENV=py27-gevent SOLC_VERSION=v0.4.8
- TOX_ENV=py27-gevent SOLC_VERSION=v0.4.9
- TOX_ENV=py27-gevent SOLC_VERSION=v0.4.11
- TOX_ENV=py27-gevent SOLC_VERSION=v0.4.12
# py34
- TOX_ENV=py34-gevent SOLC_VERSION=v0.4.1
- TOX_ENV=py34-gevent SOLC_VERSION=v0.4.2
Expand All @@ -48,6 +60,7 @@ env:
- TOX_ENV=py34-gevent SOLC_VERSION=v0.4.8
- TOX_ENV=py34-gevent SOLC_VERSION=v0.4.9
- TOX_ENV=py34-gevent SOLC_VERSION=v0.4.11
- TOX_ENV=py34-gevent SOLC_VERSION=v0.4.12
# py35
- TOX_ENV=py35-gevent SOLC_VERSION=v0.4.1
- TOX_ENV=py35-gevent SOLC_VERSION=v0.4.2
Expand All @@ -56,18 +69,20 @@ env:
- TOX_ENV=py35-gevent SOLC_VERSION=v0.4.8
- TOX_ENV=py35-gevent SOLC_VERSION=v0.4.9
- TOX_ENV=py35-gevent SOLC_VERSION=v0.4.11
- TOX_ENV=py35-gevent SOLC_VERSION=v0.4.12
# linting
- TOX_ENV=flake8
cache:
- pip: true
before_install:
install:
- if [ -n "$SOLC_VERSION" ]; then python3 $TRAVIS_BUILD_DIR/scripts/install_solc.py $SOLC_VERSION; fi
- travis_retry pip install setuptools --upgrade
- travis_retry pip install tox
- pip3 install -e . # install py-solc globally in order to use the solc installation scripts.
before_script:
- if [ -n "$SOLC_VERSION" ]; then export SOLC_BINARY="$TRAVIS_BUILD_DIR/bin/solc-$SOLC_VERSION/bin/solc"; fi
- if [ -n "$SOLC_VERSION" ]; then export LD_LIBRARY_PATH="$TRAVIS_BUILD_DIR/bin/solc-$SOLC_VERSION/bin"; fi
- if [ -n "$SOLC_VERSION" ]; then python3 -m solc.install $SOLC_VERSION; fi
- if [ -n "$SOLC_VERSION" ]; then export SOLC_BINARY="$SOLC_BASE_INSTALL_PATH/solc-$SOLC_VERSION/bin/solc"; fi
- if [ -n "$SOLC_VERSION" ]; then export LD_LIBRARY_PATH="$SOLC_BASE_INSTALL_PATH/solc-$SOLC_VERSION/bin"; fi
- env
- if [ -n "$SOLC_BINARY" ]; then $SOLC_BINARY --version; fi
script:
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
@@ -0,0 +1,2 @@
[pytest]
addopts= -v --showlocals
89 changes: 49 additions & 40 deletions scripts/install_solc.py
Expand Up @@ -19,14 +19,19 @@
import zipfile


SUPPORTED_VERSIONS = {
"0.4.1",
"0.4.2",
"0.4.6",
"0.4.7",
"0.4.8",
"0.4.11",
}
V0_4_1 = 'v0.4.1'
V0_4_2 = 'v0.4.2'
V0_4_6 = 'v0.4.6'
V0_4_7 = 'v0.4.7'
V0_4_8 = 'v0.4.8'
V0_4_9 = 'v0.4.9'
V0_4_11 = 'v0.4.11'
V0_4_12 = 'v0.4.12'


LINUX = 'linux'
OSX = 'darwin'
WINDOWS = 'win32'


BASE_INSTALL_PATH = os.path.join(
Expand All @@ -41,6 +46,17 @@
)


def get_platform():
if sys.platform.startswith('linux'):
return LINUX
elif sys.platform == OSX:
return OSX
elif sys.platform == WINDOWS:
return WINDOWS
else:
raise KeyError("Unknown platform: {0}".format(sys.platform))


def is_executable_available(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
Expand Down Expand Up @@ -280,26 +296,6 @@ def install_solc_from_static_linux(identifier):
print("solc successfully installed at: {0}".format(executable_path))


V0_4_1 = 'v0.4.1'
V0_4_2 = 'v0.4.2'
V0_4_6 = 'v0.4.6'
V0_4_7 = 'v0.4.7'
V0_4_8 = 'v0.4.8'
V0_4_9 = 'v0.4.9'
V0_4_11 = 'v0.4.11'


SUPPORTED_VERSIONS = {
V0_4_1,
V0_4_2,
V0_4_6,
V0_4_7,
V0_4_8,
V0_4_9,
V0_4_11,
}


def install_from_ubuntu_release(identifier):
install_solc_dependencies(identifier)
install_solc_from_ubuntu_release_zip(identifier)
Expand All @@ -318,28 +314,41 @@ def install_from_static_linux(identifier):


install_v0_4_11 = functools.partial(install_solc_from_static_linux, V0_4_11)
install_v0_4_12 = functools.partial(install_solc_from_static_linux, V0_4_12)


INSTALL_FUNCTIONS = {
V0_4_1: install_v0_4_1,
V0_4_2: install_v0_4_2,
V0_4_6: install_v0_4_6,
V0_4_7: install_v0_4_7,
V0_4_8: install_v0_4_8,
V0_4_9: install_v0_4_9,
V0_4_11: install_v0_4_11,
LINUX: {
V0_4_1: install_v0_4_1,
V0_4_2: install_v0_4_2,
V0_4_6: install_v0_4_6,
V0_4_7: install_v0_4_7,
V0_4_8: install_v0_4_8,
V0_4_9: install_v0_4_9,
V0_4_11: install_v0_4_11,
V0_4_12: install_v0_4_12,
},
}


def install_solc(identifier):
if identifier not in SUPPORTED_VERSIONS:
def install_solc(platform, identifier):
if platform not in INSTALL_FUNCTIONS:
raise ValueError(
"Installation of solidity is not supported on your platform ({0}). "
"Supported platforms are: {1}".format(
platform,
', '.join(sorted(INSTALL_FUNCTIONS.keys())),
)
)
elif identifier not in INSTALL_FUNCTIONS[platform]:
raise ValueError(
"Installation of solidity=={0} is not supported. Must be one of {1}".format(
identifier,
', '.join(sorted(SUPPORTED_VERSIONS)),
', '.join(sorted(INSTALL_FUNCTIONS[platform].keys())),
)
)
install_fn = INSTALL_FUNCTIONS[identifier]

install_fn = INSTALL_FUNCTIONS[platform][identifier]
install_fn()


Expand All @@ -350,4 +359,4 @@ def install_solc(identifier):
print("Invocation error. Should be invoked as `./install_solc.py <version>`")
sys.exit(1)

install_solc(identifier)
install_solc(sys.platform, identifier)

0 comments on commit 3a6de35

Please sign in to comment.