Skip to content

Commit

Permalink
Merge pull request #1296 from qstokkink/upd_libsodium_dll_loc
Browse files Browse the repository at this point in the history
Updated default dll import path to be '.'
  • Loading branch information
qstokkink authored Jun 14, 2024
2 parents 2cb4280 + 7d95f34 commit 548e78a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
11 changes: 10 additions & 1 deletion doc/basics/identity_tutorial_integration/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from asyncio import run
from base64 import b64encode
from time import sleep

from ipv8.configuration import get_default_configuration
from ipv8.REST.rest_manager import RESTManager
Expand All @@ -21,7 +22,15 @@ async def start_community() -> None:
ipv8 = IPv8(configuration)
await ipv8.start()
rest_manager = RESTManager(ipv8)
await rest_manager.start(14410 + peer_id)

# We REALLY want this particular port, keep trying
keep_trying = True
while keep_trying:
try:
await rest_manager.start(14410 + peer_id)
keep_trying = False
except OSError:
sleep(1.0) # noqa: ASYNC101

# Print the peer for reference
print("Starting peer", b64encode(ipv8.keys["anonymous id"].mid))
Expand Down
11 changes: 10 additions & 1 deletion doc/deprecated/attestation_tutorial_integration/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from base64 import b64encode
from binascii import unhexlify
from sys import argv
from time import sleep

from ipv8.attestation.identity.community import IdentityCommunity
from ipv8.attestation.wallet.community import AttestationCommunity
Expand Down Expand Up @@ -109,7 +110,15 @@ async def start_communities() -> None:
})
await ipv8.start()
rest_manager = RESTManager(ipv8)
await rest_manager.start(14410 + i)

# We REALLY want this particular port, keep trying
keep_trying = True
while keep_trying:
try:
await rest_manager.start(14410 + i)
keep_trying = False
except OSError:
sleep(1.0) # noqa: ASYNC101

# Print the peer for reference
print("Starting peer", b64encode(ipv8.keys["anonymous id"].mid))
Expand Down
8 changes: 4 additions & 4 deletions run_all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,12 @@ def install_libsodium() -> None:
# Ensure a libsodium.zip
if not pathlib.Path("libsodium.zip").exists():
import json
import urllib.request as request
from urllib import request
response = request.urlopen("https://api.github.com/repos/jedisct1/libsodium/releases")
release = json.loads(response.read())[0]
response.close()
asset = [asset for asset in release['assets'] if asset['name'].endswith("-msvc.zip")][0]
pathlib.Path("libsodium.zip").write_bytes(request.urlopen(asset['browser_download_url']).read())
asset = next(asset for asset in release['assets'] if asset['name'].endswith("-msvc.zip"))
pathlib.Path("libsodium.zip").write_bytes(request.urlopen(asset['browser_download_url']).read()) # noqa: S310

# Unpack just the libsodium.dll
if not pathlib.Path("libsodium.dll").exists():
Expand All @@ -285,7 +285,7 @@ def windows_missing_libsodium() -> bool:
return False

# Try to find it in the local directory. This is where we'll download it anyway.
os.add_dll_directory(os.path.dirname(__file__) or os.path.abspath('.'))
os.add_dll_directory(os.path.abspath('.'))
try:
import libnacl # noqa: F401
return False
Expand Down

0 comments on commit 548e78a

Please sign in to comment.