sonolus.py 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.

Potentially problematic release.


This version of sonolus.py might be problematic. Click here for more details.

Files changed (96) hide show
  1. sonolus_py-0.1.0/.gitignore +18 -0
  2. sonolus_py-0.1.0/.python-version +1 -0
  3. sonolus_py-0.1.0/LICENSE +21 -0
  4. sonolus_py-0.1.0/PKG-INFO +10 -0
  5. sonolus_py-0.1.0/README.md +2 -0
  6. sonolus_py-0.1.0/profile +0 -0
  7. sonolus_py-0.1.0/pyproject.toml +37 -0
  8. sonolus_py-0.1.0/scripts/generate.py +91 -0
  9. sonolus_py-0.1.0/scripts/runtimes/Engine/Tutorial/Blocks.json +315 -0
  10. sonolus_py-0.1.0/scripts/runtimes/Functions.json +3232 -0
  11. sonolus_py-0.1.0/scripts/runtimes/Level/Play/Blocks.json +926 -0
  12. sonolus_py-0.1.0/scripts/runtimes/Level/Preview/Blocks.json +347 -0
  13. sonolus_py-0.1.0/scripts/runtimes/Level/Watch/Blocks.json +792 -0
  14. sonolus_py-0.1.0/sonolus/__init__.py +0 -0
  15. sonolus_py-0.1.0/sonolus/backend/__init__.py +0 -0
  16. sonolus_py-0.1.0/sonolus/backend/allocate.py +51 -0
  17. sonolus_py-0.1.0/sonolus/backend/blocks.py +756 -0
  18. sonolus_py-0.1.0/sonolus/backend/excepthook.py +37 -0
  19. sonolus_py-0.1.0/sonolus/backend/finalize.py +69 -0
  20. sonolus_py-0.1.0/sonolus/backend/flow.py +92 -0
  21. sonolus_py-0.1.0/sonolus/backend/interpret.py +333 -0
  22. sonolus_py-0.1.0/sonolus/backend/ir.py +89 -0
  23. sonolus_py-0.1.0/sonolus/backend/mode.py +24 -0
  24. sonolus_py-0.1.0/sonolus/backend/node.py +40 -0
  25. sonolus_py-0.1.0/sonolus/backend/ops.py +197 -0
  26. sonolus_py-0.1.0/sonolus/backend/optimize.py +9 -0
  27. sonolus_py-0.1.0/sonolus/backend/passes.py +6 -0
  28. sonolus_py-0.1.0/sonolus/backend/place.py +90 -0
  29. sonolus_py-0.1.0/sonolus/backend/simplify.py +30 -0
  30. sonolus_py-0.1.0/sonolus/backend/utils.py +48 -0
  31. sonolus_py-0.1.0/sonolus/backend/visitor.py +880 -0
  32. sonolus_py-0.1.0/sonolus/build/__init__.py +0 -0
  33. sonolus_py-0.1.0/sonolus/build/cli.py +170 -0
  34. sonolus_py-0.1.0/sonolus/build/collection.py +293 -0
  35. sonolus_py-0.1.0/sonolus/build/compile.py +90 -0
  36. sonolus_py-0.1.0/sonolus/build/defaults.py +32 -0
  37. sonolus_py-0.1.0/sonolus/build/engine.py +149 -0
  38. sonolus_py-0.1.0/sonolus/build/level.py +23 -0
  39. sonolus_py-0.1.0/sonolus/build/node.py +43 -0
  40. sonolus_py-0.1.0/sonolus/build/project.py +94 -0
  41. sonolus_py-0.1.0/sonolus/py.typed +0 -0
  42. sonolus_py-0.1.0/sonolus/script/__init__.py +0 -0
  43. sonolus_py-0.1.0/sonolus/script/archetype.py +651 -0
  44. sonolus_py-0.1.0/sonolus/script/array.py +241 -0
  45. sonolus_py-0.1.0/sonolus/script/bucket.py +192 -0
  46. sonolus_py-0.1.0/sonolus/script/callbacks.py +105 -0
  47. sonolus_py-0.1.0/sonolus/script/comptime.py +146 -0
  48. sonolus_py-0.1.0/sonolus/script/containers.py +247 -0
  49. sonolus_py-0.1.0/sonolus/script/debug.py +70 -0
  50. sonolus_py-0.1.0/sonolus/script/effect.py +132 -0
  51. sonolus_py-0.1.0/sonolus/script/engine.py +101 -0
  52. sonolus_py-0.1.0/sonolus/script/globals.py +234 -0
  53. sonolus_py-0.1.0/sonolus/script/graphics.py +141 -0
  54. sonolus_py-0.1.0/sonolus/script/icon.py +73 -0
  55. sonolus_py-0.1.0/sonolus/script/internal/__init__.py +5 -0
  56. sonolus_py-0.1.0/sonolus/script/internal/builtin_impls.py +144 -0
  57. sonolus_py-0.1.0/sonolus/script/internal/context.py +365 -0
  58. sonolus_py-0.1.0/sonolus/script/internal/descriptor.py +17 -0
  59. sonolus_py-0.1.0/sonolus/script/internal/error.py +15 -0
  60. sonolus_py-0.1.0/sonolus/script/internal/generic.py +197 -0
  61. sonolus_py-0.1.0/sonolus/script/internal/impl.py +69 -0
  62. sonolus_py-0.1.0/sonolus/script/internal/introspection.py +14 -0
  63. sonolus_py-0.1.0/sonolus/script/internal/native.py +38 -0
  64. sonolus_py-0.1.0/sonolus/script/internal/value.py +144 -0
  65. sonolus_py-0.1.0/sonolus/script/interval.py +98 -0
  66. sonolus_py-0.1.0/sonolus/script/iterator.py +211 -0
  67. sonolus_py-0.1.0/sonolus/script/level.py +52 -0
  68. sonolus_py-0.1.0/sonolus/script/math.py +92 -0
  69. sonolus_py-0.1.0/sonolus/script/num.py +382 -0
  70. sonolus_py-0.1.0/sonolus/script/options.py +194 -0
  71. sonolus_py-0.1.0/sonolus/script/particle.py +158 -0
  72. sonolus_py-0.1.0/sonolus/script/pointer.py +30 -0
  73. sonolus_py-0.1.0/sonolus/script/project.py +17 -0
  74. sonolus_py-0.1.0/sonolus/script/range.py +58 -0
  75. sonolus_py-0.1.0/sonolus/script/record.py +293 -0
  76. sonolus_py-0.1.0/sonolus/script/runtime.py +526 -0
  77. sonolus_py-0.1.0/sonolus/script/sprite.py +332 -0
  78. sonolus_py-0.1.0/sonolus/script/text.py +404 -0
  79. sonolus_py-0.1.0/sonolus/script/timing.py +42 -0
  80. sonolus_py-0.1.0/sonolus/script/transform.py +118 -0
  81. sonolus_py-0.1.0/sonolus/script/ui.py +160 -0
  82. sonolus_py-0.1.0/sonolus/script/values.py +43 -0
  83. sonolus_py-0.1.0/sonolus/script/vec.py +48 -0
  84. sonolus_py-0.1.0/tests/__init__.py +0 -0
  85. sonolus_py-0.1.0/tests/script/__init__.py +0 -0
  86. sonolus_py-0.1.0/tests/script/conftest.py +93 -0
  87. sonolus_py-0.1.0/tests/script/test_array.py +270 -0
  88. sonolus_py-0.1.0/tests/script/test_array_map.py +59 -0
  89. sonolus_py-0.1.0/tests/script/test_assert.py +56 -0
  90. sonolus_py-0.1.0/tests/script/test_helpers.py +62 -0
  91. sonolus_py-0.1.0/tests/script/test_interval.py +223 -0
  92. sonolus_py-0.1.0/tests/script/test_num.py +205 -0
  93. sonolus_py-0.1.0/tests/script/test_range.py +94 -0
  94. sonolus_py-0.1.0/tests/script/test_record.py +187 -0
  95. sonolus_py-0.1.0/tests/script/test_var_array.py +296 -0
  96. sonolus_py-0.1.0/uv.lock +257 -0
@@ -0,0 +1,18 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ .idea/
13
+
14
+ test.py
15
+
16
+ .hypothesis/
17
+
18
+ !/sonolus/build/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kyle Chang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.3
2
+ Name: sonolus.py
3
+ Version: 0.1.0
4
+ Summary: Sonolus engine development in Python
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.13
7
+ Description-Content-Type: text/markdown
8
+
9
+ # Sonolus.py
10
+ Sonolus engine development in Python.
@@ -0,0 +1,2 @@
1
+ # Sonolus.py
2
+ Sonolus engine development in Python.
Binary file
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "sonolus.py"
3
+ version = "0.1.0"
4
+ description = "Sonolus engine development in Python"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+
8
+ [project.scripts]
9
+ sonolus-py = "sonolus.build.cli:main"
10
+
11
+ [tool.uv]
12
+ dev-dependencies = [
13
+ "hypothesis>=6.115.3",
14
+ "pre-commit>=4.0.1",
15
+ "pytest-xdist>=3.6.1",
16
+ "pytest>=8.3.3",
17
+ "ruff>=0.6.9",
18
+ ]
19
+
20
+ [tool.ruff]
21
+ line-length = 120
22
+ target-version = "py313"
23
+
24
+ [tool.ruff.lint]
25
+ preview = true
26
+ select = ["F", "E", "W", "I", "N", "D", "UP", "YTT", "B", "A", "COM", "C4", "DTZ", "PIE", "PT", "Q", "SLOT", "SIM", "PTH", "PL", "PERF", "FURB", "LOG", "RUF"]
27
+ ignore = ["E402", "D1", "COM812", "PLW2901", "PLW3201", "PLR6301", "PLC0415", "PLR2004", "PLR09", "SIM108", "FURB113", "A005"]
28
+
29
+ [tool.ruff.lint.pydocstyle]
30
+ convention = "google"
31
+
32
+ [build-system]
33
+ requires = ["hatchling"]
34
+ build-backend = "hatchling.build"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["sonolus"]
@@ -0,0 +1,91 @@
1
+ import json
2
+ from pathlib import Path
3
+ from typing import TextIO
4
+
5
+ functions_file = "Functions.json"
6
+ block_files = {
7
+ "Tutorial": "Engine/Tutorial/Blocks.json",
8
+ "Play": "Level/Play/Blocks.json",
9
+ "Preview": "Level/Preview/Blocks.json",
10
+ "Watch": "Level/Watch/Blocks.json",
11
+ }
12
+ base_dir = Path(__file__).parent
13
+ out_dir = base_dir / "out"
14
+ runtimes_dir = base_dir / "runtimes"
15
+
16
+
17
+ def functions():
18
+ with (
19
+ (runtimes_dir / functions_file).open("r", encoding="utf-8") as f,
20
+ (out_dir / "ops.py").open("w", encoding="utf-8") as out,
21
+ ):
22
+ data = json.load(f)
23
+ out.write(
24
+ "from enum import Enum\n"
25
+ "\n"
26
+ "\n"
27
+ "class Op(str, Enum):\n"
28
+ " def __new__(cls, name: str, side_effects: bool, pure: bool, control_flow: bool):\n"
29
+ " obj = str.__new__(cls, name)\n"
30
+ " obj._value_ = name\n"
31
+ " obj.side_effects = side_effects\n"
32
+ " obj.pure = pure\n"
33
+ " obj.control_flow = control_flow\n"
34
+ " return obj\n"
35
+ "\n"
36
+ )
37
+ for function in data:
38
+ name = function["name"]
39
+ side_effects = function["sideEffects"]
40
+ pure = function["pure"]
41
+ control_flow = function["controlFlow"]
42
+ out.write(f' {name} = ("{name}", {side_effects}, {pure}, {control_flow})\n')
43
+
44
+
45
+ def block(name: str, f: TextIO, out: TextIO):
46
+ data = json.load(f)
47
+ out.write(f"class {name}Block(_Block, Enum):\n")
48
+ for block in data:
49
+ name = block["name"]
50
+ id_ = block["id"]
51
+ readable = block["readable"]
52
+ writable = block["writable"]
53
+ out.write(
54
+ f' {name} = ({id_}, {{{
55
+ ", ".join(f'"{e}"' for e in readable)
56
+ }}}, {{{
57
+ ", ".join(f'"{e}"' for e in writable)
58
+ }}})\n'
59
+ )
60
+
61
+
62
+ def blocks():
63
+ with (out_dir / "blocks.py").open("w", encoding="utf-8") as out:
64
+ out.write(
65
+ "from enum import Enum\n"
66
+ "\n"
67
+ "\n"
68
+ "class _Block(int):\n"
69
+ " def __new__(cls, id_: int, readable: set[str], writable: set[str]):\n"
70
+ " obj = int.__new__(cls, id_)\n"
71
+ " obj.readable = readable\n"
72
+ " obj.writable = writable\n"
73
+ " return obj\n"
74
+ )
75
+ for name, file in block_files.items():
76
+ out.write("\n\n")
77
+ with (
78
+ (runtimes_dir / file).open("r", encoding="utf-8") as f,
79
+ ):
80
+ block(name, f, out)
81
+ out.write(f"\n" f"\n" f"type Block = {" | ".join(f'{name}Block' for name in block_files)}\n")
82
+
83
+
84
+ def main():
85
+ out_dir.mkdir(exist_ok=True)
86
+ functions()
87
+ blocks()
88
+
89
+
90
+ if __name__ == "__main__":
91
+ main()
@@ -0,0 +1,315 @@
1
+ [
2
+ {
3
+ "name": "RuntimeEnvironment",
4
+ "id": 1000,
5
+ "readable": [
6
+ "preprocess",
7
+ "navigate",
8
+ "update"
9
+ ],
10
+ "writable": [
11
+ "preprocess"
12
+ ],
13
+ "values": [
14
+ {
15
+ "type": "item",
16
+ "name": "debugMode"
17
+ },
18
+ {
19
+ "type": "item",
20
+ "name": "screenAspectRatio"
21
+ },
22
+ {
23
+ "type": "item",
24
+ "name": "audioOffset"
25
+ }
26
+ ]
27
+ },
28
+ {
29
+ "name": "RuntimeUpdate",
30
+ "id": 1001,
31
+ "readable": [
32
+ "preprocess",
33
+ "navigate",
34
+ "update"
35
+ ],
36
+ "writable": [],
37
+ "values": [
38
+ {
39
+ "type": "item",
40
+ "name": "time"
41
+ },
42
+ {
43
+ "type": "item",
44
+ "name": "deltaTime"
45
+ },
46
+ {
47
+ "type": "item",
48
+ "name": "navigationDirection"
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "name": "RuntimeSkinTransform",
54
+ "id": 1002,
55
+ "readable": [
56
+ "preprocess",
57
+ "navigate",
58
+ "update"
59
+ ],
60
+ "writable": [
61
+ "preprocess",
62
+ "navigate",
63
+ "update"
64
+ ],
65
+ "values": [
66
+ {
67
+ "type": "item",
68
+ "name": "m",
69
+ "count": 16
70
+ }
71
+ ]
72
+ },
73
+ {
74
+ "name": "RuntimeParticleTransform",
75
+ "id": 1003,
76
+ "readable": [
77
+ "preprocess",
78
+ "navigate",
79
+ "update"
80
+ ],
81
+ "writable": [
82
+ "preprocess",
83
+ "navigate",
84
+ "update"
85
+ ],
86
+ "values": [
87
+ {
88
+ "type": "item",
89
+ "name": "m",
90
+ "count": 16
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ "name": "RuntimeBackground",
96
+ "id": 1004,
97
+ "readable": [
98
+ "preprocess",
99
+ "navigate",
100
+ "update"
101
+ ],
102
+ "writable": [
103
+ "preprocess",
104
+ "navigate",
105
+ "update"
106
+ ],
107
+ "values": [
108
+ {
109
+ "type": "group",
110
+ "items": [
111
+ {
112
+ "type": "item",
113
+ "name": "x"
114
+ },
115
+ {
116
+ "type": "item",
117
+ "name": "y"
118
+ }
119
+ ],
120
+ "count": 4
121
+ }
122
+ ]
123
+ },
124
+ {
125
+ "name": "RuntimeUI",
126
+ "id": 1005,
127
+ "readable": [
128
+ "preprocess",
129
+ "navigate",
130
+ "update"
131
+ ],
132
+ "writable": [
133
+ "preprocess"
134
+ ],
135
+ "values": [
136
+ {
137
+ "type": "group",
138
+ "items": [
139
+ {
140
+ "type": "item",
141
+ "name": "anchorX"
142
+ },
143
+ {
144
+ "type": "item",
145
+ "name": "anchorY"
146
+ },
147
+ {
148
+ "type": "item",
149
+ "name": "pivotX"
150
+ },
151
+ {
152
+ "type": "item",
153
+ "name": "pivotY"
154
+ },
155
+ {
156
+ "type": "item",
157
+ "name": "width"
158
+ },
159
+ {
160
+ "type": "item",
161
+ "name": "height"
162
+ },
163
+ {
164
+ "type": "item",
165
+ "name": "rotation"
166
+ },
167
+ {
168
+ "type": "item",
169
+ "name": "alpha"
170
+ },
171
+ {
172
+ "type": "item",
173
+ "name": "background"
174
+ }
175
+ ],
176
+ "forEach": [
177
+ "menu",
178
+ "navigationPrevious",
179
+ "navigationNext",
180
+ "instruction"
181
+ ]
182
+ }
183
+ ]
184
+ },
185
+ {
186
+ "name": "RuntimeUIConfiguration",
187
+ "id": 1006,
188
+ "readable": [
189
+ "preprocess",
190
+ "navigate",
191
+ "update"
192
+ ],
193
+ "writable": [
194
+ "preprocess"
195
+ ],
196
+ "values": [
197
+ {
198
+ "type": "group",
199
+ "items": [
200
+ {
201
+ "type": "item",
202
+ "name": "scale"
203
+ },
204
+ {
205
+ "type": "item",
206
+ "name": "alpha"
207
+ }
208
+ ],
209
+ "forEach": [
210
+ "menu",
211
+ "navigation",
212
+ "instruction"
213
+ ]
214
+ }
215
+ ]
216
+ },
217
+ {
218
+ "name": "TutorialMemory",
219
+ "id": 2000,
220
+ "readable": [
221
+ "preprocess",
222
+ "navigate",
223
+ "update"
224
+ ],
225
+ "writable": [
226
+ "preprocess",
227
+ "navigate",
228
+ "update"
229
+ ],
230
+ "values": [
231
+ {
232
+ "type": "item",
233
+ "name": "generic",
234
+ "count": 4096
235
+ }
236
+ ]
237
+ },
238
+ {
239
+ "name": "TutorialData",
240
+ "id": 2001,
241
+ "readable": [
242
+ "preprocess",
243
+ "navigate",
244
+ "update"
245
+ ],
246
+ "writable": [
247
+ "preprocess"
248
+ ],
249
+ "values": [
250
+ {
251
+ "type": "item",
252
+ "name": "generic",
253
+ "count": 4096
254
+ }
255
+ ]
256
+ },
257
+ {
258
+ "name": "TutorialInstruction",
259
+ "id": 2002,
260
+ "readable": [
261
+ "preprocess",
262
+ "navigate",
263
+ "update"
264
+ ],
265
+ "writable": [
266
+ "preprocess",
267
+ "navigate",
268
+ "update"
269
+ ],
270
+ "values": [
271
+ {
272
+ "type": "item",
273
+ "name": "text"
274
+ }
275
+ ]
276
+ },
277
+ {
278
+ "name": "EngineRom",
279
+ "id": 3000,
280
+ "readable": [
281
+ "preprocess",
282
+ "navigate",
283
+ "update"
284
+ ],
285
+ "writable": [],
286
+ "values": [
287
+ {
288
+ "type": "item",
289
+ "name": "rom",
290
+ "minCount": 0
291
+ }
292
+ ]
293
+ },
294
+ {
295
+ "name": "TemporaryMemory",
296
+ "id": 10000,
297
+ "readable": [
298
+ "preprocess",
299
+ "navigate",
300
+ "update"
301
+ ],
302
+ "writable": [
303
+ "preprocess",
304
+ "navigate",
305
+ "update"
306
+ ],
307
+ "values": [
308
+ {
309
+ "type": "item",
310
+ "name": "generic",
311
+ "count": 4096
312
+ }
313
+ ]
314
+ }
315
+ ]