Skip to content

Commit d90a14d

Browse files
authored
Use proper p2pd binary on macOS (#586)
1 parent 33a9a41 commit d90a14d

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ of [Go toolchain](https://golang.org/doc/install) (1.15 or 1.16 are supported).
8181

8282
- __Linux__ is the default OS for which hivemind is developed and tested. We recommend Ubuntu 18.04+ (64-bit), but
8383
other 64-bit distros should work as well. Legacy 32-bit is not recommended.
84-
- __macOS 10.x__ can run hivemind using [Docker](https://docs.docker.com/desktop/mac/install/).
84+
- __macOS__ is partially supported.
85+
If you have issues, you can run hivemind using [Docker](https://docs.docker.com/desktop/mac/install/) instead.
8586
We recommend using [our Docker image](https://hub.docker.com/r/learningathome/hivemind).
8687
- __Windows 10+ (experimental)__ can run hivemind
8788
using [WSL](https://docs.microsoft.com/ru-ru/windows/wsl/install-win10). You can configure WSL to use GPU by

setup.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import glob
33
import hashlib
44
import os
5+
import platform
56
import re
67
import subprocess
78
import tarfile
@@ -13,14 +14,15 @@
1314
from setuptools.command.build_py import build_py
1415
from setuptools.command.develop import develop
1516

16-
P2PD_VERSION = "v0.3.16"
17+
P2PD_VERSION = "v0.3.17"
1718

1819
P2PD_SOURCE_URL = f"https://github.com/learning-at-home/go-libp2p-daemon/archive/refs/tags/{P2PD_VERSION}.tar.gz"
1920
P2PD_BINARY_URL = f"https://github.com/learning-at-home/go-libp2p-daemon/releases/download/{P2PD_VERSION}/"
2021

2122
# The value is sha256 of the binary from the release page
22-
EXECUTABLES = {
23-
"p2pd": "057ec61edbe926cf049e9532d43ea9540da55db7b2d8c816d2bbdddce23f3cdf",
23+
P2P_BINARY_HASH = {
24+
"linux": "b0dd69e80f03a6fe5546f7079242b0228e93cd88d6e58442a227ed9521a95328",
25+
"darwin": "f5cf7a86335e0264a65a6cf0fbd1033409e6f9bee65f9c4ee6c330b3cb53c3b5",
2426
}
2527

2628
here = os.path.abspath(os.path.dirname(__file__))
@@ -71,31 +73,31 @@ def build_p2p_daemon():
7173
with tarfile.open(dest, "r:gz") as tar:
7274
tar.extractall(tempdir)
7375

74-
for executable in EXECUTABLES:
75-
result = subprocess.run(
76-
["go", "build", "-o", os.path.join(here, "hivemind", "hivemind_cli", executable)],
77-
cwd=os.path.join(tempdir, f"go-libp2p-daemon-{P2PD_VERSION.lstrip('v')}", executable),
78-
)
79-
if result.returncode != 0:
80-
raise RuntimeError(f"Failed to build {executable}: exited with status code: {result.returncode}")
76+
result = subprocess.run(
77+
["go", "build", "-o", os.path.join(here, "hivemind", "hivemind_cli", "p2pd")],
78+
cwd=os.path.join(tempdir, f"go-libp2p-daemon-{P2PD_VERSION.lstrip('v')}", "p2pd"),
79+
)
80+
if result.returncode != 0:
81+
raise RuntimeError(f"Failed to build p2pd: exited with status code: {result.returncode}")
8182

8283

8384
def download_p2p_daemon():
84-
for executable, expected_hash in EXECUTABLES.items():
85-
binary_path = os.path.join(here, "hivemind", "hivemind_cli", executable)
85+
binary_path = os.path.join(here, "hivemind", "hivemind_cli", "p2pd")
86+
os_name = platform.system().lower()
87+
expected_hash = P2P_BINARY_HASH[os_name]
8688

87-
if sha256(binary_path) != expected_hash:
88-
binary_url = os.path.join(P2PD_BINARY_URL, executable)
89-
print(f"Downloading {binary_url}")
89+
if sha256(binary_path) != expected_hash:
90+
binary_url = os.path.join(P2PD_BINARY_URL, f"p2pd-{os_name}")
91+
print(f"Downloading {binary_url}")
9092

91-
urllib.request.urlretrieve(binary_url, binary_path)
92-
os.chmod(binary_path, 0o777)
93+
urllib.request.urlretrieve(binary_url, binary_path)
94+
os.chmod(binary_path, 0o777)
9395

94-
actual_hash = sha256(binary_path)
95-
if actual_hash != expected_hash:
96-
raise RuntimeError(
97-
f"The sha256 checksum for {executable} does not match (expected: {expected_hash}, actual: {actual_hash})"
98-
)
96+
actual_hash = sha256(binary_path)
97+
if actual_hash != expected_hash:
98+
raise RuntimeError(
99+
f"The sha256 checksum for p2pd does not match (expected: {expected_hash}, actual: {actual_hash})"
100+
)
99101

100102

101103
class BuildPy(build_py):

0 commit comments

Comments
 (0)