Skip to content

Commit

Permalink
Merge pull request #12 from iamdefinitelyahuman/travis
Browse files Browse the repository at this point in the history
Travis
  • Loading branch information
iamdefinitelyahuman committed Jul 23, 2019
2 parents 558dba5 + a8be7ad commit 48c8f14
Show file tree
Hide file tree
Showing 23 changed files with 239 additions and 316 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Binaries
bin
solcx/temp

# C extensions
*.so
Expand Down Expand Up @@ -58,3 +59,6 @@ docs/_build

# npm
node_modules

# other
.vscode
222 changes: 36 additions & 186 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,189 +1,39 @@
language: python
python:
- "3.5"
os:
- linux
dist: trusty
sudo: required
env:
global:
- SOLC_BASE_INSTALL_PATH=$TRAVIS_BUILD_DIR
# Based on https://github.com/cclauss/Travis-CI-Python-on-three-OSes
matrix:
include:
# lint
- python: "3.5"
env: TOX_POSARGS="-e flake8"
# installation
- python: "3.4"
env: TOX_POSARGS="-e py34-installation"
- python: "3.5"
env: TOX_POSARGS="-e py35-installation"
- python: "3.6"
env: TOX_POSARGS="-e py36-installation"
# solc 0.4.1
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.1
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.1
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.1
# solc 0.4.2
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.2
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.2
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.2
# solc 0.4.6
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.6
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.6
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.6
# solc 0.4.7
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.7
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.7
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.7
# solc 0.4.8
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.8
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.8
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.8
# solc 0.4.9
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.9
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.9
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.9
# solc 0.4.11
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.11
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.11
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.11
# solc 0.4.12
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.12
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.12
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.12
# solc 0.4.13
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.13
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.13
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.13
# solc 0.4.14
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.14
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.14
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.14
# solc 0.4.15
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.15
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.15
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.15
# solc 0.4.16
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.16
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.16
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.16
# solc 0.4.17
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.17
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.17
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.17
# solc 0.4.18
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.18
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.18
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.18
# solc 0.4.19
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.19
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.19
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.19
# solc 0.4.20
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.20
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.20
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.20
# solc 0.4.21
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.21
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.21
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.21
# solc 0.4.22
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.22
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.22
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.22
# solc 0.4.23
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.23
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.23
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.23
# solc 0.4.24
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.24
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.24
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.24
# solc 0.4.25
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.25
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.25
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.25
- name: "Python 3.7.1 on Xenial Linux"
language: python
python: 3.7 # this works for Linux but is ignored on macOS or Windows
dist: xenial # required for Python >= 3.7
sudo: true
install:
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo apt-get update
- sudo apt-get install -y solc
- pip install -r requirements-dev.txt
- pip install flake8
script: flake8 solcx/ tests/ --max-line-length=100
- name: "Python 3.6.8 on Xenial Linux"
language: python
python: 3.6
dist: xenial
sudo: true
install:
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo apt-get update
- sudo apt-get install -y solc
- pip install -r requirements-dev.txt
- name: "Python 3.7.3 on Windows"
os: windows # Windows 10.0.17134 N/A Build 17134
language: shell # 'language: python' is an error on Travis CI Windows
# python: 3.7 # 'python:' is ignored on Travis CI Windows
install:
- choco install python # this install takes at least 1 min 30 sec
- python -m pip install --upgrade pip
- pip3 install -r requirements-dev.txt
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH

cache:
- pip: true
before_install:
install:
- travis_retry pip install setuptools --upgrade
- travis_retry pip install tox
- pip --version
- pip install -e . # install py-solc globally in order to use the solc installation scripts.
before_script:
- python --version
- if [ -n "$SOLC_VERSION" ]; then python -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:
- tox $TOX_POSARGS
after_script:
- cat .tox/$TOX_POSARGS/log/*.log
script: python -m pytest tests --cov=solcx
after_success: python -m coveralls
notifications:
email: false
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# py-solc-x

[![Pypi Status](https://img.shields.io/pypi/v/py-solc-x.svg)](https://pypi.org/project/py-solc-x/) [![Build Status](https://img.shields.io/travis/com/iamdefinitelyahuman/py-solc-x.svg)](https://travis-ci.com/iamdefinitelyahuman/py-solc-x) [![Coverage Status](https://coveralls.io/repos/github/iamdefinitelyahuman/py-solc-x/badge.svg?branch=master)](https://coveralls.io/github/iamdefinitelyahuman/py-solc-x?branch=master)

Python wrapper around the `solc` Solidity compiler with `0.5.x` support.

Forked from [py-solc](https://github.com/ethereum/py-solc).
Expand All @@ -8,7 +10,14 @@ Forked from [py-solc](https://github.com/ethereum/py-solc).

Py-solc-x allows the use of multiple versions of solc and installs them as needed. You must have all required [solc dependencies](https://solidity.readthedocs.io/en/latest/installing-solidity.html#building-from-source) installed for it to work properly.

Versions `>=0.4.11` may be installed, however only versions `>=0.4.2` are supported and tested.
## Supported Versions

Py-solc-x can install the following `solc` versions:

* Linux and Windows: `>=0.4.11`
* OSX: `>=0.5.0`

`0.4.x` versions are available on OSX if they have been [installed via brew](https://github.com/ethereum/homebrew-ethereum), but cannot be installed directly by py-solc-x.

## Quickstart

Expand Down Expand Up @@ -161,7 +170,13 @@ This project was recently forked from [py-solc](https://github.com/ethereum/py-s

### Tests

Tests have not been updated from py-solc and are currently failing. If you would like to contribute by updating them, please don't hesitate :)
To run the test suite:

```bash
$ pytest tests/
```

Tests are still a work in progress. The old (some failing) ``py-solc`` tests are available [here](https://github.com/iamdefinitelyahuman/py-solc-x/tree/master/tests-old).

## License

Expand Down
9 changes: 5 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pytest>=2.9.2
tox>=2.3.1
coveralls==1.7.0
pytest>=5.0.0
pytest-cov>=2.7.1
semantic_version>=2.6.0
bumpversion==0.5.3
twine==1.12.1
twine==1.13.0
requests>=2.19.0
2 changes: 1 addition & 1 deletion solcx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
compile_standard,
link_code,
)
from .install import (
from .install import ( # noqa: F401
import_installed_solc,
install_solc,
install_solc_pragma,
Expand Down
16 changes: 11 additions & 5 deletions solcx/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def import_installed_solc():
platform = _get_platform()
if platform == 'linux':
# on Linux, copy active version of solc
path_list = [subprocess.run(['which', 'solc'], stdout=subprocess.PIPE).stdout.decode().strip()]
path_list = [
subprocess.run(['which', 'solc'], stdout=subprocess.PIPE).stdout.decode().strip()
]
if not path_list[0]:
return
elif platform == 'darwin':
Expand Down Expand Up @@ -111,7 +113,9 @@ def set_solc_version_pragma(version, silent=False):
version = version.strip()
comparator_set_range = [i.strip() for i in version.split('||')]
installed_versions = get_installed_solc_versions()
comparator_regex = re.compile(r'(?P<operator>([<>]?=?|\^))(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+))')
comparator_regex = re.compile(
r'(?P<operator>([<>]?=?|\^))(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+))'
)
range_flag = False
set_version = None
for installed_version in reversed(installed_versions):
Expand All @@ -138,10 +142,10 @@ def set_solc_version_pragma(version, silent=False):
print("Using solc version {}".format(solc_version))


def get_available_solc_versions():
def get_available_solc_versions(headers={}):
versions = []
pattern = VERSION_REGEX[_get_platform()]
for release in requests.get(ALL_RELEASES).json():
for release in requests.get(ALL_RELEASES, headers=headers).json():
asset = next((i for i in release['assets'] if re.match(pattern, i['name'])), False)
if asset:
versions.append(release['tag_name'])
Expand Down Expand Up @@ -176,7 +180,9 @@ def install_solc(version, allow_osx=False):
def install_solc_pragma(version, install=True):
version = version.strip()
comparator_set_range = [i.strip() for i in version.split('||')]
comparator_regex = re.compile(r'(?P<operator>([<>]?=?|\^))(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+))')
comparator_regex = re.compile(
r'(?P<operator>([<>]?=?|\^))(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+))'
)
versions_json = requests.get(ALL_RELEASES).json()
range_flag = False
for version_json in versions_json:
Expand Down
6 changes: 3 additions & 3 deletions solcx/utils/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import numbers
import collections
from collections import abc


if sys.version_info.major == 2:
Expand Down Expand Up @@ -36,11 +36,11 @@ def is_boolean(value):


def is_dict(obj):
return isinstance(obj, collections.Mapping)
return isinstance(obj, abc.Mapping)


def is_list_like(obj):
return not is_string(obj) and isinstance(obj, collections.Sequence)
return not is_string(obj) and isinstance(obj, abc.Sequence)


def is_null(obj):
Expand Down
2 changes: 1 addition & 1 deletion solcx/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def solc_wrapper(solc_binary=None,

if combined_json:
if "v0.5" in command[0]:
combined_json = combined_json.replace(',clone-bin','')
combined_json = combined_json.replace(',clone-bin', '')
command.extend(('--combined-json', combined_json))

if gas:
Expand Down
Loading

0 comments on commit 48c8f14

Please sign in to comment.