From b395a8b2fb68e83cca4aa1cddd4ee2f4fb338909 Mon Sep 17 00:00:00 2001 From: Aleksandr Borzunov Date: Wed, 23 Aug 2023 19:19:59 +0000 Subject: [PATCH 1/4] Download platform-specific binaries --- setup.py | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/setup.py b/setup.py index 45b245553..4ecb98afa 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ import glob import hashlib import os +import platform import re import subprocess import tarfile @@ -13,14 +14,15 @@ from setuptools.command.build_py import build_py from setuptools.command.develop import develop -P2PD_VERSION = "v0.3.16" +P2PD_VERSION = "v0.3.17" P2PD_SOURCE_URL = f"https://github.com/learning-at-home/go-libp2p-daemon/archive/refs/tags/{P2PD_VERSION}.tar.gz" P2PD_BINARY_URL = f"https://github.com/learning-at-home/go-libp2p-daemon/releases/download/{P2PD_VERSION}/" # The value is sha256 of the binary from the release page -EXECUTABLES = { - "p2pd": "057ec61edbe926cf049e9532d43ea9540da55db7b2d8c816d2bbdddce23f3cdf", +P2P_BINARY_HASH = { + "linux": "b0dd69e80f03a6fe5546f7079242b0228e93cd88d6e58442a227ed9521a95328", + "darwin": "f5cf7a86335e0264a65a6cf0fbd1033409e6f9bee65f9c4ee6c330b3cb53c3b5", } here = os.path.abspath(os.path.dirname(__file__)) @@ -71,31 +73,31 @@ def build_p2p_daemon(): with tarfile.open(dest, "r:gz") as tar: tar.extractall(tempdir) - for executable in EXECUTABLES: - result = subprocess.run( - ["go", "build", "-o", os.path.join(here, "hivemind", "hivemind_cli", executable)], - cwd=os.path.join(tempdir, f"go-libp2p-daemon-{P2PD_VERSION.lstrip('v')}", executable), - ) - if result.returncode != 0: - raise RuntimeError(f"Failed to build {executable}: exited with status code: {result.returncode}") + result = subprocess.run( + ["go", "build", "-o", os.path.join(here, "hivemind", "hivemind_cli", "p2pd")], + cwd=os.path.join(tempdir, f"go-libp2p-daemon-{P2PD_VERSION.lstrip('v')}", "p2pd"), + ) + if result.returncode != 0: + raise RuntimeError(f"Failed to build p2pd: exited with status code: {result.returncode}") def download_p2p_daemon(): - for executable, expected_hash in EXECUTABLES.items(): - binary_path = os.path.join(here, "hivemind", "hivemind_cli", executable) + binary_path = os.path.join(here, "hivemind", "hivemind_cli", "p2pd") + os_name = platform.system().lower() + expected_hash = P2P_BINARY_HASH[os_name] - if sha256(binary_path) != expected_hash: - binary_url = os.path.join(P2PD_BINARY_URL, executable) - print(f"Downloading {binary_url}") + if sha256(binary_path) != expected_hash: + binary_url = os.path.join(P2PD_BINARY_URL, f"p2pd-{os_name}") + print(f"Downloading {binary_url}") - urllib.request.urlretrieve(binary_url, binary_path) - os.chmod(binary_path, 0o777) + urllib.request.urlretrieve(binary_url, binary_path) + os.chmod(binary_path, 0o777) - actual_hash = sha256(binary_path) - if actual_hash != expected_hash: - raise RuntimeError( - f"The sha256 checksum for {executable} does not match (expected: {expected_hash}, actual: {actual_hash})" - ) + actual_hash = sha256(binary_path) + if actual_hash != expected_hash: + raise RuntimeError( + f"The sha256 checksum for p2pd does not match (expected: {expected_hash}, actual: {actual_hash})" + ) class BuildPy(build_py): From d7cd30fa4a63792e2d69697a327a14f5057b75d4 Mon Sep 17 00:00:00 2001 From: Alexander Borzunov Date: Fri, 25 Aug 2023 01:49:28 +0400 Subject: [PATCH 2/4] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e5f4e1587..2491b2e93 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,8 @@ of [Go toolchain](https://golang.org/doc/install) (1.15 or 1.16 are supported). - __Linux__ is the default OS for which hivemind is developed and tested. We recommend Ubuntu 18.04+ (64-bit), but other 64-bit distros should work as well. Legacy 32-bit is not recommended. -- __macOS 10.x__ can run hivemind using [Docker](https://docs.docker.com/desktop/mac/install/). - We recommend using [our Docker image](https://hub.docker.com/r/learningathome/hivemind). +- __macOS__ is also supported, but some features may not work properly. + If you have issues, you can run hivemind using [our Docker image](https://hub.docker.com/r/learningathome/hivemind). - __Windows 10+ (experimental)__ can run hivemind using [WSL](https://docs.microsoft.com/ru-ru/windows/wsl/install-win10). You can configure WSL to use GPU by following sections 1–3 of [this guide](https://docs.nvidia.com/cuda/wsl-user-guide/index.html) by NVIDIA. After From 530e992fae32cee8583d0670d6e419c0bb41dbab Mon Sep 17 00:00:00 2001 From: Alexander Borzunov Date: Fri, 25 Aug 2023 23:03:42 +0400 Subject: [PATCH 3/4] Update README.md Co-authored-by: Max Ryabinin --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2491b2e93..a1ce96ed9 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,8 @@ of [Go toolchain](https://golang.org/doc/install) (1.15 or 1.16 are supported). - __Linux__ is the default OS for which hivemind is developed and tested. We recommend Ubuntu 18.04+ (64-bit), but other 64-bit distros should work as well. Legacy 32-bit is not recommended. - __macOS__ is also supported, but some features may not work properly. - If you have issues, you can run hivemind using [our Docker image](https://hub.docker.com/r/learningathome/hivemind). + If you have issues, you can run hivemind using [Docker](https://docs.docker.com/desktop/mac/install/). + We recommend using [our Docker image](https://hub.docker.com/r/learningathome/hivemind). - __Windows 10+ (experimental)__ can run hivemind using [WSL](https://docs.microsoft.com/ru-ru/windows/wsl/install-win10). You can configure WSL to use GPU by following sections 1–3 of [this guide](https://docs.nvidia.com/cuda/wsl-user-guide/index.html) by NVIDIA. After From 752cdda352031ef6373a44ac0861f082773ffb08 Mon Sep 17 00:00:00 2001 From: Alexander Borzunov Date: Fri, 25 Aug 2023 23:04:37 +0400 Subject: [PATCH 4/4] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a1ce96ed9..a633a7aee 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,8 @@ of [Go toolchain](https://golang.org/doc/install) (1.15 or 1.16 are supported). - __Linux__ is the default OS for which hivemind is developed and tested. We recommend Ubuntu 18.04+ (64-bit), but other 64-bit distros should work as well. Legacy 32-bit is not recommended. -- __macOS__ is also supported, but some features may not work properly. - If you have issues, you can run hivemind using [Docker](https://docs.docker.com/desktop/mac/install/). +- __macOS__ is partially supported. + If you have issues, you can run hivemind using [Docker](https://docs.docker.com/desktop/mac/install/) instead. We recommend using [our Docker image](https://hub.docker.com/r/learningathome/hivemind). - __Windows 10+ (experimental)__ can run hivemind using [WSL](https://docs.microsoft.com/ru-ru/windows/wsl/install-win10). You can configure WSL to use GPU by