From d991ca7ba38512f45c23b82fa77ce5c47ed6e47e Mon Sep 17 00:00:00 2001 From: szotov Date: Thu, 5 Jul 2018 11:17:48 +0300 Subject: [PATCH] Minor improvements for Windows compatibility --- nucypher/blockchain/eth/sol/compile.py | 10 ++++++---- nucypher/config/utils.py | 2 +- tests/fixtures.py | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/nucypher/blockchain/eth/sol/compile.py b/nucypher/blockchain/eth/sol/compile.py index 3af310380..0e53dbf9a 100644 --- a/nucypher/blockchain/eth/sol/compile.py +++ b/nucypher/blockchain/eth/sol/compile.py @@ -1,4 +1,4 @@ -import distutils +import shutil import itertools import os @@ -9,11 +9,13 @@ from solc.exceptions import SolcError class SolidityCompiler: - __default_version = 'v0.4.22' + __default_version = 'v0.4.24' __default_configuration_path = os.path.join(dirname(abspath(__file__)), './compiler.json') - __bin_path = os.path.dirname(distutils.spawn.find_executable('python')) - __default_sol_binary_path = os.path.join(__bin_path, 'solc') + __default_sol_binary_path = shutil.which('solc') + if __default_sol_binary_path is None: + __bin_path = os.path.dirname(shutil.which('python')) + __default_sol_binary_path = os.path.join(__bin_path, 'solc') __default_contract_dir = os.path.join(dirname(abspath(__file__)), 'source', 'contracts') __default_chain_name = 'tester' diff --git a/nucypher/config/utils.py b/nucypher/config/utils.py index b5e85f2b4..cb2dc7c47 100644 --- a/nucypher/config/utils.py +++ b/nucypher/config/utils.py @@ -125,7 +125,7 @@ def check_config_tree(configuration_dir: str=None) -> bool: def check_config_runtime() -> bool: rules = ( - (os.getuid() != 0, 'Cannot run as root user.'), + (os.name == 'nt' or os.getuid() != 0, 'Cannot run as root user.'), ) for rule, failure_reason in rules: diff --git a/tests/fixtures.py b/tests/fixtures.py index 947734820..c606b9b9a 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -40,8 +40,9 @@ def tempfile_path(): """ User is responsible for closing the file given at the path. """ - _, path = tempfile.mkstemp() + fd, path = tempfile.mkstemp() yield path + os.close(fd) os.remove(path)