Skip to content

Commit

Permalink
Merge pull request #109 from iamdefinitelyahuman/v1.0.0-dev
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
iamdefinitelyahuman authored Aug 27, 2020
2 parents dd01343 + 237bb23 commit 0028506
Show file tree
Hide file tree
Showing 45 changed files with 2,948 additions and 1,246 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
python-version: 3.6

- name: Install Tox
run: pip install tox
run: pip install tox wheel

- name: Run Tox
run: tox -e lint
Expand All @@ -36,13 +36,20 @@ jobs:
steps:
- uses: actions/checkout@v1

# install solc for one job to test importing already-installed versions
- name: Install solc
run: |
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
- name: Setup Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6

- name: Install Tox
run: pip install tox
run: pip install tox wheel

- name: Run Tox
run: tox -e py36
Expand All @@ -66,7 +73,7 @@ jobs:
python-version: 3.7

- name: Install Tox
run: pip install tox
run: pip install tox wheel

- name: Run Tox
run: tox -e py37
Expand All @@ -81,8 +88,9 @@ jobs:
py38:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v1
Expand All @@ -93,7 +101,7 @@ jobs:
python-version: 3.8

- name: Install Tox
run: pip install tox
run: pip install tox wheel

- name: Run Tox
run: tox -e py38
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
rev: v5.4.2
hooks:
- id: isort

Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ This project was forked from `py-solc`. View the original changelog [here](https

## [Unreleased](https://github.com/iamdefinitelyahuman/py-solc-x)

## [1.0.0](https://github.com/iamdefinitelyahuman/py-solc-x/releases/tag/v1.0.0) - 2020-08-26
### Added
- "latest" is a valid version number when installing ([#104](https://github.com/iamdefinitelyahuman/py-solc-x/pull/104))
- Custom exception classes ([#103](https://github.com/iamdefinitelyahuman/py-solc-x/pull/103))
- Main compiler functions have `solc_version` and `solc_binary` kwargs for setting the version or using a custom solc binary ([#98](https://github.com/iamdefinitelyahuman/py-solc-x/pull/98))
- MyPy types ([#99](https://github.com/iamdefinitelyahuman/py-solc-x/pull/99))

### Changed
- Major refactor of the main compiler functions and low-level solc wrapper ([#96](https://github.com/iamdefinitelyahuman/py-solc-x/pull/96))
- Binaries are installed from [solc-bin.ethereum.org](https://solc-bin.ethereum.org/) instead of Github ([#108](https://github.com/iamdefinitelyahuman/py-solc-x/pull/108))
- Building from source is now handled by a separate function `solcx.install.compile_solc` ([#108](https://github.com/iamdefinitelyahuman/py-solc-x/pull/108))
- `get_available_solc_versions` has been split into `get_installable_solc_versions` and `get_compilable_solc_versions` ([#108](https://github.com/iamdefinitelyahuman/py-solc-x/pull/108))
- `get_solc_folder` is now `get_solcx_install_folder` ([#102](https://github.com/iamdefinitelyahuman/py-solc-x/pull/102))
- Paths are represented as `Path` objects instead of strings ([#97](https://github.com/iamdefinitelyahuman/py-solc-x/pull/97))
- Solc versions are represented as `semantic_version.Version` objects instead of strings ([#93](https://github.com/iamdefinitelyahuman/py-solc-x/pull/93))

### Removed
- `utils.string` and `utils.types` subpackages ([#95](https://github.com/iamdefinitelyahuman/py-solc-x/pull/95))

## [0.10.1](https://github.com/iamdefinitelyahuman/py-solc-x/releases/tag/v0.10.1) - 2020-07-17
### Fixed
- Support ARM 64 bit architecture (`aarch64`)
Expand Down
187 changes: 24 additions & 163 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,189 +2,44 @@

[![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/github/workflow/status/iamdefinitelyahuman/py-solc-x/py-solc-x%20workflow)](https://github.com/iamdefinitelyahuman/py-solc-x/actions) [![Coverage Status](https://img.shields.io/codecov/c/github/iamdefinitelyahuman/py-solc-x)](https://codecov.io/gh/iamdefinitelyahuman/py-solc-x)

Python wrapper around the `solc` Solidity compiler with `0.5.x` and `0.6.x` support.
Python wrapper and version management tool for the `solc` Solidity compiler.

Forked from [`py-solc`](https://github.com/ethereum/py-solc).

## Dependencies

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.
## Features

## Supported Versions
* Full support for Solidity `>=0.4.11`
* Install Solidity on Linux, OSX and Windows
* Compile Solidity from source on Linux and OSX

Py-solc-x can install the following solc versions:
## Dependencies

* Linux and Windows: `>=0.4.11`
* OSX: `>=0.5.0`
Py-solc-x allows the use of multiple versions of solc, and can install or compile them as needed. If you wish to compile from source you must first insall the required [solc dependencies](https://solidity.readthedocs.io/en/latest/installing-solidity.html#building-from-source).

See [Installing Solidity on OSX](https://github.com/iamdefinitelyahuman/py-solc-x/wiki/Installing-Solidity-on-OSX) for information on how to use `0.4.x` versions with OSX.

## Quickstart
## Installation

Installation
### via `pip`

```sh
```bash
pip install py-solc-x
```

## Installing the `solc` Executable

The first time py-solc-x is imported it will automatically check for an installed version of solc on your system. If none is found, you must manually install via `solcx.install_solc`:

```python
>>> from solcx import install_solc
>>> install_solc('v0.4.25')
```

Or via the command line:
### via `setuptools`

```bash
python -m solcx.install v0.4.25
```

By default, `solc` versions are installed at `~/.solcx/`. If you wish to use a different directory you can specify it with the `SOLCX_BINARY_PATH` environment variable.

## Setting the `solc` Version

Py-solc-x defaults to the most recent installed version set as the active one. To check or modify the active version:

```python
>>> from solcx import get_solc_version, set_solc_version
>>> get_solc_version()
Version('0.5.7+commit.6da8b019.Linux.gpp')
>>> set_solc_version('v0.4.25')
>>>
```

You can also set the version based on the pragma version string. The highest compatible version will be used:

```python
>>> from solcx import set_solc_version_pragma
>>> set_solc_version_pragma('^0.4.20 || >0.5.5 <0.7.0')
Using solc version 0.5.8
>>> set_solc_version_pragma('^0.4.20 || >0.5.5 <0.7.0', check_new=True)
Using solc version 0.5.8
Newer compatible solc version exists: 0.6.0
git clone https://github.com/iamdefinitelyahuman/py-solc-x.git
cd py-solc-x
python3 setup.py install
```

To view available and installed versions:
## Documentation

```python
>>> from solcx import get_installed_solc_versions, get_available_solc_versions
>>> get_installed_solc_versions()
['v0.4.25', 'v0.5.3', 'v0.6.0']
>>> get_available_solc_versions()
['v0.6.0', 'v0.5.15', 'v0.5.14', 'v0.5.13', 'v0.5.12', 'v0.5.11', 'v0.5.10', 'v0.5.9', 'v0.5.8', 'v0.5.7', 'v0.5.6', 'v0.5.5', 'v0.5.4', 'v0.5.3', 'v0.5.2', 'v0.5.1', 'v0.5.0', 'v0.4.25', 'v0.4.24', 'v0.4.23', 'v0.4.22', 'v0.4.21', 'v0.4.20', 'v0.4.19', 'v0.4.18', 'v0.4.17', 'v0.4.16', 'v0.4.15', 'v0.4.14', 'v0.4.13', 'v0.4.12', 'v0.4.11']
```
Documentation is hosted at [Read the Docs](https://solcx.readthedocs.io/en/latest/).

To install the highest compatible version based on the pragma version string:
## Testing

```python
>>> from solcx import install_solc_pragma
>>> install_solc_pragma('^0.4.20 || >0.5.5 <0.7.0')
```

## Standard JSON Compilation

Use the `solcx.compile_standard` function to make use of the [standard-json](http://solidity.readthedocs.io/en/latest/using-the-compiler.html#compiler-input-and-output-json-description) compilation feature.

```python
>>> from solcx import compile_standard
>>> compile_standard({
... 'language': 'Solidity',
... 'sources': {'Foo.sol': 'content': "...."},
... })
{
'contracts': {...},
'sources': {...},
'errors': {...},
}
>>> compile_standard({
... 'language': 'Solidity',
... 'sources': {'Foo.sol': {'urls': ["/path/to/my/sources/Foo.sol"]}},
... }, allow_paths="/path/to/my/sources")
{
'contracts': {...},
'sources': {...},
'errors': {...},
}
```

## Legacy Combined JSON compilation

```python
>>> from solcx import compile_source, compile_files
>>> compile_source("contract Foo { function Foo() {} }")
{
'Foo': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
}
>>> compile_files(["/path/to/Foo.sol", "/path/to/Bar.sol"])
{
'Foo': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
'Bar': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
}
```

## Unlinked Libraries

```python
>>> from solcx import link_code
>>> unlinked_bytecode = "606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273__TestA_________________________________90630c55699c906064906000906004818660325a03f41560025750505056"
>>> link_code(unlinked_bytecode, {'TestA': '0xd3cda913deb6f67967b99d67acdfa1712c293601'})
... "606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273d3cda913deb6f67967b99d67acdfa1712c29360190630c55699c906064906000906004818660325a03f41560025750505056"
```

## Import Path Remappings

`solc` provides path aliasing allow you to have more reusable project configurations.

You can use this like:

```python
>>> from solcx import compile_files

>>> compile_files([source_file_path], import_remappings=["zeppeling=/my-zeppelin-checkout-folder"])
```

[More information about solc import aliasing](http://solidity.readthedocs.io/en/latest/layout-of-source-files.html#paths)

## Development

This project was forked from [`py-solc`](https://github.com/ethereum/py-solc) and should be considered a beta. Comments, questions, criticisms and pull requests are welcomed.

### Tests

Py-solc-x is tested on Linux and Windows with solc versions ``>=0.4.11``.
Py-solc-x is tested on Linux, OSX and Windows with solc versions ``>=0.4.11``.

To run the test suite:

Expand All @@ -194,6 +49,12 @@ pytest tests/

By default, the test suite installs all available `solc` versions for your OS. If you only wish to test against already installed versions, include the `--no-install` flag.

## Contributing

Help is always appreciated! Feel free to open an issue if you find a problem, or a pull request if you've solved an issue.

Please check out our [Contribution Guide](CONTRIBUTING.md) prior to opening a pull request, and join the Brownie [Gitter channel](https://gitter.im/eth-brownie/community) if you have any questions.

## License

This project is licensed under the [MIT license](LICENSE).
Loading

0 comments on commit 0028506

Please sign in to comment.