c2pa-python 0.32.7__tar.gz → 0.32.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {c2pa_python-0.32.7/src/c2pa_python.egg-info → c2pa_python-0.32.9}/PKG-INFO +1 -1
  2. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/pyproject.toml +1 -1
  3. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa/c2pa.py +19 -31
  4. {c2pa_python-0.32.7 → c2pa_python-0.32.9/src/c2pa_python.egg-info}/PKG-INFO +1 -1
  5. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/tests/test_unit_tests.py +1 -1
  6. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/LICENSE-APACHE +0 -0
  7. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/LICENSE-MIT +0 -0
  8. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/MANIFEST.in +0 -0
  9. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/README.md +0 -0
  10. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/requirements.txt +0 -0
  11. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/scripts/download_artifacts.py +0 -0
  12. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/setup.cfg +0 -0
  13. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/setup.py +0 -0
  14. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa/__init__.py +0 -0
  15. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa/build.py +0 -0
  16. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa/lib.py +0 -0
  17. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa_python.egg-info/SOURCES.txt +0 -0
  18. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa_python.egg-info/dependency_links.txt +0 -0
  19. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa_python.egg-info/entry_points.txt +0 -0
  20. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa_python.egg-info/requires.txt +0 -0
  21. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/src/c2pa_python.egg-info/top_level.txt +0 -0
  22. {c2pa_python-0.32.7 → c2pa_python-0.32.9}/tests/test_unit_tests_threaded.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: c2pa-python
3
- Version: 0.32.7
3
+ Version: 0.32.9
4
4
  Summary: Python bindings for the C2PA Content Authenticity Initiative (CAI) library
5
5
  Author-email: Gavin Peacock <gvnpeacock@adobe.com>, Tania Mathern <mathern@adobe.com>
6
6
  Maintainer-email: Gavin Peacock <gpeacock@adobe.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "c2pa-python"
7
- version = "0.32.7"
7
+ version = "0.32.9"
8
8
  requires-python = ">=3.10"
9
9
  description = "Python bindings for the C2PA Content Authenticity Initiative (CAI) library"
10
10
  readme = { file = "README.md", content-type = "text/markdown" }
@@ -1870,17 +1870,8 @@ class Stream:
1870
1870
  if not data or length <= 0:
1871
1871
  return -1
1872
1872
 
1873
- # Create a temporary buffer to safely handle the data
1874
- temp_buffer = (ctypes.c_ubyte * length)()
1875
- try:
1876
- # Copy data to our temporary buffer
1877
- ctypes.memmove(temp_buffer, data, length)
1878
- # Write from our safe buffer
1879
- self._file_like_stream.write(bytes(temp_buffer))
1880
- return length
1881
- finally:
1882
- # Ensure temporary buffer is cleared
1883
- ctypes.memset(temp_buffer, 0, length)
1873
+ self._file_like_stream.write(ctypes.string_at(data, length))
1874
+ return length
1884
1875
  except Exception:
1885
1876
  return -1
1886
1877
 
@@ -2339,10 +2330,8 @@ class Reader(ManagedResource):
2339
2330
  else:
2340
2331
  if not isinstance(manifest_data, bytes):
2341
2332
  raise TypeError(Reader._ERROR_MESSAGES['manifest_error'])
2342
- manifest_array = (
2343
- ctypes.c_ubyte *
2344
- len(manifest_data))(
2345
- *manifest_data)
2333
+ manifest_array = (ctypes.c_ubyte * len(manifest_data)).from_buffer_copy(
2334
+ manifest_data)
2346
2335
  self._handle = (
2347
2336
  _lib.c2pa_reader_from_manifest_data_and_stream(
2348
2337
  format_bytes,
@@ -2425,10 +2414,8 @@ class Reader(ManagedResource):
2425
2414
  raise TypeError(
2426
2415
  Reader._ERROR_MESSAGES[
2427
2416
  'manifest_error'])
2428
- manifest_array = (
2429
- ctypes.c_ubyte *
2430
- len(manifest_data))(
2431
- *manifest_data)
2417
+ manifest_array = (ctypes.c_ubyte * len(manifest_data)).from_buffer_copy(
2418
+ manifest_data)
2432
2419
  # Consume current reader,
2433
2420
  # with manifest data and stream (C FFI pattern),
2434
2421
  # to create a new one (switch out)
@@ -2890,10 +2877,7 @@ class Signer(ManagedResource):
2890
2877
  if data_len > 1024 * 1024: # 1MB limit
2891
2878
  return -1
2892
2879
 
2893
- # Recover signed data (copy, to avoid lifetime issues)
2894
- temp_buffer = (ctypes.c_ubyte * data_len)()
2895
- ctypes.memmove(temp_buffer, data_ptr, data_len)
2896
- data = bytes(temp_buffer)
2880
+ data = ctypes.string_at(data_ptr, data_len)
2897
2881
 
2898
2882
  if not data:
2899
2883
  # Error: empty data, invalid so return -1,
@@ -3558,10 +3542,7 @@ class Builder(ManagedResource):
3558
3542
  manifest_bytes = b""
3559
3543
  if manifest_bytes_ptr and result > 0:
3560
3544
  try:
3561
- # Convert the C pointer to Python bytes
3562
- temp_buffer = (ctypes.c_ubyte * result)()
3563
- ctypes.memmove(temp_buffer, manifest_bytes_ptr, result)
3564
- manifest_bytes = bytes(temp_buffer)
3545
+ manifest_bytes = ctypes.string_at(manifest_bytes_ptr, result)
3565
3546
  except Exception:
3566
3547
  manifest_bytes = b""
3567
3548
  finally:
@@ -3660,7 +3641,13 @@ class Builder(ManagedResource):
3660
3641
  context's signer is used.
3661
3642
  format: The MIME type of the content.
3662
3643
  source: The source stream.
3663
- dest: The destination stream (optional).
3644
+ dest: The destination stream (optional). When
3645
+ omitted, the signed asset is buffered into
3646
+ an in-memory `BytesIO` sized to the full
3647
+ output. For assets larger than a few MB,
3648
+ pass a file or other writable stream to
3649
+ avoid buffering the whole signed payload
3650
+ in memory.
3664
3651
 
3665
3652
  Returns:
3666
3653
  Manifest bytes
@@ -3758,7 +3745,9 @@ def format_embeddable(format: str, manifest_bytes: bytes) -> tuple[int, bytes]:
3758
3745
  _clear_error_state()
3759
3746
 
3760
3747
  format_str = format.encode('utf-8')
3761
- manifest_array = (ctypes.c_ubyte * len(manifest_bytes))(*manifest_bytes)
3748
+ manifest_array = (ctypes.c_ubyte * len(manifest_bytes)).from_buffer_copy(
3749
+ manifest_bytes
3750
+ )
3762
3751
  result_bytes_ptr = ctypes.POINTER(ctypes.c_ubyte)()
3763
3752
 
3764
3753
  result = _lib.c2pa_format_embeddable(
@@ -3771,10 +3760,9 @@ def format_embeddable(format: str, manifest_bytes: bytes) -> tuple[int, bytes]:
3771
3760
  _check_ffi_operation_result(result,
3772
3761
  "Failed to format embeddable manifest", check=lambda r: r < 0)
3773
3762
 
3774
- # Convert the result bytes to a Python bytes object
3775
3763
  size = result
3776
3764
  try:
3777
- result_bytes = bytes(result_bytes_ptr[:size])
3765
+ result_bytes = ctypes.string_at(result_bytes_ptr, size)
3778
3766
  except Exception as e:
3779
3767
  raise C2paError(
3780
3768
  f"Failed to convert embeddable manifest bytes: {e}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: c2pa-python
3
- Version: 0.32.7
3
+ Version: 0.32.9
4
4
  Summary: Python bindings for the C2PA Content Authenticity Initiative (CAI) library
5
5
  Author-email: Gavin Peacock <gvnpeacock@adobe.com>, Tania Mathern <mathern@adobe.com>
6
6
  Maintainer-email: Gavin Peacock <gpeacock@adobe.com>
@@ -70,7 +70,7 @@ def load_test_settings_json():
70
70
  class TestC2paSdk(unittest.TestCase):
71
71
  def test_sdk_version(self):
72
72
  # This test verifies the native libraries used match the expected version.
73
- self.assertIn("0.82.1", sdk_version())
73
+ self.assertIn("0.85.0", sdk_version())
74
74
 
75
75
 
76
76
  class TestReader(unittest.TestCase):
File without changes
File without changes
File without changes
File without changes
File without changes