Skip to content

Commit 68ec164

Browse files
ruby now loads from default libs location
python now loads from default libs location
1 parent 6adc04e commit 68ec164

File tree

8 files changed

+33
-9
lines changed

8 files changed

+33
-9
lines changed

devops/build_sdks.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ def build_python(args) -> None:
6969
python_dir = abspath(join(dirname(__file__), '..', 'python'))
7070
update_line(join(python_dir, 'setup.cfg'),
7171
{'version = ': f'version = {get_package_versions(args)}'})
72-
# Copy in the binaries
73-
copy_okapi_libs(join(python_dir, 'okapi', 'libs'))
7472

7573

7674
def build_java(args) -> None:
@@ -85,8 +83,6 @@ def build_ruby(args) -> None:
8583
ruby_dir = abspath(join(dirname(__file__), '..', 'ruby'))
8684
update_line(join(ruby_dir, 'lib', 'version.rb'),
8785
{' VERSION =': f" VERSION = '{get_package_versions(args)}'"})
88-
# Copy in the binaries
89-
copy_okapi_libs(join(ruby_dir, 'libs'))
9086

9187

9288
def build_golang(args) -> None:

python/tests/test_keys.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import base64
22
import unittest
3+
from os.path import dirname, join, abspath
4+
35
import base58
46

57
from okapi.wrapper import DIDKey
68
from okapi.proto.okapi.keys.v1 import GenerateKeyRequest, KeyType, GenerateKeyResponse, ResolveRequest
7-
from okapi.okapi_utils import DidError
9+
from okapi.okapi_utils import DidError, get_os_arch_binary, set_library_path
810

911

1012
def base64_padding(base_64: str) -> str:
@@ -18,6 +20,11 @@ def base64_padding(base_64: str) -> str:
1820

1921

2022
class KeyTests(unittest.TestCase):
23+
def setUp(self) -> None:
24+
base_dir = abspath(join(dirname(__file__), '..', '..'))
25+
lib_path, _ = get_os_arch_binary(base_dir)
26+
set_library_path(dirname(lib_path))
27+
2128
def test_generate_key(self):
2229
request = GenerateKeyRequest()
2330
request.key_type = KeyType.KEY_TYPE_ED25519

python/tests/test_ldproofs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import datetime
22
import unittest
3+
from os.path import join, dirname, abspath
34

4-
from okapi.okapi_utils import dictionary_to_struct
5+
from okapi.okapi_utils import dictionary_to_struct, set_library_path, get_os_arch_binary
56
from okapi.proto.okapi.keys.v1 import GenerateKeyRequest, KeyType, JsonWebKey
67
from okapi.wrapper import DIDKey, LDProofs
78
from okapi.proto.okapi.proofs.v1 import CreateProofRequest, LdSuite
89

910

1011
class LdProofsTests(unittest.TestCase):
12+
def setUp(self) -> None:
13+
base_dir = abspath(join(dirname(__file__), '..', '..'))
14+
lib_path, _ = get_os_arch_binary(base_dir)
15+
set_library_path(dirname(lib_path))
16+
1117
def test_generate_capability_invocation_proof_with_jcs(self):
1218
capability_dict = {"@context": "https://w3id.org/security/v2",
1319
"target": "urn:trinsic:wallets:noop",

python/tests/test_oberon.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import unittest
2+
from os.path import join, dirname, abspath
23

4+
from okapi.okapi_utils import set_library_path, get_os_arch_binary
35
from okapi.proto.okapi.security.v1 import CreateOberonKeyRequest, CreateOberonTokenRequest, CreateOberonProofRequest, \
46
VerifyOberonProofRequest, UnBlindOberonTokenRequest, BlindOberonTokenRequest
57
from okapi.wrapper import Oberon
68

79

810
class OberonTests(unittest.TestCase):
11+
def setUp(self) -> None:
12+
base_dir = abspath(join(dirname(__file__), '..', '..'))
13+
lib_path, _ = get_os_arch_binary(base_dir)
14+
set_library_path(dirname(lib_path))
15+
916
def test_oberon_demo(self):
1017
key = Oberon.create_key(CreateOberonKeyRequest())
1118
data = bytes("alice", "utf8")

ruby/lib/okapi.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ def self.library_path=(path)
3030
@@library_path = path
3131
end
3232

33+
def self.library_directory
34+
return 'windows' if OS.windows?
35+
return 'linux' if OS.linux?
36+
return 'macos' if OS.mac?
37+
38+
raise NotImplementedError
39+
end
40+
3341
def self.library_name
3442
return 'okapi.dll' if OS.windows?
3543
return 'libokapi.so' if OS.linux?

ruby/test/key_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class KeyTest < Minitest::Test
1212
def before_setup
13-
Okapi.library_path = ('./libs')
13+
Okapi.library_path = "#{__dir__}/../../libs/#{Okapi.library_directory}"
1414
Okapi.load_native_library
1515
end
1616

ruby/test/ldproof_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class LdProofTest < Minitest::Test
1313
def before_setup
14-
Okapi.library_path = ('./libs')
14+
Okapi.library_path = "#{__dir__}/../../libs/#{Okapi.library_directory}"
1515
Okapi.load_native_library
1616
end
1717

ruby/test/oberon_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class OberonTest < Minitest::Test
1212
def before_setup
13-
Okapi.library_path = ('./libs')
13+
Okapi.library_path = "#{__dir__}/../../libs/#{Okapi.library_directory}"
1414
Okapi.load_native_library
1515
end
1616

0 commit comments

Comments
 (0)