pyshieldnet 1.0.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 (119) hide show
  1. pyshieldnet-1.0.0/CHANGELOG.md +56 -0
  2. pyshieldnet-1.0.0/LICENSE +324 -0
  3. pyshieldnet-1.0.0/MANIFEST.in +8 -0
  4. pyshieldnet-1.0.0/NOTICE +39 -0
  5. pyshieldnet-1.0.0/PKG-INFO +183 -0
  6. pyshieldnet-1.0.0/README.md +155 -0
  7. pyshieldnet-1.0.0/build_ffi.py +394 -0
  8. pyshieldnet-1.0.0/ci/build-libsodium.sh +33 -0
  9. pyshieldnet-1.0.0/csrc/native.map +1 -0
  10. pyshieldnet-1.0.0/csrc/sndev_host.c +332 -0
  11. pyshieldnet-1.0.0/csrc/sndev_host.h +43 -0
  12. pyshieldnet-1.0.0/docs/agents.md +2 -0
  13. pyshieldnet-1.0.0/docs/api.md +14 -0
  14. pyshieldnet-1.0.0/docs/building.md +39 -0
  15. pyshieldnet-1.0.0/docs/changelog.md +2 -0
  16. pyshieldnet-1.0.0/docs/client.md +100 -0
  17. pyshieldnet-1.0.0/docs/device-emulator.md +61 -0
  18. pyshieldnet-1.0.0/docs/examples.md +40 -0
  19. pyshieldnet-1.0.0/docs/index.md +2 -0
  20. pyshieldnet-1.0.0/docs/keys.md +33 -0
  21. pyshieldnet-1.0.0/docs/releasing.md +53 -0
  22. pyshieldnet-1.0.0/docs/requirements.txt +9 -0
  23. pyshieldnet-1.0.0/docs/testing.md +32 -0
  24. pyshieldnet-1.0.0/examples/README.md +31 -0
  25. pyshieldnet-1.0.0/examples/common.py +118 -0
  26. pyshieldnet-1.0.0/examples/discover.py +30 -0
  27. pyshieldnet-1.0.0/examples/emulate.py +71 -0
  28. pyshieldnet-1.0.0/examples/fill.py +151 -0
  29. pyshieldnet-1.0.0/examples/info.py +50 -0
  30. pyshieldnet-1.0.0/examples/loopback.py +53 -0
  31. pyshieldnet-1.0.0/pyproject.toml +58 -0
  32. pyshieldnet-1.0.0/setup.cfg +4 -0
  33. pyshieldnet-1.0.0/setup.py +55 -0
  34. pyshieldnet-1.0.0/src/pyshieldnet/__init__.py +4 -0
  35. pyshieldnet-1.0.0/src/pyshieldnet/client.py +669 -0
  36. pyshieldnet-1.0.0/src/pyshieldnet/device.py +394 -0
  37. pyshieldnet-1.0.0/src/pyshieldnet/errors.py +102 -0
  38. pyshieldnet-1.0.0/src/pyshieldnet/kdf.py +98 -0
  39. pyshieldnet-1.0.0/src/pyshieldnet.egg-info/PKG-INFO +183 -0
  40. pyshieldnet-1.0.0/src/pyshieldnet.egg-info/SOURCES.txt +48 -0
  41. pyshieldnet-1.0.0/src/pyshieldnet.egg-info/dependency_links.txt +1 -0
  42. pyshieldnet-1.0.0/src/pyshieldnet.egg-info/requires.txt +5 -0
  43. pyshieldnet-1.0.0/src/pyshieldnet.egg-info/top_level.txt +1 -0
  44. pyshieldnet-1.0.0/tests/conftest.py +66 -0
  45. pyshieldnet-1.0.0/tests/test_build.py +52 -0
  46. pyshieldnet-1.0.0/tests/test_client.py +222 -0
  47. pyshieldnet-1.0.0/tests/test_device.py +428 -0
  48. pyshieldnet-1.0.0/tests/test_kdf.py +169 -0
  49. pyshieldnet-1.0.0/tests/test_lifecycle.py +378 -0
  50. pyshieldnet-1.0.0/tests/test_threads.py +146 -0
  51. pyshieldnet-1.0.0/third_party/SOURCES +2 -0
  52. pyshieldnet-1.0.0/third_party/libshieldnet/LICENSE +270 -0
  53. pyshieldnet-1.0.0/third_party/libshieldnet/NOTICE +22 -0
  54. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/command.h +64 -0
  55. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/command_encode.h +184 -0
  56. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/command_parse.h +157 -0
  57. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/command_response_policy.h +19 -0
  58. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/crypto.h +69 -0
  59. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/decompress.h +37 -0
  60. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/frame.h +48 -0
  61. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/mode_decode_policy.h +9 -0
  62. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/payload_encode_policy.h +290 -0
  63. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/pixel_frame_policy.h +31 -0
  64. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/protocol.h +117 -0
  65. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/response_decode.h +285 -0
  66. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_agent.h +74 -0
  67. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_agent_dispatch.h +103 -0
  68. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_app_frame.h +122 -0
  69. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_client.h +488 -0
  70. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_client_session.h +123 -0
  71. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_client_wire.h +149 -0
  72. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_demux.h +54 -0
  73. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_device.h +454 -0
  74. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_kdf.h +105 -0
  75. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_pts.h +76 -0
  76. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_replay.h +78 -0
  77. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_source.h +52 -0
  78. pyshieldnet-1.0.0/third_party/libshieldnet/include/shieldnet/sn_wire.h +58 -0
  79. pyshieldnet-1.0.0/third_party/libshieldnet/port/shieldnet_device.h +336 -0
  80. pyshieldnet-1.0.0/third_party/libshieldnet/port/shieldnet_io.h +75 -0
  81. pyshieldnet-1.0.0/third_party/libshieldnet/port/shieldnet_log.h +42 -0
  82. pyshieldnet-1.0.0/third_party/libshieldnet/port/shieldnet_os.h +241 -0
  83. pyshieldnet-1.0.0/third_party/libshieldnet/port/shieldnet_os_posix.c +302 -0
  84. pyshieldnet-1.0.0/third_party/libshieldnet/src/command.c +673 -0
  85. pyshieldnet-1.0.0/third_party/libshieldnet/src/crypto.c +135 -0
  86. pyshieldnet-1.0.0/third_party/libshieldnet/src/decompress.c +44 -0
  87. pyshieldnet-1.0.0/third_party/libshieldnet/src/frame.c +65 -0
  88. pyshieldnet-1.0.0/third_party/libshieldnet/src/protocol.c +167 -0
  89. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_agent.c +167 -0
  90. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_agent_dispatch.c +145 -0
  91. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_app_frame.c +195 -0
  92. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_client.c +836 -0
  93. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_client_session.c +202 -0
  94. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_client_wire.c +200 -0
  95. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_demux.c +44 -0
  96. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_device.c +413 -0
  97. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_kdf.c +257 -0
  98. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_replay.c +133 -0
  99. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_session.c +849 -0
  100. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_source.c +86 -0
  101. pyshieldnet-1.0.0/third_party/libshieldnet/src/sn_wire.c +177 -0
  102. pyshieldnet-1.0.0/third_party/libshieldnet/vendor/ikcp.c +1437 -0
  103. pyshieldnet-1.0.0/third_party/libshieldnet/vendor/ikcp.h +468 -0
  104. pyshieldnet-1.0.0/third_party/libshieldnet/vendor/lz4.c +2829 -0
  105. pyshieldnet-1.0.0/third_party/libshieldnet/vendor/lz4.h +884 -0
  106. pyshieldnet-1.0.0/third_party/libshieldnet-client/LICENSE +301 -0
  107. pyshieldnet-1.0.0/third_party/libshieldnet-client/NOTICE +30 -0
  108. pyshieldnet-1.0.0/third_party/libshieldnet-client/include/shieldnet_client.h +500 -0
  109. pyshieldnet-1.0.0/third_party/libshieldnet-client/src/disc.c +642 -0
  110. pyshieldnet-1.0.0/third_party/libshieldnet-client/src/disc.h +69 -0
  111. pyshieldnet-1.0.0/third_party/libshieldnet-client/src/plat.h +253 -0
  112. pyshieldnet-1.0.0/third_party/libshieldnet-client/src/plat_posix.c +665 -0
  113. pyshieldnet-1.0.0/third_party/libshieldnet-client/src/plat_win32.c +559 -0
  114. pyshieldnet-1.0.0/third_party/libshieldnet-client/src/snc.c +1968 -0
  115. pyshieldnet-1.0.0/third_party/libshieldnet-client/src/snc_proto.h +10 -0
  116. pyshieldnet-1.0.0/third_party/libshieldnet-client/src/snc_test.h +56 -0
  117. pyshieldnet-1.0.0/third_party/libshieldnet-client/vendor/mdns/LICENSE +24 -0
  118. pyshieldnet-1.0.0/third_party/libshieldnet-client/vendor/mdns/VERSION +4 -0
  119. pyshieldnet-1.0.0/third_party/libshieldnet-client/vendor/mdns/mdns.h +1621 -0
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ ## [1.0.0] - 2026-12-05
4
+
5
+ First release. Built on libshieldnet 1.1.0 and libshieldnet-client 1.0.1.
6
+
7
+ ### Added
8
+
9
+ - `pyshieldnet._native`: one CFFI (API mode) extension that compiles
10
+ libshieldnet-client and libshieldnet (client and device roles) from sibling
11
+ checkouts, or from the copies an sdist carries under `third_party/`. Only
12
+ `PyInit__native` is exported; every C symbol, including a
13
+ statically linked libsodium, is local to the extension.
14
+ - `pyshieldnet.client`: `Context` and `Device` wrap every public `snc_*` function
15
+ (discovery, including `discover_services` for application-defined service types,
16
+ connect, reconnect, queries, brightness, fps, mode, power, NTP,
17
+ pixel frames, raw requests, `has_capability`, `Status.ext`),
18
+ with `SncError` subclasses in `pyshieldnet.errors`. `close()` waits for calls
19
+ already inside C, refuses from callback threads, and an `atexit` hook and a fork
20
+ handler close or disown contexts.
21
+ - `pyshieldnet.kdf`: `derive_kdev`, `provision_kdev` (wipes the caller's PSK
22
+ buffer), and the AEAD primitives `encrypt` / `decrypt`.
23
+ - `pyshieldnet.device`: `DeviceEmulator` runs a real libshieldnet device (admission,
24
+ session, command core) whose ops are a Python `DeviceHandler`, on the host's own
25
+ IPv4 address. A PTS frame's `Frame` carries its `frame_number`.
26
+ - Build: libsodium (1.0.22 in the release wheels, `ci/build-libsodium.sh`) is linked
27
+ statically by default; `PYSHIELDNET_SODIUM=shared`
28
+ links it dynamically. uv
29
+ cache keys cover every C source and header, including the sibling checkouts.
30
+ - Tests: client, KDF (protocol vectors), emulator integration, lifecycle (exit
31
+ order, fork, finalizer threads) and thread-concurrency tests; per-test timeout;
32
+ a non-empty `PYSHIELDNET_REQUIRE_NET` turns network skips into failures.
33
+ - Examples: `discover.py`, `info.py` and `fill.py` (ports of libshieldnet-client's
34
+ examples), `emulate.py` (an emulated device on this host) and `loopback.py` (client
35
+ and emulator in one process, no hardware needed).
36
+ - CI (GitHub Actions): the suite on Python 3.10 to 3.14 and 3.14t, static and shared
37
+ libsodium, and the loopback example, against the public libshieldnet,
38
+ libshieldnet-client and shieldnet-protocol release tags; an sdist that carries the
39
+ two libraries' sources; manylinux x86_64 and aarch64 wheels built from it with
40
+ cibuildwheel and tested; and, on a `v*` tag, publication to PyPI through trusted
41
+ publishing.
42
+ - Documentation: docstrings on every public class and function; `docs/` covers
43
+ building, the client, keys, the device emulator, testing and releasing; a MkDocs
44
+ site with an API reference generated from the docstrings, published to GitHub Pages
45
+ (https://shieldled.github.io/pyshieldnet/) by `.github/workflows/docs.yml`.
46
+ - Free-threaded CPython 3.14t: importing pyshieldnet keeps the GIL disabled, and
47
+ the suite passes with `PYTHON_GIL=0`.
48
+
49
+ ### Fixed (before the first release)
50
+
51
+ - An emulator's finalizer no longer stops the emulator synchronously on a client
52
+ I/O thread, on another emulator's agent thread, or after an event callback that
53
+ held its last reference is released; the stop is handed to a background thread.
54
+ - From an emulator handler, `Context.close()`, `Device.close()`,
55
+ `DeviceEmulator.start()` and `stop()` raise `RuntimeError` instead of being able to
56
+ deadlock against the client's I/O thread.
@@ -0,0 +1,324 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2025-2026 BlackShield LDA
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ ================================================================================
205
+ THIRD-PARTY COMPONENTS
206
+
207
+ This product includes the third-party components below, each under its own
208
+ licence. Their licence texts follow.
209
+
210
+
211
+ ================================================================================
212
+ mdns (The Unlicense)
213
+ libshieldnet-client vendor/mdns/mdns.h (https://github.com/mjansson/mdns)
214
+ ================================================================================
215
+
216
+ This is free and unencumbered software released into the public domain.
217
+
218
+ Anyone is free to copy, modify, publish, use, compile, sell, or
219
+ distribute this software, either in source code form or as a compiled
220
+ binary, for any purpose, commercial or non-commercial, and by any
221
+ means.
222
+
223
+ In jurisdictions that recognize copyright laws, the author or authors
224
+ of this software dedicate any and all copyright interest in the
225
+ software to the public domain. We make this dedication for the benefit
226
+ of the public at large and to the detriment of our heirs and
227
+ successors. We intend this dedication to be an overt act of
228
+ relinquishment in perpetuity of all present and future rights to this
229
+ software under copyright law.
230
+
231
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
232
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
233
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
234
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
235
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
236
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
237
+ OTHER DEALINGS IN THE SOFTWARE.
238
+
239
+ For more information, please refer to <http://unlicense.org>
240
+
241
+
242
+ ================================================================================
243
+ LZ4 (BSD 2-Clause License)
244
+ libshieldnet vendor/lz4.c, vendor/lz4.h
245
+ ================================================================================
246
+
247
+ LZ4 - Fast LZ compression algorithm
248
+ Copyright (C) 2011-2023, Yann Collet.
249
+
250
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
251
+
252
+ Redistribution and use in source and binary forms, with or without
253
+ modification, are permitted provided that the following conditions are
254
+ met:
255
+
256
+ * Redistributions of source code must retain the above copyright
257
+ notice, this list of conditions and the following disclaimer.
258
+ * Redistributions in binary form must reproduce the above
259
+ copyright notice, this list of conditions and the following disclaimer
260
+ in the documentation and/or other materials provided with the
261
+ distribution.
262
+
263
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
264
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
265
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
266
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
267
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
268
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
269
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
270
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
271
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
272
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
273
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274
+
275
+
276
+ ================================================================================
277
+ KCP (MIT License)
278
+ libshieldnet vendor/ikcp.c, vendor/ikcp.h (https://github.com/skywind3000/kcp), modified
279
+ ================================================================================
280
+
281
+ MIT License
282
+
283
+ Copyright (c) 2017 Lin Wei (skywind3000 at gmail.com)
284
+
285
+ Permission is hereby granted, free of charge, to any person obtaining a copy
286
+ of this software and associated documentation files (the "Software"), to deal
287
+ in the Software without restriction, including without limitation the rights
288
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
289
+ copies of the Software, and to permit persons to whom the Software is
290
+ furnished to do so, subject to the following conditions:
291
+
292
+ The above copyright notice and this permission notice shall be included in all
293
+ copies or substantial portions of the Software.
294
+
295
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
296
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
297
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
298
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
299
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
300
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
301
+ SOFTWARE.
302
+
303
+
304
+ ================================================================================
305
+ libsodium (ISC License)
306
+ https://libsodium.org; linked statically into the extension by default
307
+ ================================================================================
308
+
309
+ ISC License
310
+
311
+ Copyright (c) 2013-2026
312
+ Frank Denis <j at pureftpd dot org>
313
+
314
+ Permission to use, copy, modify, and/or distribute this software for any
315
+ purpose with or without fee is hereby granted, provided that the above
316
+ copyright notice and this permission notice appear in all copies.
317
+
318
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
319
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
320
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
321
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
322
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
323
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
324
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,8 @@
1
+ include build_ffi.py CHANGELOG.md
2
+ include csrc/*.c csrc/*.h csrc/*.map
3
+ include ci/build-libsodium.sh
4
+ graft docs
5
+ graft examples
6
+ graft tests
7
+ prune .deps
8
+ global-exclude __pycache__ *.py[cod] *.so *.o
@@ -0,0 +1,39 @@
1
+ pyshieldnet
2
+ Copyright (c) 2025-2026 BlackShield LDA
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ It is built together with, and its binaries contain, the following components.
7
+
8
+ libshieldnet-client (Apache License 2.0)
9
+ Copyright (c) 2025-2026 BlackShield LDA
10
+ https://github.com/shieldled/libshieldnet-client
11
+ compiled from source; not in this repository, but its sources are in the sdist
12
+ under third_party/libshieldnet-client, with its own LICENSE and NOTICE.
13
+
14
+ libshieldnet (Apache License 2.0)
15
+ Copyright (c) 2025-2026 BlackShield LDA
16
+ https://github.com/shieldled/libshieldnet
17
+ compiled from source; not in this repository, but its sources are in the sdist
18
+ under third_party/libshieldnet, with its own LICENSE and NOTICE.
19
+
20
+ mdns (The Unlicense, public domain)
21
+ 2017 Mattias Jansson, https://github.com/mjansson/mdns
22
+ libshieldnet-client vendor/mdns/mdns.h
23
+
24
+ LZ4 (BSD 2-Clause License)
25
+ Copyright (C) 2011-2023, Yann Collet.
26
+ libshieldnet vendor/lz4.c, lz4.h (licence text at the head of lz4.c)
27
+
28
+ KCP (MIT License)
29
+ Copyright (c) 2017 Lin Wei (skywind3000 at gmail.com)
30
+ libshieldnet vendor/ikcp.c, ikcp.h, modified by BlackShield LDA; the changes
31
+ are listed in ikcp.h's header.
32
+
33
+ libsodium (ISC License)
34
+ Copyright (c) 2013-2026 Frank Denis <j at pureftpd dot org>
35
+ https://libsodium.org
36
+ Linked statically into the extension by default (PYSHIELDNET_SODIUM=shared
37
+ links it dynamically instead); not distributed in this repository.
38
+
39
+ The full licence texts are in LICENSE.
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyshieldnet
3
+ Version: 1.0.0
4
+ Summary: Python bindings for ShieldNet devices (libshieldnet-client, libshieldnet)
5
+ Author: BlackShield LDA
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/shieldled/pyshieldnet
8
+ Project-URL: Documentation, https://shieldled.github.io/pyshieldnet/
9
+ Project-URL: Issues, https://github.com/shieldled/pyshieldnet/issues
10
+ Project-URL: Changelog, https://github.com/shieldled/pyshieldnet/blob/master/CHANGELOG.md
11
+ Keywords: shieldled,shieldnet,led
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: C
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
18
+ Classifier: Topic :: System :: Networking
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: cffi>=2.0
24
+ Provides-Extra: test
25
+ Requires-Dist: pytest>=8; extra == "test"
26
+ Requires-Dist: pytest-timeout>=2.3; extra == "test"
27
+ Dynamic: license-file
28
+
29
+ # pyshieldnet
30
+
31
+ [![Documentation](https://img.shields.io/badge/docs-shieldled.github.io%2Fpyshieldnet-blue.svg)](https://shieldled.github.io/pyshieldnet/)
32
+ [![CI](https://github.com/shieldled/pyshieldnet/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/shieldled/pyshieldnet/actions/workflows/ci.yml)
33
+ [![Docs](https://github.com/shieldled/pyshieldnet/actions/workflows/docs.yml/badge.svg?branch=master)](https://github.com/shieldled/pyshieldnet/actions/workflows/docs.yml)
34
+ [![PyPI](https://img.shields.io/pypi/v/pyshieldnet.svg)](https://pypi.org/project/pyshieldnet/)
35
+ [![Python 3.10-3.14 | 3.14t](https://img.shields.io/badge/python-3.10%E2%80%933.14%20%7C%203.14t-blue.svg)](https://pypi.org/project/pyshieldnet/)
36
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/shieldled/pyshieldnet/blob/master/LICENSE)
37
+ [![Platform: Linux](https://img.shields.io/badge/platform-Linux-lightgrey.svg)](#install)
38
+
39
+ Control ShieldNet devices from Python: find them on your network, connect, and send
40
+ them colours.
41
+
42
+ **[Read the documentation](https://shieldled.github.io/pyshieldnet/)**
43
+
44
+ - **Talk to devices**: discover, connect, change brightness and mode, stream pixels.
45
+ - **No hardware? No problem**: a built-in emulated device for trying things out and
46
+ for tests.
47
+ - **Just works**: one `pip install`, nothing else to set up on Linux.
48
+
49
+ ## Install
50
+
51
+ ```sh
52
+ pip install pyshieldnet
53
+ ```
54
+
55
+ Works on Linux (x86_64 and ARM64) with Python 3.10 or newer. On other Linux machines
56
+ pip builds it from source; see [Building](https://shieldled.github.io/pyshieldnet/building/).
57
+
58
+ ## Try it
59
+
60
+ This runs a pretend device and talks to it, all on your machine:
61
+
62
+ ```python
63
+ import secrets
64
+ import time
65
+
66
+ from pyshieldnet.client import Context
67
+ from pyshieldnet.device import DeviceEmulator, DeviceHandler, local_ipv4
68
+
69
+ addr = local_ipv4()[0]
70
+ device_id = secrets.token_bytes(8)
71
+ psk = bytearray(secrets.token_bytes(32)) # a throwaway key
72
+
73
+ handler = DeviceHandler() # records what arrives
74
+ emu = DeviceEmulator(handler, device_id, psk, bind=addr, source_check=False)
75
+ with emu, Context() as ctx:
76
+ with ctx.connect(addr, emu.port, device_id, psk, same_host=True) as dev:
77
+ info = dev.get_device_info()
78
+ print(f"{info.strips} strips x {info.leds} LEDs, caps {info.caps!r}")
79
+ dev.set_mode(1) # PIXEL mode
80
+ red = bytes([255, 0, 0, 0]) # 4 bytes per pixel
81
+ dev.push_frame(1, red * (info.strips * info.leds))
82
+ for _ in range(100): # frames arrive asynchronously
83
+ if handler.frames:
84
+ break
85
+ time.sleep(0.01)
86
+ print(f"the device received frame {handler.frames[-1].frame_number}: "
87
+ f"{len(handler.frames[-1].pixels) // 4} pixels")
88
+ ```
89
+
90
+ ## Use a real device
91
+
92
+ You need the device's 32-byte key in a file (here `psk.bin`):
93
+
94
+ ```python
95
+ from pyshieldnet.client import Context, device_id_from_instance
96
+
97
+ with open("psk.bin", "rb", buffering=0) as f: # into a wipeable buffer
98
+ psk = bytearray(32)
99
+ if f.readinto(psk) != 32:
100
+ raise ValueError("psk.bin must hold 32 bytes")
101
+
102
+ with Context() as ctx:
103
+ found = ctx.discover(3000) # browses mDNS for 3 s
104
+ for f in found:
105
+ print(f.instance, f.addr, f.port, f.label)
106
+
107
+ d = found[0]
108
+ try:
109
+ device_id = device_id_from_instance(d.instance)
110
+ dev = ctx.connect(d.addr, d.port, device_id, psk)
111
+ finally:
112
+ psk[:] = bytes(32) # wipe your own copy
113
+ with dev:
114
+ info = dev.get_device_info() # cached from the handshake
115
+ if info.has_pixel: # else it refuses frames
116
+ if dev.get_mode()[0] != 1:
117
+ dev.set_mode(1) # PIXEL; again after reconnect()
118
+ px = bytes(info.strips * info.leds * 4) # 4 B per pixel: off
119
+ dev.push_frame(1, px) # False when the mailbox is busy
120
+ ```
121
+
122
+ Something went wrong? Errors are exceptions from `pyshieldnet.errors`, such as
123
+ `ETimeout`. Using threads or asyncio? Read the
124
+ [few rules](https://shieldled.github.io/pyshieldnet/client/#threads-and-asyncio) first.
125
+
126
+ ## Learn more
127
+
128
+ - [Client guide](https://shieldled.github.io/pyshieldnet/client/): everything you can do
129
+ with a device
130
+ - [Device emulator](https://shieldled.github.io/pyshieldnet/device-emulator/): fake
131
+ devices for testing
132
+ - [Keys](https://shieldled.github.io/pyshieldnet/keys/): handling device keys safely
133
+ - [Examples](https://shieldled.github.io/pyshieldnet/examples/): ready-to-run scripts
134
+ - [API reference](https://shieldled.github.io/pyshieldnet/api/): every class and
135
+ function
136
+ - [Changelog](https://shieldled.github.io/pyshieldnet/changelog/)
137
+
138
+ ## For AI assistants
139
+
140
+ - [AGENTS.md](https://github.com/shieldled/pyshieldnet/blob/master/AGENTS.md) gives
141
+ coding agents (Claude Code, Codex, Cursor, Copilot and others) the rules for using
142
+ and changing pyshieldnet.
143
+ - The docs site has
144
+ [llms.txt](https://shieldled.github.io/pyshieldnet/llms.txt), an index for LLMs, and
145
+ [llms-full.txt](https://shieldled.github.io/pyshieldnet/llms-full.txt), all the docs
146
+ in one file to attach to a chat.
147
+
148
+ ## Building from source
149
+
150
+ ```sh
151
+ git clone https://github.com/shieldled/pyshieldnet
152
+ git clone https://github.com/shieldled/libshieldnet
153
+ git clone https://github.com/shieldled/libshieldnet-client
154
+ git clone https://github.com/shieldled/shieldnet-protocol # test vectors
155
+ pyshieldnet/ci/build-libsodium.sh # libsodium 1.0.22 into ~/.local
156
+ cd pyshieldnet
157
+ python3 -m venv .venv && . .venv/bin/activate
158
+ pip install -e '.[test]' && pytest
159
+ ```
160
+
161
+ More in [Building](https://shieldled.github.io/pyshieldnet/building/),
162
+ [Testing](https://shieldled.github.io/pyshieldnet/testing/) and
163
+ [Releasing](https://shieldled.github.io/pyshieldnet/releasing/).
164
+
165
+ ## License
166
+
167
+ Apache 2.0, Copyright (c) 2025-2026 BlackShield LDA. See
168
+ [LICENSE](https://github.com/shieldled/pyshieldnet/blob/master/LICENSE).
169
+
170
+ pyshieldnet also includes these open-source projects:
171
+
172
+ | Project | License |
173
+ |---|---|
174
+ | [libshieldnet-client](https://github.com/shieldled/libshieldnet-client) 1.0.1 | Apache 2.0 |
175
+ | [libshieldnet](https://github.com/shieldled/libshieldnet) 1.1.0 | Apache 2.0 |
176
+ | [libsodium](https://libsodium.org) 1.0.22 | ISC |
177
+ | [LZ4](https://github.com/lz4/lz4) 1.10.0 | BSD 2-Clause |
178
+ | [KCP](https://github.com/skywind3000/kcp) (modified) | MIT |
179
+ | [mdns](https://github.com/mjansson/mdns) | Unlicense (public domain) |
180
+
181
+ Sharing a wheel? Keep its `LICENSE` and `NOTICE` files with it (every wheel already
182
+ includes them). [NOTICE](https://github.com/shieldled/pyshieldnet/blob/master/NOTICE)
183
+ has the full credits.