dpp-sdk 0.1.0__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 (34) hide show
  1. dpp_sdk-0.1.0/.gitignore +22 -0
  2. dpp_sdk-0.1.0/CHANGELOG.md +20 -0
  3. dpp_sdk-0.1.0/LICENSE +183 -0
  4. dpp_sdk-0.1.0/PKG-INFO +99 -0
  5. dpp_sdk-0.1.0/README.md +69 -0
  6. dpp_sdk-0.1.0/docs/PORTING_PLAN.md +101 -0
  7. dpp_sdk-0.1.0/docs/RELEASING.md +106 -0
  8. dpp_sdk-0.1.0/docs/phase01-implementation-report.md +87 -0
  9. dpp_sdk-0.1.0/pyproject.toml +89 -0
  10. dpp_sdk-0.1.0/src/dpp_sdk/__init__.py +76 -0
  11. dpp_sdk-0.1.0/src/dpp_sdk/clients/__init__.py +54 -0
  12. dpp_sdk-0.1.0/src/dpp_sdk/clients/_http.py +143 -0
  13. dpp_sdk-0.1.0/src/dpp_sdk/clients/errors.py +49 -0
  14. dpp_sdk-0.1.0/src/dpp_sdk/clients/payloads.py +118 -0
  15. dpp_sdk-0.1.0/src/dpp_sdk/clients/registry.py +25 -0
  16. dpp_sdk-0.1.0/src/dpp_sdk/clients/repo.py +130 -0
  17. dpp_sdk-0.1.0/src/dpp_sdk/core/__init__.py +38 -0
  18. dpp_sdk-0.1.0/src/dpp_sdk/core/errors.py +21 -0
  19. dpp_sdk-0.1.0/src/dpp_sdk/core/model.py +205 -0
  20. dpp_sdk-0.1.0/src/dpp_sdk/core/validation.py +200 -0
  21. dpp_sdk-0.1.0/src/dpp_sdk/dpp4fun/__init__.py +33 -0
  22. dpp_sdk-0.1.0/src/dpp_sdk/dpp4fun/model.py +147 -0
  23. dpp_sdk-0.1.0/src/dpp_sdk/dpp4fun/transport.py +99 -0
  24. dpp_sdk-0.1.0/src/dpp_sdk/dpp4fun/validation.py +200 -0
  25. dpp_sdk-0.1.0/src/dpp_sdk/py.typed +0 -0
  26. dpp_sdk-0.1.0/tests/__init__.py +0 -0
  27. dpp_sdk-0.1.0/tests/conftest.py +90 -0
  28. dpp_sdk-0.1.0/tests/test_clients.py +160 -0
  29. dpp_sdk-0.1.0/tests/test_core_model.py +93 -0
  30. dpp_sdk-0.1.0/tests/test_core_validation.py +93 -0
  31. dpp_sdk-0.1.0/tests/test_dpp4fun_validation.py +95 -0
  32. dpp_sdk-0.1.0/tests/test_end_to_end.py +24 -0
  33. dpp_sdk-0.1.0/tests/test_smoke.py +17 -0
  34. dpp_sdk-0.1.0/tests/test_transport_roundtrip.py +66 -0
@@ -0,0 +1,22 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ .venv/
9
+ venv/
10
+
11
+ # Tooling caches
12
+ .pytest_cache/
13
+ .mypy_cache/
14
+ .ruff_cache/
15
+ .coverage
16
+ htmlcov/
17
+ coverage.xml
18
+
19
+ # Editor / OS
20
+ .idea/
21
+ .vscode/
22
+ .DS_Store
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ All notable changes to `dpp-sdk` are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] — Initial release
10
+
11
+ First public release of the Python port of the Java DPP SDK.
12
+
13
+ ### Added
14
+ - `dpp_sdk.core` — core DPP model, validation, and identifiers (Pydantic v2).
15
+ - `dpp_sdk.dpp4fun` — furniture-specific DPP aggregate, validation, and flat/nested JSON transport.
16
+ - `dpp_sdk.clients` — `httpx`-based HTTP clients for the DPP repository and registry APIs.
17
+ - Packaging: PEP 621 `pyproject.toml`, `src/` layout, `py.typed` marker, sdist + wheel build.
18
+
19
+ [Unreleased]: https://github.com/CIR4FUN-EU/dpp-sdk-python/compare/v0.1.0...HEAD
20
+ [0.1.0]: https://github.com/CIR4FUN-EU/dpp-sdk-python/releases/tag/v0.1.0
dpp_sdk-0.1.0/LICENSE ADDED
@@ -0,0 +1,183 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work (an example is provided in the Appendix below).
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
47
+ by the copyright owner or by an individual or Legal Entity authorized to submit
48
+ on behalf of the copyright owner. For the purposes of this definition,
49
+ "submitted" means any form of electronic, verbal, or written communication sent
50
+ to the Licensor or its representatives, including but not limited to
51
+ communication on electronic mailing lists, source code control systems, and
52
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
53
+ the purpose of discussing and improving the Work, but excluding communication
54
+ that is conspicuously marked or otherwise designated in writing by the copyright
55
+ owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
62
+ License, each Contributor hereby grants to You a perpetual, worldwide,
63
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
64
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
65
+ sublicense, and distribute the Work and such Derivative Works in Source or
66
+ Object form.
67
+
68
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
69
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
70
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
71
+ license to make, have made, use, offer to sell, sell, import, and otherwise
72
+ transfer the Work, where such license applies only to those patent claims
73
+ licensable by such Contributor that are necessarily infringed by their
74
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
75
+ to which such Contribution(s) was submitted. If You institute patent litigation
76
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
77
+ alleging that the Work or a Contribution incorporated within the Work
78
+ constitutes direct or contributory patent infringement, then any patent licenses
79
+ granted to You under this License for that Work shall terminate as of the date
80
+ such litigation is filed.
81
+
82
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
83
+ Derivative Works thereof in any medium, with or without modifications, and in
84
+ Source or Object form, provided that You meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
87
+ this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices stating that You
90
+ changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works that You
93
+ distribute, all copyright, patent, trademark, and attribution notices from the
94
+ Source form of the Work, excluding those notices that do not pertain to any part
95
+ of the Derivative Works; and
96
+
97
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
98
+ any Derivative Works that You distribute must include a readable copy of the
99
+ attribution notices contained within such NOTICE file, excluding those notices
100
+ that do not pertain to any part of the Derivative Works, in at least one of the
101
+ following places: within a NOTICE text file distributed as part of the
102
+ Derivative Works; within the Source form or documentation, if provided along
103
+ with the Derivative Works; or, within a display generated by the Derivative
104
+ Works, if and wherever such third-party notices normally appear. The contents of
105
+ the NOTICE file are for informational purposes only and do not modify the
106
+ License. You may add Your own attribution notices within Derivative Works that
107
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
108
+ provided that such additional attribution notices cannot be construed as
109
+ modifying the License.
110
+
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a whole,
114
+ provided Your use, reproduction, and distribution of the Work otherwise complies
115
+ with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
118
+ Contribution intentionally submitted for inclusion in the Work by You to the
119
+ Licensor shall be under the terms and conditions of this License, without any
120
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
121
+ supersede or modify the terms of any separate license agreement you may have
122
+ executed with Licensor regarding such Contributions.
123
+
124
+ 6. Trademarks. This License does not grant permission to use the trade names,
125
+ trademarks, service marks, or product names of the Licensor, except as required
126
+ for reasonable and customary use in describing the origin of the Work and
127
+ reproducing the content of the NOTICE file.
128
+
129
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
130
+ writing, Licensor provides the Work (and each Contributor provides its
131
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
132
+ KIND, either express or implied, including, without limitation, any warranties
133
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
134
+ PARTICULAR PURPOSE. You are solely responsible for determining the
135
+ appropriateness of using or redistributing the Work and assume any risks
136
+ associated with Your exercise of permissions under this License.
137
+
138
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
139
+ tor t (including negligence), contract, or otherwise, unless required by
140
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
141
+ writing, shall any Contributor be liable to You for damages, including any
142
+ direct, indirect, special, incidental, or consequential damages of any character
143
+ arising as a result of this License or out of the use or inability to use the
144
+ Work (including but not limited to damages for loss of goodwill, work stoppage,
145
+ computer failure or malfunction, or any and all other commercial damages or
146
+ losses), even if such Contributor has been advised of the possibility of such
147
+ damages.
148
+
149
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
150
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
151
+ acceptance of support, warranty, indemnity, or other liability obligations
152
+ and/or rights consistent with this License. However, in accepting such
153
+ obligations, You may act only on Your own behalf and on Your sole
154
+ responsibility, not on behalf of any other Contributor, and only if You agree to
155
+ indemnify, defend, and hold each Contributor harmless for any liability incurred
156
+ by, or claims asserted against, such Contributor by reason of your accepting any
157
+ such warranty or additional liability.
158
+
159
+ END OF TERMS AND CONDITIONS
160
+
161
+ APPENDIX: How to apply the Apache License to your work.
162
+
163
+ To apply the Apache License to your work, attach the following boilerplate
164
+ notice, with the fields enclosed by brackets "[]" replaced with your own
165
+ identifying information. (Don't include the brackets!) The text should be
166
+ enclosed in the appropriate comment syntax for the file format. We also
167
+ recommend that a file or class name and description of purpose be included on
168
+ the same "printed page" as the copyright notice for easier identification within
169
+ third-party archives.
170
+
171
+ Copyright [yyyy] [name of copyright owner]
172
+
173
+ Licensed under the Apache License, Version 2.0 (the "License");
174
+ you may not use this file except in compliance with the License.
175
+ You may obtain a copy of the License at
176
+
177
+ http://www.apache.org/licenses/LICENSE-2.0
178
+
179
+ Unless required by applicable law or agreed to in writing, software
180
+ distributed under the License is distributed on an "AS IS" BASIS,
181
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
182
+ See the License for the specific language governing permissions and
183
+ limitations under the License.
dpp_sdk-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: dpp-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for Digital Product Passports (DPP) — idiomatic Pydantic v2 port of the Java DPP SDK
5
+ Project-URL: Homepage, https://github.com/CIR4FUN-EU/dpp-sdk-python
6
+ Project-URL: Repository, https://github.com/CIR4FUN-EU/dpp-sdk-python
7
+ Project-URL: Issues, https://github.com/CIR4FUN-EU/dpp-sdk-python/issues
8
+ Project-URL: Changelog, https://github.com/CIR4FUN-EU/dpp-sdk-python/blob/main/CHANGELOG.md
9
+ Project-URL: Reference, https://github.com/CIR4FUN-EU/dpp-sdk-platform
10
+ Author-email: Enno Mueller <ennomueller@online.de>
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: digital-product-passport,dpp,prEN-18222,sustainability
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: httpx>=0.27
20
+ Requires-Dist: pydantic>=2.6
21
+ Provides-Extra: dev
22
+ Requires-Dist: mypy>=1.9; extra == 'dev'
23
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
24
+ Requires-Dist: pytest>=8.0; extra == 'dev'
25
+ Requires-Dist: ruff>=0.4; extra == 'dev'
26
+ Provides-Extra: release
27
+ Requires-Dist: build>=1.2; extra == 'release'
28
+ Requires-Dist: twine>=5.1; extra == 'release'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # dpp-sdk (Python)
32
+
33
+ Python SDK for **Digital Product Passports (DPP)** — an idiomatic [Pydantic v2](https://docs.pydantic.dev)
34
+ port of the Java DPP SDK in the sibling repo `../dpp-sdk-platform`.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ pip install dpp-sdk
40
+ ```
41
+
42
+ Requires Python 3.11+.
43
+
44
+ ## Quickstart
45
+
46
+ ```python
47
+ from dpp_sdk import Dpp4Fun, from_json, to_json, validate_dpp4fun
48
+
49
+ # Parse an incoming passport (accepts both flat and nested JSON shapes)
50
+ dpp = from_json(raw_json)
51
+
52
+ # Validate against the DPP rule set (raises on violations)
53
+ validate_dpp4fun(dpp)
54
+
55
+ # Serialize back to the flattened wire JSON
56
+ payload = to_json(dpp)
57
+ ```
58
+
59
+ The `httpx`-based HTTP clients for the DPP repository and registry live in `dpp_sdk.clients`:
60
+
61
+ ```python
62
+ from dpp_sdk.clients import DppRepoClient, DppRegistryClient
63
+ ```
64
+
65
+ See [`docs/PORTING_PLAN.md`](docs/PORTING_PLAN.md) for design notes and
66
+ [`docs/RELEASING.md`](docs/RELEASING.md) for how releases are cut.
67
+
68
+ ## Scope
69
+
70
+ | Package | Purpose | Java source ported from |
71
+ |---|---|---|
72
+ | `dpp_sdk.core` | Reusable core DPP model, validation, JSON transport | `dpp-datamodel/dpp-core` |
73
+ | `dpp_sdk.dpp4fun` | Furniture-specific DPP aggregate | `dpp-datamodel/dpp4fun` |
74
+ | `dpp_sdk.clients` | HTTP clients for the DPP repository & registry APIs | `dpp-sdk-clients` |
75
+
76
+ The Spring Boot mock services in `../dpp-sdk-platform/dpp-sdk-demo` are **not** ported; they are
77
+ reused as a conformance oracle for client tests.
78
+
79
+ ## Development
80
+
81
+ ```bash
82
+ python -m venv .venv && source .venv/bin/activate
83
+ pip install -e ".[dev]"
84
+
85
+ pytest # tests
86
+ mypy # type check (strict)
87
+ ruff check . # lint
88
+ ```
89
+
90
+ ## Layout
91
+
92
+ ```
93
+ src/dpp_sdk/
94
+ core/ # core model + validation
95
+ dpp4fun/ # furniture aggregate, validation, JSON transport
96
+ clients/ # repo + registry HTTP clients
97
+ tests/ # pytest suite
98
+ docs/ # PORTING_PLAN.md, RELEASING.md
99
+ ```
@@ -0,0 +1,69 @@
1
+ # dpp-sdk (Python)
2
+
3
+ Python SDK for **Digital Product Passports (DPP)** — an idiomatic [Pydantic v2](https://docs.pydantic.dev)
4
+ port of the Java DPP SDK in the sibling repo `../dpp-sdk-platform`.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ pip install dpp-sdk
10
+ ```
11
+
12
+ Requires Python 3.11+.
13
+
14
+ ## Quickstart
15
+
16
+ ```python
17
+ from dpp_sdk import Dpp4Fun, from_json, to_json, validate_dpp4fun
18
+
19
+ # Parse an incoming passport (accepts both flat and nested JSON shapes)
20
+ dpp = from_json(raw_json)
21
+
22
+ # Validate against the DPP rule set (raises on violations)
23
+ validate_dpp4fun(dpp)
24
+
25
+ # Serialize back to the flattened wire JSON
26
+ payload = to_json(dpp)
27
+ ```
28
+
29
+ The `httpx`-based HTTP clients for the DPP repository and registry live in `dpp_sdk.clients`:
30
+
31
+ ```python
32
+ from dpp_sdk.clients import DppRepoClient, DppRegistryClient
33
+ ```
34
+
35
+ See [`docs/PORTING_PLAN.md`](docs/PORTING_PLAN.md) for design notes and
36
+ [`docs/RELEASING.md`](docs/RELEASING.md) for how releases are cut.
37
+
38
+ ## Scope
39
+
40
+ | Package | Purpose | Java source ported from |
41
+ |---|---|---|
42
+ | `dpp_sdk.core` | Reusable core DPP model, validation, JSON transport | `dpp-datamodel/dpp-core` |
43
+ | `dpp_sdk.dpp4fun` | Furniture-specific DPP aggregate | `dpp-datamodel/dpp4fun` |
44
+ | `dpp_sdk.clients` | HTTP clients for the DPP repository & registry APIs | `dpp-sdk-clients` |
45
+
46
+ The Spring Boot mock services in `../dpp-sdk-platform/dpp-sdk-demo` are **not** ported; they are
47
+ reused as a conformance oracle for client tests.
48
+
49
+ ## Development
50
+
51
+ ```bash
52
+ python -m venv .venv && source .venv/bin/activate
53
+ pip install -e ".[dev]"
54
+
55
+ pytest # tests
56
+ mypy # type check (strict)
57
+ ruff check . # lint
58
+ ```
59
+
60
+ ## Layout
61
+
62
+ ```
63
+ src/dpp_sdk/
64
+ core/ # core model + validation
65
+ dpp4fun/ # furniture aggregate, validation, JSON transport
66
+ clients/ # repo + registry HTTP clients
67
+ tests/ # pytest suite
68
+ docs/ # PORTING_PLAN.md, RELEASING.md
69
+ ```
@@ -0,0 +1,101 @@
1
+ # DPP SDK — Python Port Plan
2
+
3
+ ## Context
4
+
5
+ This project is the **Python port** of the Java DPP SDK that lives in the sibling repo
6
+ `../dpp-sdk-platform`. That Java SDK is a reference implementation for **Digital Product
7
+ Passports** (draft prEN-18222-aligned). The goal here is to provide *the same functionality*
8
+ as an idiomatic Python SDK.
9
+
10
+ Scope and fidelity decided with the user:
11
+ - **Cover:** the datamodel (`dpp-core` + `dpp4fun`) **and** the HTTP clients
12
+ (`dpp-repo-client`, `dpp-registry-client`). **Exclude** the Spring Boot mock services /
13
+ integration demo (reuse them only as a test oracle, see Verification).
14
+ - **Fidelity:** **idiomatic Python using Pydantic v2** — not a literal 1:1 port.
15
+
16
+ ## Verdict (feasibility)
17
+
18
+ **High confidence, no architectural blockers.** The Java SDK has no code generation, no
19
+ annotation processors, no Lombok/MapStruct, and **no SAMM/ESMF/Catena-X or RDF/JSON-LD**.
20
+ It is hand-written immutable POJOs, hand-written bidirectional mappers, a validator registry,
21
+ Jackson JSON, and plain HTTP clients — all of which have clean (often simpler) Python
22
+ equivalents.
23
+
24
+ **Effort:** Java is ~6.9k LOC (datamodel + clients) + ~3.7k test LOC, but much is boilerplate
25
+ Pydantic gives for free. Idiomatic Python should land around **2.5–4k LOC**; realistic budget
26
+ **~4–7 focused weeks** to feature + test parity. Time goes into re-encoding validation rules
27
+ and reproducing the JSON transport contract — not raw translation.
28
+
29
+ ## Why Pydantic collapses most of the work
30
+
31
+ The Java SDK is layered: immutable **model** → **Builder** → **Validator** (runtime
32
+ `Map<Class,Validator>` registry) → **payload DTO** → **Mapper** → **JsonCodec**. Pydantic v2
33
+ collapses these into one declarative class:
34
+
35
+ | Java layer | Python (Pydantic v2) |
36
+ |---|---|
37
+ | Immutable model + `private final` + equals/hashCode/toString | `class X(BaseModel)` + `model_config = ConfigDict(frozen=True)` — equality/repr/hash free |
38
+ | Nested static `Builder` + `toBuilder()` | keyword constructor + `model_copy(update=...)` |
39
+ | `Validator<T>` + `ValidationService` registry | `@field_validator` / `@model_validator` on the model |
40
+ | Jackson payload DTO + `@JsonProperty` | same model with `Field(alias=...)`, `populate_by_name=True` |
41
+ | `Mapper.toPayload/toDomain` | `model_dump(by_alias=True)` / `model_validate(...)` |
42
+ | `Dpp4FunJsonCodec` | `model_dump_json()` / `model_validate_json()` |
43
+
44
+ UUID → `uuid.UUID`, `LocalDate` → `datetime.date`, `OrganizationRole` → `enum.Enum`/`StrEnum`.
45
+
46
+ ## Real challenges (where the time goes)
47
+
48
+ 1. **Flat vs. nested transport (the tricky part).** The Java codec emits *flattened* outbound
49
+ JSON (lifts `coreDpp`'s passportMetadata/nameplate/documentation to the root) but accepts
50
+ *both* flat and nested inbound. Implement with a `@model_serializer` for flattening on
51
+ output and a `@model_validator(mode="before")` to normalize flat-or-nested on input. Pin
52
+ byte-for-byte wire compatibility with the Java output via golden-file round-trip tests —
53
+ real consumers depend on the wire shape.
54
+ 2. **~20 validators with cross-object/conditional rules** (externalDocumentationLink ⇒
55
+ documentation required; category ↔ productType case-insensitive contains; mandatory
56
+ material ⇒ portion > 0; BOM uniqueness by name+reference; update dates not in the future;
57
+ dimensions present ⇒ unit required). Map to `@model_validator(mode="after")`; transcribe
58
+ and test each against the Java `VALIDATION_RULES.md`.
59
+ 3. **Fail-fast vs. collect-all.** Java throws on first violation (`ValidationException`);
60
+ Pydantic aggregates all errors into one `ValidationError`. Decide and document the chosen
61
+ contract (recommend adopting Pydantic's multi-error behavior; note the intentional diff).
62
+ 4. **Immutability nuance.** `frozen=True` blocks reassignment but not in-place list mutation.
63
+ Use `tuple`/`frozenset` for collection fields, or document the trade-off.
64
+ 5. **HTTP clients.** `HttpDppRepoClient<T>` is generic over codec+validator and supports
65
+ fine-grained element updates via **RFC 6902 JSON Patch**. Port with `httpx`; use the
66
+ `jsonpatch` library; `<T>` → `TypeVar`/`Generic[T]` or a `type[BaseModel]` arg. The API
67
+ wrapper DTOs (statusCode/payload/messages) become small Pydantic models.
68
+ 6. **Packaging.** Ship a proper PyPI package: `pyproject.toml` (PEP 621), `src/` layout,
69
+ `py.typed` marker, `ruff` + `mypy` + `pytest`. Flatten the Maven 7-module split into one
70
+ package: `dpp_sdk.core`, `dpp_sdk.dpp4fun`, `dpp_sdk.clients`.
71
+
72
+ ## Execution outline
73
+
74
+ 1. **Package skeleton:** `pyproject.toml`, `src/dpp_sdk/{core,dpp4fun,clients}/`, `py.typed`,
75
+ ruff/mypy/pytest config.
76
+ 2. **Core models** (`dpp_sdk/core/model.py`): Pydantic models for PassportMetadata, Nameplate,
77
+ Documentation, Organization, Contact, Address, Email, Telephone, DppCore; `OrganizationRole`
78
+ enum. Field aliases mirror Jackson `@JsonProperty`.
79
+ 3. **Core validation:** `@field_validator`/`@model_validator` encoding the core subset of
80
+ `VALIDATION_RULES.md`.
81
+ 4. **dpp4fun models + validation** (`dpp_sdk/dpp4fun/model.py`): Dpp4Fun, ProductClassification,
82
+ Characteristics, Dimensions, BillOfMaterials/Material/Component/Part, plus cross-object rules.
83
+ 5. **Transport:** `@model_serializer` (flatten out) + `@model_validator(mode="before")` (accept
84
+ flat or nested) on Dpp4Fun, replacing `Dpp4FunJsonCodec`. Provide thin
85
+ `to_json()/from_json()/from_json_and_validate()` helpers for API familiarity.
86
+ 6. **HTTP clients** (`dpp_sdk/clients/`): `httpx`-based `DppRepoClient` / `DppRegistryClient`,
87
+ generic over a model type; JSON-Patch updates via `jsonpatch`; API-wrapper response models.
88
+ 7. **Tests:** port `TestDataFactory`/`CoreTestDataFactory` as pytest fixtures; replicate the
89
+ Java round-trip, edge-case, inbound-validation, and end-to-end scenario suites.
90
+
91
+ ## Verification
92
+
93
+ - **Wire compatibility (most important):** capture canonical JSON outputs from the Java SDK for
94
+ the demo fixtures, commit them as golden files, and assert Python `model_dump_json()` matches
95
+ (modulo key order). Round-trip both flat and nested inbound payloads.
96
+ - **Validation parity:** for every rule in `VALIDATION_RULES.md`, a passing case and a failing
97
+ case; assert the failing case raises.
98
+ - **Client parity:** run the Python clients against the existing Java Spring Boot mock
99
+ repo/registry in `../dpp-sdk-platform/dpp-sdk-demo` (reuse as a conformance oracle, do not
100
+ port). Exercise create / read / update (JSON Patch) / register flows.
101
+ - `pytest` green, `mypy` clean, `ruff` clean.
@@ -0,0 +1,106 @@
1
+ # Releasing `dpp-sdk`
2
+
3
+ This project ships a single PyPI package, `dpp-sdk`, built with
4
+ [hatchling](https://hatch.pypa.io/). Releases are automated with GitHub Actions and
5
+ **PyPI Trusted Publishing** (OIDC) — no API tokens are ever stored.
6
+
7
+ - Build tool: `python -m build` → `dist/dpp_sdk-X.Y.Z-py3-none-any.whl` + `.tar.gz`
8
+ - Version source of truth: `__version__` in `src/dpp_sdk/__init__.py`
9
+ (hatchling reads it via `[tool.hatch.version]`)
10
+ - Workflows: `.github/workflows/release.yml` (publish) and `ci.yml` (test gate)
11
+
12
+ ---
13
+
14
+ ## One-time setup (do this once, before the first release)
15
+
16
+ Trusted Publishing maps a specific GitHub repo + workflow + environment to a PyPI project.
17
+ It must be registered **before** the first upload, while the project name is still unclaimed
18
+ (a "pending publisher").
19
+
20
+ ### 1. Create accounts
21
+ - PyPI: <https://pypi.org/account/register/>
22
+ - TestPyPI (separate account): <https://test.pypi.org/account/register/>
23
+
24
+ Enable 2FA on both.
25
+
26
+ ### 2. Register the pending publisher on **PyPI**
27
+ Go to <https://pypi.org/manage/account/publishing/> → "Add a new pending publisher" and enter:
28
+
29
+ | Field | Value |
30
+ |---|---|
31
+ | PyPI Project Name | `dpp-sdk` |
32
+ | Owner | `CIR4FUN-EU` |
33
+ | Repository name | `dpp-sdk-python` |
34
+ | Workflow name | `release.yml` |
35
+ | Environment name | `pypi` |
36
+
37
+ ### 3. Register the pending publisher on **TestPyPI**
38
+ Repeat at <https://test.pypi.org/manage/account/publishing/> with the **same values**, except:
39
+
40
+ | Field | Value |
41
+ |---|---|
42
+ | Environment name | `testpypi` |
43
+
44
+ ### 4. Create the GitHub Environments
45
+ In the GitHub repo → Settings → Environments, create two environments whose names match
46
+ the workflow:
47
+ - `testpypi`
48
+ - `pypi` — add yourself (`OnneM156`) as a **Required reviewer** so production uploads pause
49
+ for manual approval.
50
+
51
+ No secrets are needed in either environment; OIDC handles auth.
52
+
53
+ ---
54
+
55
+ ## Cutting a release
56
+
57
+ 1. Make sure `main` is green (CI passes: ruff, mypy, pytest).
58
+ 2. Bump the version in `src/dpp_sdk/__init__.py` (`__version__ = "X.Y.Z"`), following
59
+ [SemVer](https://semver.org/).
60
+ 3. Move the `## [Unreleased]` notes in `CHANGELOG.md` under a new `## [X.Y.Z]` heading and
61
+ update the compare links at the bottom.
62
+ 4. Commit: `git commit -am "Release vX.Y.Z"` and push to `main`.
63
+ 5. Tag and push the tag:
64
+ ```bash
65
+ git tag vX.Y.Z
66
+ git push origin vX.Y.Z
67
+ ```
68
+ 6. The **Release** workflow runs automatically:
69
+ - builds the sdist + wheel and runs `twine check`,
70
+ - publishes to **TestPyPI**,
71
+ - then waits on the `pypi` environment for your approval.
72
+ 7. Verify the TestPyPI artifact in a clean environment:
73
+ ```bash
74
+ python -m venv /tmp/relcheck && source /tmp/relcheck/bin/activate
75
+ pip install --index-url https://test.pypi.org/simple/ \
76
+ --extra-index-url https://pypi.org/simple/ dpp-sdk
77
+ python -c "import dpp_sdk; print(dpp_sdk.__version__)"
78
+ ```
79
+ (The `--extra-index-url` lets `pydantic`/`httpx` resolve from real PyPI, since TestPyPI
80
+ may not host them.)
81
+ 8. Approve the `pypi` environment in the GitHub Actions run → the package publishes to PyPI.
82
+ 9. Confirm:
83
+ ```bash
84
+ pip install dpp-sdk
85
+ python -c "import dpp_sdk; from dpp_sdk import Dpp4Fun; print(dpp_sdk.__version__)"
86
+ ```
87
+
88
+ > **Note:** a given version can only be uploaded once. If a (Test)PyPI upload of `X.Y.Z`
89
+ > already exists, bump to a new version — you cannot overwrite or re-upload it.
90
+
91
+ ---
92
+
93
+ ## Manual fallback (no CI)
94
+
95
+ If you ever need to publish from a workstation instead of CI:
96
+
97
+ ```bash
98
+ pip install -e ".[release]" # installs build + twine
99
+ python -m build # -> dist/
100
+ twine check dist/*
101
+ twine upload --repository testpypi dist/* # dry run
102
+ twine upload dist/* # real PyPI
103
+ ```
104
+
105
+ This uses a PyPI API token configured in `~/.pypirc` rather than Trusted Publishing.
106
+ Prefer the tag-driven CI flow above whenever possible.