Skip to content

Commit 2bb3def

Browse files
committed
fix: Add sdk_version and get the current value from version()
1 parent 31fd9a7 commit 2bb3def

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/c2pa/c2pa.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,15 @@ def _handle_string_result(result: ctypes.c_void_p, check_error: bool = True) ->
316316
return py_string
317317

318318
def sdk_version() -> str:
319-
return "0.8.0"
319+
"""
320+
Returns the c2pa-rs version string, e.g., "0.49.5".
321+
"""
322+
vstr = version()
323+
# Example: "c2pa-c/0.49.5 c2pa-rs/0.49.5"
324+
for part in vstr.split():
325+
if part.startswith("c2pa-rs/"):
326+
return part.split("/", 1)[1]
327+
return vstr # fallback if not found
320328

321329
def version() -> str:
322330
"""Get the C2PA library version."""

tests/test_unit_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
import unittest
1818
from unittest.mock import mock_open, patch
1919

20-
from c2pa import Builder, C2paError as Error, Reader, C2paSigningAlg as SigningAlg, C2paSignerInfo, Signer # load_settings_file
20+
from c2pa import Builder, C2paError as Error, Reader, C2paSigningAlg as SigningAlg, C2paSignerInfo, Signer, sdk_version # load_settings_file
2121

2222
PROJECT_PATH = os.getcwd()
2323

2424
testPath = os.path.join(PROJECT_PATH, "tests", "fixtures", "C.jpg")
2525

2626
class TestC2paSdk(unittest.TestCase):
2727
def test_version(self):
28-
self.assertIn("0.9.0", sdk_version())
28+
self.assertIn("0.49.5", sdk_version())
2929

3030

3131
class TestReader(unittest.TestCase):

0 commit comments

Comments
 (0)