Skip to content

Commit

Permalink
Merge pull request #260 from ulope/fix/setup_requires
Browse files Browse the repository at this point in the history
Fix contract compilation during initial install
  • Loading branch information
CosminNechifor authored Sep 6, 2018
2 parents d77e2a7 + d386c61 commit ce3fad4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion raiden_contracts/contract_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from typing import Dict, Union

from solc import compile_files
from web3.utils.contracts import find_matching_event_abi


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -135,6 +134,9 @@ def get_contract_abi(self, contract_name: str) -> Dict:

def get_event_abi(self, contract_name: str, event_name: str) -> Dict:
""" Returns the ABI for a given event. """
# Import locally to avoid web3 dependency during installation via `compile_contracts`
from web3.utils.contracts import find_matching_event_abi

if not self._contracts:
self._compile_all_contracts()
contract_abi = self.get_contract_abi(contract_name)
Expand Down
18 changes: 15 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@
from distutils.core import setup

import os
from typing import List

from setuptools import Command
from setuptools.command.build_py import build_py
from setuptools.command.sdist import sdist


DESCRIPTION = 'Raiden contracts library and utilities'
VERSION = '0.2.0'


def read_requirements(path: str):
def read_requirements(path: str) -> List[str]:
assert os.path.isfile(path)
with open(path) as requirements:
return requirements.read().split()


def _get_single_requirement(requirements: List[str], package: str) -> List[str]:
return [req for req in requirements if req.startswith(package)]


class BuildPyCommand(build_py):
def run(self):
try:
Expand Down Expand Up @@ -76,6 +83,8 @@ def run(self):
traceback.print_exc()


requirements = read_requirements('requirements.txt')

config = {
'version': VERSION,
'scripts': [],
Expand All @@ -86,7 +95,8 @@ def run(self):
'url': 'https://github.com/raiden-network/raiden-contracts/',
'license': 'MIT',
'keywords': 'raiden ethereum blockchain',
'install_requires': read_requirements('requirements.txt'),
'install_requires': requirements,
'setup_requires': _get_single_requirement(requirements, 'py-solc'),
'packages': find_packages(),
'include_package_data': True,
'classifiers': [
Expand All @@ -95,7 +105,8 @@ def run(self):
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
'entry_points': {
'console_scripts': ['deploy = raiden_contracts.deploy.__main__:main'],
Expand All @@ -105,6 +116,7 @@ def run(self):
'build_py': BuildPyCommand,
'sdist': SdistCommand,
},
'zip_safe': False,
}

setup(**config)

0 comments on commit ce3fad4

Please sign in to comment.