From dc249fbb880d8ae4aca9ba619ecf5818ccc37a8a Mon Sep 17 00:00:00 2001 From: AustEcon Date: Sun, 1 Aug 2021 01:20:01 +1200 Subject: [PATCH] I have produced cross-platform wheels for plyvel here: https://pypi.org/project/plyvel-wheels/#files - Which fixes this problem: https://github.com/wbolster/plyvel/issues/114 for details on "Symbol not found: __ZTIN7leveldb10ComparatorE" error - By including a statically linked leveldb v 1.22 in the wheel (for Mac). - This also saves the user from needing to perform a "brew install leveldb" step and is therefore an essential part of making the SDK a one-click-installation... --- .../electrumsv/local_tools.py | 18 ++++-------------- .../electrumx/local_tools.py | 16 ++++++---------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/electrumsv_sdk/builtin_components/electrumsv/local_tools.py b/electrumsv_sdk/builtin_components/electrumsv/local_tools.py index 038d57e6..cb2e375d 100644 --- a/electrumsv_sdk/builtin_components/electrumsv/local_tools.py +++ b/electrumsv_sdk/builtin_components/electrumsv/local_tools.py @@ -99,20 +99,10 @@ def packages_electrumsv(self, url: str, branch: str) -> None: ) electrumsv_libs_path = PYTHON_LIB_DIR / self.plugin.COMPONENT_NAME - if sys.platform == 'win32': - cmd1 = f"{sys.executable} -m pip install --target {electrumsv_libs_path} --upgrade " \ - f"-r {electrumsv_requirements_path}" - cmd2 = f"{sys.executable} -m pip install --target {electrumsv_libs_path} --upgrade " \ - f"-r {electrumsv_binary_requirements_path}" - elif sys.platform in ['linux', 'darwin']: - cmd1 = f"{sys.executable} -m pip install --target {electrumsv_libs_path} --upgrade " \ - f"-r {electrumsv_requirements_path}" - cmd2 = f"{sys.executable} -m pip install --target {electrumsv_libs_path} --upgrade " \ - f"-r {electrumsv_binary_requirements_path}" - else: - cmd1 = f"echo platform: {sys.platform} unsupported" - cmd2 = f"echo ''" - + cmd1 = f"{sys.executable} -m pip install --target {electrumsv_libs_path} --upgrade " \ + f"-r {electrumsv_requirements_path}" + cmd2 = f"{sys.executable} -m pip install --target {electrumsv_libs_path} --upgrade " \ + f"-r {electrumsv_binary_requirements_path}" process1 = subprocess.Popen(cmd1, shell=True) process1.wait() process2 = subprocess.Popen(cmd2, shell=True) diff --git a/electrumsv_sdk/builtin_components/electrumx/local_tools.py b/electrumsv_sdk/builtin_components/electrumx/local_tools.py index f312fa19..9bb11cb3 100644 --- a/electrumsv_sdk/builtin_components/electrumx/local_tools.py +++ b/electrumsv_sdk/builtin_components/electrumx/local_tools.py @@ -79,15 +79,15 @@ def packages_electrumx(self, url: str, branch: str) -> None: """plyvel wheels are not available on windows so it is swapped out for plyvel-win32 to make it work""" - def modify_requirements_for_windows(temp_requirements): - """replaces plyvel with plyvel-win32""" + def modify_requirements_for_windows_and_mac(temp_requirements): + """replaces plyvel with plyvel-wheels""" packages = [] with open(requirements_path, 'r') as f: for line in f.readlines(): if line.strip() == 'plyvel': continue packages.append(line) - packages.append('plyvel-win32') + packages.append('plyvel-wheels') with open(temp_requirements, 'w') as f: f.writelines(packages) @@ -98,19 +98,15 @@ def modify_requirements_for_windows(temp_requirements): requirements_path = self.plugin.src.joinpath('requirements.txt') electrumx_libs_path = PYTHON_LIB_DIR / self.plugin.COMPONENT_NAME - if sys.platform in ['linux', 'darwin']: - if sys.platform == 'darwin': - # so that plyvel dependency can build wheel - process = subprocess.Popen(["brew", "install", "leveldb"]) - process.wait() + if sys.platform == 'linux': process = subprocess.Popen( f"{sys.executable} -m pip install --target {electrumx_libs_path} " f"-r {requirements_path} --upgrade", shell=True) process.wait() - elif sys.platform == 'win32': + elif sys.platform in {'win32', 'darwin'}: temp_requirements = self.plugin.src.joinpath('requirements-temp.txt') - modify_requirements_for_windows(temp_requirements) + modify_requirements_for_windows_and_mac(temp_requirements) process = subprocess.Popen( f"{sys.executable} -m pip install --target {electrumx_libs_path} " f"-r {temp_requirements} --upgrade", shell=True)