Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/test-c2pa-rs-source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ jobs:
working-directory: c2pa-python
env:
C2PA_PREFLIGHT_RUN: "1"
run: python ./tests/test_unit_tests.py
C2PA_RS_PATH: ${{ github.workspace }}/c2pa-rs
run: |
python ./tests/test_unit_tests.py
python ./tests/test_unit_tests_threaded.py

tests-windows:
name: Unit tests (Windows, ${{ matrix.runs-on }})
Expand Down Expand Up @@ -205,4 +208,8 @@ jobs:
working-directory: c2pa-python
env:
C2PA_PREFLIGHT_RUN: "1"
run: python .\tests\test_unit_tests.py
C2PA_RS_PATH: ${{ github.workspace }}\c2pa-rs
run: |
python .\tests\test_unit_tests.py
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
python .\tests\test_unit_tests_threaded.py
1 change: 1 addition & 0 deletions c2pa-rs-preflight-ref.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main
15 changes: 8 additions & 7 deletions docs/context-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ The `Context` class encapsulates configuration for:
- **Signer configuration**: Optional signer credentials stored in the `Context` for reuse.
- **State isolation**: Each `Context` is independent, allowing different configurations to coexist in the same application.

`Context` replaces the deprecated global `load_settings()` function with explicit, isolated configuration:
`Context` replaces the removed thread-local `load_settings()` function with explicit, isolated configuration:

- **Makes dependencies explicit**: Configuration is passed directly to `Reader` and `Builder`, not hidden in global state.
- **Enables multiple configurations**: Run different configurations simultaneously (for example, one for development with test certificates, another for production with strict validation).
- **Eliminates global state**: Each `Reader` and `Builder` gets its configuration from the `Context` you pass, avoiding subtle bugs from shared state.
- **Simplifies testing**: Create isolated configurations for tests without worrying about cleanup or interference.

> [!NOTE]
> The deprecated `load_settings()` function still works for backward compatibility, but you are encouraged to migrate your code to use `Context`. See [Migrating from load_settings](#migrating-from-load_settings).
> c2pa-rs 0.92 no longer supports thread-local settings, and `load_settings()` has been removed from these bindings. See [Migrating from load_settings](#migrating-from-load_settings).

## Quick start

Expand Down Expand Up @@ -754,15 +754,15 @@ assert isinstance(ctx, ContextProvider) # True

## Migrating from load_settings

The `load_settings()` function is deprecated. Replace it with `Settings` and `Context` APIs:
The `load_settings()` function has been removed. Replace it with `Settings` and `Context` APIs, passing the context to every operation that needs the configuration:

| Aspect | `load_settings` (legacy) | `Context` |
|--------|--------------------------|-----------|
| Scope | Global state | Per Reader/Builder, passed explicitly |
| Multiple configs | Not supported | One context per configuration |
| Testing | Shared global state | Isolated contexts per test |

**Deprecated:**
**Old approach (no longer supported):**

```py
from c2pa import load_settings, Reader
Expand All @@ -774,10 +774,11 @@ reader = Reader("image.jpg") # uses global settings
**Current approach:**

```py
from c2pa import Settings, Context, Reader
from c2pa import Context, Reader

ctx = Context.from_dict({"builder": {"thumbnail": {"enabled": False}}})
reader = Reader("image.jpg", context=ctx)
with Context.from_dict({"builder": {"thumbnail": {"enabled": False}}}) as ctx:
with Reader("image.jpg", context=ctx) as reader:
print(reader.json())
```

## See also
Expand Down
11 changes: 3 additions & 8 deletions docs/intents.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ You can set the intent on a `Builder` instance by:
- [Using Context](#using-context)
- [Using `set_intent` on the `Builder`](#using-set_intent-on-the-builder)

Don't set the intent using the deprecated `load_settings()` function. For existing code, see [Context and settings - Migrating from load_settings](context-settings.md#migrating-from-load_settings).
The thread-local `load_settings()` function has been removed. For existing code, see [Context and settings - Migrating from load_settings](context-settings.md#migrating-from-load_settings).

### Using Context

Expand Down Expand Up @@ -114,11 +114,7 @@ flowchart TD
Check --> |No| CheckCtx{Was a Context with
builder.intent provided?}
CheckCtx --> |Yes| UseCtx["Use Context intent"]
CheckCtx --> |No| CheckGlobal{Was load_settings called
with builder.intent?}
CheckGlobal --> |Yes| UseGlobal["Use global intent
(deprecated)"]
CheckGlobal --> |No| NoIntent["No intent set.
CheckCtx --> |No| NoIntent["No intent set.
Caller must define actions
manually in manifest JSON."]
```
Expand Down Expand Up @@ -173,8 +169,7 @@ The `Builder` intent controls what the `Builder` does with the source stream (so
```mermaid
flowchart TD
Intent["Intent
(via Context, set_intent,
or load_settings)"] --> Q{Intent type?}
(via Context or set_intent)"] --> Q{Intent type?}
Q --> |CREATE| CreateFlow["No parent allowed
Source stream is new content"]
Q --> |EDIT or UPDATE| EditFlow{Was a parentOf ingredient
Expand Down
21 changes: 21 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Release notes

## Unreleased: c2pa-rs 0.92 preflight (DO NOT MERGE)

This branch tests the upcoming native SDK, not a published Python release.
The normal native release pin is unchanged.

### Breaking changes

Removed `load_settings()`: c2pa-rs 0.92 removes thread-local settings.
Create a `Context` with `Settings` (or `Context.from_dict` / `from_json`)
and pass it explicitly to every `Reader` and `Builder` that needs that
configuration. Constructors without a context continue to use SDK defaults.
See [Migrating from load_settings](context-settings.md#migrating-from-load_settings).

Reader and Builder constructors now use the current context-based C APIs.
Native strings, manifests, and signatures are released through `c2pa_free`.
`format_embeddable()` retains its `(size, bytes)` result using a temporary
default-context builder. For custom settings or format-specific builder state,
use `Builder.compose_manifest(format, manifest_bytes)` on a live builder.
Signing closes the builder, so use a separate builder for composition after
`sign()`.

## Version 0.33.0

### Breaking changes
Expand Down
4 changes: 2 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ manifest_json = json.dumps({

## Settings, Context, and ContextProvider

The `Settings` and `Context` classes provide per-instance configuration for `Reader` and `Builder` operations, replacing the global `load_settings()` function, which is now deprecated.
The `Settings` and `Context` classes provide per-instance configuration for `Reader` and `Builder` operations, replacing the removed thread-local `load_settings()` function.

See [Context and settings](context-settings.md) for details.

Expand Down Expand Up @@ -144,7 +144,7 @@ The built-in `Context` class is the standard `ContextProvider` implementation. C

### Migrating from load_settings

The `load_settings()` function is deprecated. Replace it with `Settings` and `Context`. See [Migrating from load_settings](context-settings.md#migrating-from-load_settings) for details.
The `load_settings()` function has been removed for c2pa-rs 0.92 compatibility. Replace it with `Settings` and `Context`. See [Migrating from load_settings](context-settings.md#migrating-from-load_settings) for details.

## File-based operation

Expand Down
6 changes: 2 additions & 4 deletions src/c2pa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
Context,
ContextBuilder,
ContextProvider,
sdk_version,
load_settings
sdk_version
) # NOQA

# Re-export C2paError and its subclasses
Expand All @@ -50,6 +49,5 @@
'Context',
'ContextBuilder',
'ContextProvider',
'sdk_version',
'load_settings'
'sdk_version'
]
Loading
Loading