py-solc
=======
|Build Status| |PyPi version| |PyPi downloads|
Python wrapper around the ``solc`` Solidity compiler.
Dependency
----------
This library requires the ``solc`` executable to be present.
Only versions ``>=0.4.2`` are supported and tested though this library
may work with other versions.
`solc installation
instructions <http://solidity.readthedocs.io/en/latest/installing-solidity.html>`__
Quickstart
----------
Installation
.. code:: sh
pip install py-solc
Development
-----------
Clone the repository and then run:
.. code:: sh
pip install -e . -r requirements-dev.txt
Running the tests
~~~~~~~~~~~~~~~~~
You can run the tests with:
.. code:: sh
py.test tests
Or you can install ``tox`` to run the full test suite.
Releasing
~~~~~~~~~
Pandoc is required for transforming the markdown README to the proper
format to render correctly on pypi.
For Debian-like systems:
::
apt install pandoc
Or on OSX:
.. code:: sh
brew install pandoc
To release a new version:
.. code:: sh
bumpversion $$VERSION_PART_TO_BUMP$$
git push && git push --tags
make release
How to bumpversion
^^^^^^^^^^^^^^^^^^
The version format for this repo is ``{major}.{minor}.{patch}`` for
stable, and ``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable
(``stage`` can be alpha or beta).
To issue the next version in line, use bumpversion and specify which
part to bump, like ``bumpversion minor`` or ``bumpversion devnum``.
If you are in a beta version, ``bumpversion stage`` will switch to a
stable.
To issue an unstable version when the current version is stable, specify
the new version explicitly, like
``bumpversion --new-version 4.0.0-alpha.1 devnum``
Standard JSON Compilation
-------------------------
Use the ``solc.compile_standard`` function to make use the
[standard-json] compilation feature.
`Solidity Documentation for Standard JSON input and ouptup
format <http://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description>`__
::
>>> from solc 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
--------------------------------
.. code:: python
>>> from solc import compile_source, compile_files, link_code
>>> 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_code = "606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273__TestA_________________________________90630c55699c906064906000906004818660325a03f41560025750505056"
>>> link_code(unlinked_code, {'TestA': '0xd3cda913deb6f67967b99d67acdfa1712c293601'})
... "606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273d3cda913deb6f67967b99d67acdfa1712c29360190630c55699c906064906000906004818660325a03f41560025750505056"
Setting the path to the ``solc`` binary
---------------------------------------
You can use the environment variable ``SOLC_BINARY`` to set the path to
your solc binary.
Installing the ``solc`` binary
------------------------------
This feature is experimental and subject to breaking changes.
Any of the following versions of ``solc`` can be installed using
``py-solc`` on the listed platforms.
- ``v0.4.1`` (linux)
- ``v0.4.2`` (linux)
- ``v0.4.6`` (linux)
- ``v0.4.7`` (linux)
- ``v0.4.8`` (linux/osx)
- ``v0.4.9`` (linux)
- ``v0.4.11`` (linux/osx)
- ``v0.4.12`` (linux/osx)
- ``v0.4.13`` (linux/osx)
- ``v0.4.14`` (linux/osx)
- ``v0.4.15`` (linux/osx)
- ``v0.4.16`` (linux/osx)
- ``v0.4.17`` (linux/osx)
- ``v0.4.18`` (linux/osx)
- ``v0.4.19`` (linux/osx)
- ``v0.4.20`` (linux/osx)
- ``v0.4.21`` (linux/osx)
- ``v0.4.22`` (linux/osx)
- ``v0.4.23`` (linux/osx)
- ``v0.4.24`` (linux/osx)
- ``v0.4.25`` (linux/osx)
Installation can be done via the command line:
.. code:: bash
$ python -m solc.install v0.4.25
Or from python using the ``install_solc`` function.
.. code:: python
>>> from solc import install_solc
>>> install_solc('v0.4.25')
The installed binary can be found under your home directory. The
``v0.4.25`` binary would be located at
``$HOME/.py-solc/solc-v0.4.25/bin/solc``. Older linux installs will also
require that you set the environment variable
``LD_LIBRARY_PATH=$HOME/.py-solc/solc-v0.4.25/bin``
Import path remappings
----------------------
``solc`` provides path aliasing allow you to have more reusable project
configurations.
You can use this like:
::
from solc import compile_source, compile_files, link_code
compile_files([source_file_path], import_remappings=["zeppeling=/my-zeppelin-checkout-folder"])
`More information about solc import
aliasing <http://solidity.readthedocs.io/en/develop/layout-of-source-files.html#paths>`__
.. |Build Status| image:: https://travis-ci.org/ethereum/py-solc.png
:target: https://travis-ci.org/ethereum/py-solc
.. |PyPi version| image:: https://pypip.in/v/py-solc/badge.png
:target: https://pypi.python.org/pypi/py-solc
.. |PyPi downloads| image:: https://pypip.in/d/py-solc/badge.png
:target: https://pypi.python.org/pypi/py-solc
Raw data
{
"_id": null,
"home_page": "https://github.com/ethereum/py-solc",
"name": "py-solc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.4, <4",
"maintainer_email": "",
"keywords": "ethereum solidity solc",
"author": "Piper Merriam",
"author_email": "pipermerriam@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/53/8d/5451ff817206a1ba234ac2f33e0e9cbe1f88aa3eff2966e9d9e1a70d7e42/py-solc-3.2.0.tar.gz",
"platform": "",
"description": "py-solc\n=======\n\n|Build Status| |PyPi version| |PyPi downloads|\n\nPython wrapper around the ``solc`` Solidity compiler.\n\nDependency\n----------\n\nThis library requires the ``solc`` executable to be present.\n\nOnly versions ``>=0.4.2`` are supported and tested though this library\nmay work with other versions.\n\n`solc installation\ninstructions <http://solidity.readthedocs.io/en/latest/installing-solidity.html>`__\n\nQuickstart\n----------\n\nInstallation\n\n.. code:: sh\n\n pip install py-solc\n\nDevelopment\n-----------\n\nClone the repository and then run:\n\n.. code:: sh\n\n pip install -e . -r requirements-dev.txt\n\nRunning the tests\n~~~~~~~~~~~~~~~~~\n\nYou can run the tests with:\n\n.. code:: sh\n\n py.test tests\n\nOr you can install ``tox`` to run the full test suite.\n\nReleasing\n~~~~~~~~~\n\nPandoc is required for transforming the markdown README to the proper\nformat to render correctly on pypi.\n\nFor Debian-like systems:\n\n::\n\n apt install pandoc\n\nOr on OSX:\n\n.. code:: sh\n\n brew install pandoc\n\nTo release a new version:\n\n.. code:: sh\n\n bumpversion $$VERSION_PART_TO_BUMP$$\n git push && git push --tags\n make release\n\nHow to bumpversion\n^^^^^^^^^^^^^^^^^^\n\nThe version format for this repo is ``{major}.{minor}.{patch}`` for\nstable, and ``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable\n(``stage`` can be alpha or beta).\n\nTo issue the next version in line, use bumpversion and specify which\npart to bump, like ``bumpversion minor`` or ``bumpversion devnum``.\n\nIf you are in a beta version, ``bumpversion stage`` will switch to a\nstable.\n\nTo issue an unstable version when the current version is stable, specify\nthe new version explicitly, like\n``bumpversion --new-version 4.0.0-alpha.1 devnum``\n\nStandard JSON Compilation\n-------------------------\n\nUse the ``solc.compile_standard`` function to make use the\n[standard-json] compilation feature.\n\n`Solidity Documentation for Standard JSON input and ouptup\nformat <http://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description>`__\n\n::\n\n >>> from solc import compile_standard\n >>> compile_standard({\n ... 'language': 'Solidity',\n ... 'sources': {'Foo.sol': 'content': \"....\"},\n ... })\n {\n 'contracts': {...},\n 'sources': {...},\n 'errors': {...},\n }\n >>> compile_standard({\n ... 'language': 'Solidity',\n ... 'sources': {'Foo.sol': 'urls': [\"/path/to/my/sources/Foo.sol\"]},\n ... }, allow_paths=\"/path/to/my/sources\")\n {\n 'contracts': {...},\n 'sources': {...},\n 'errors': {...},\n }\n\nLegacy Combined JSON compilation\n--------------------------------\n\n.. code:: python\n\n >>> from solc import compile_source, compile_files, link_code\n >>> compile_source(\"contract Foo { function Foo() {} }\")\n {\n 'Foo': {\n 'abi': [{'inputs': [], 'type': 'constructor'}],\n 'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',\n 'code_runtime': '0x60606040526008565b00',\n 'source': None,\n 'meta': {\n 'compilerVersion': '0.3.5-9da08ac3',\n 'language': 'Solidity',\n 'languageVersion': '0',\n },\n },\n }\n >>> compile_files([\"/path/to/Foo.sol\", \"/path/to/Bar.sol\"])\n {\n 'Foo': {\n 'abi': [{'inputs': [], 'type': 'constructor'}],\n 'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',\n 'code_runtime': '0x60606040526008565b00',\n 'source': None,\n 'meta': {\n 'compilerVersion': '0.3.5-9da08ac3',\n 'language': 'Solidity',\n 'languageVersion': '0',\n },\n },\n 'Bar': {\n 'abi': [{'inputs': [], 'type': 'constructor'}],\n 'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',\n 'code_runtime': '0x60606040526008565b00',\n 'source': None,\n 'meta': {\n 'compilerVersion': '0.3.5-9da08ac3',\n 'language': 'Solidity',\n 'languageVersion': '0',\n },\n },\n }\n >>> unlinked_code = \"606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273__TestA_________________________________90630c55699c906064906000906004818660325a03f41560025750505056\"\n >>> link_code(unlinked_code, {'TestA': '0xd3cda913deb6f67967b99d67acdfa1712c293601'})\n ... \"606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273d3cda913deb6f67967b99d67acdfa1712c29360190630c55699c906064906000906004818660325a03f41560025750505056\"\n\nSetting the path to the ``solc`` binary\n---------------------------------------\n\nYou can use the environment variable ``SOLC_BINARY`` to set the path to\nyour solc binary.\n\nInstalling the ``solc`` binary\n------------------------------\n\n This feature is experimental and subject to breaking changes.\n\nAny of the following versions of ``solc`` can be installed using\n``py-solc`` on the listed platforms.\n\n- ``v0.4.1`` (linux)\n- ``v0.4.2`` (linux)\n- ``v0.4.6`` (linux)\n- ``v0.4.7`` (linux)\n- ``v0.4.8`` (linux/osx)\n- ``v0.4.9`` (linux)\n- ``v0.4.11`` (linux/osx)\n- ``v0.4.12`` (linux/osx)\n- ``v0.4.13`` (linux/osx)\n- ``v0.4.14`` (linux/osx)\n- ``v0.4.15`` (linux/osx)\n- ``v0.4.16`` (linux/osx)\n- ``v0.4.17`` (linux/osx)\n- ``v0.4.18`` (linux/osx)\n- ``v0.4.19`` (linux/osx)\n- ``v0.4.20`` (linux/osx)\n- ``v0.4.21`` (linux/osx)\n- ``v0.4.22`` (linux/osx)\n- ``v0.4.23`` (linux/osx)\n- ``v0.4.24`` (linux/osx)\n- ``v0.4.25`` (linux/osx)\n\nInstallation can be done via the command line:\n\n.. code:: bash\n\n $ python -m solc.install v0.4.25\n\nOr from python using the ``install_solc`` function.\n\n.. code:: python\n\n >>> from solc import install_solc\n >>> install_solc('v0.4.25')\n\nThe installed binary can be found under your home directory. The\n``v0.4.25`` binary would be located at\n``$HOME/.py-solc/solc-v0.4.25/bin/solc``. Older linux installs will also\nrequire that you set the environment variable\n``LD_LIBRARY_PATH=$HOME/.py-solc/solc-v0.4.25/bin``\n\nImport path remappings\n----------------------\n\n``solc`` provides path aliasing allow you to have more reusable project\nconfigurations.\n\nYou can use this like:\n\n::\n\n from solc import compile_source, compile_files, link_code\n\n compile_files([source_file_path], import_remappings=[\"zeppeling=/my-zeppelin-checkout-folder\"])\n\n`More information about solc import\naliasing <http://solidity.readthedocs.io/en/develop/layout-of-source-files.html#paths>`__\n\n.. |Build Status| image:: https://travis-ci.org/ethereum/py-solc.png\n :target: https://travis-ci.org/ethereum/py-solc\n.. |PyPi version| image:: https://pypip.in/v/py-solc/badge.png\n :target: https://pypi.python.org/pypi/py-solc\n.. |PyPi downloads| image:: https://pypip.in/d/py-solc/badge.png\n :target: https://pypi.python.org/pypi/py-solc\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python wrapper around the solc binary",
"version": "3.2.0",
"split_keywords": [
"ethereum",
"solidity",
"solc"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4774d36abca3f36ccdcd04976c50f83502c870623e5beb4a4ec96c7bad4bb9e8",
"md5": "9a23571d559eb1f4a905bf3912fafc1f",
"sha256": "9ec0bc36ef22a9b0f5642e7846999c4485fa2fa562a61897aeb0a4ca53d60153"
},
"downloads": -1,
"filename": "py_solc-3.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9a23571d559eb1f4a905bf3912fafc1f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.4, <4",
"size": 12897,
"upload_time": "2018-10-04T15:23:40",
"upload_time_iso_8601": "2018-10-04T15:23:40.595156Z",
"url": "https://files.pythonhosted.org/packages/47/74/d36abca3f36ccdcd04976c50f83502c870623e5beb4a4ec96c7bad4bb9e8/py_solc-3.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "538d5451ff817206a1ba234ac2f33e0e9cbe1f88aa3eff2966e9d9e1a70d7e42",
"md5": "ed3f190b2a7d335db2845a0359d051a3",
"sha256": "82095bdac661072f48cf2daf8a96bdb625674330d92b225be26043e8d3ef8c9a"
},
"downloads": -1,
"filename": "py-solc-3.2.0.tar.gz",
"has_sig": false,
"md5_digest": "ed3f190b2a7d335db2845a0359d051a3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.4, <4",
"size": 12770,
"upload_time": "2018-10-04T15:23:42",
"upload_time_iso_8601": "2018-10-04T15:23:42.247812Z",
"url": "https://files.pythonhosted.org/packages/53/8d/5451ff817206a1ba234ac2f33e0e9cbe1f88aa3eff2966e9d9e1a70d7e42/py-solc-3.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2018-10-04 15:23:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "ethereum",
"github_project": "py-solc",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "py-solc"
}