unity-devkit 0.3.5.dev257__py3-none-any.whl → 0.3.5.dev261__py3-none-any.whl
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.
- unity_devkit/build_unity.py +1 -11
- unity_devkit/matrix.py +10 -4
- unity_devkit/player_build.py +58 -36
- unity_devkit/projects.py +28 -8
- {unity_devkit-0.3.5.dev257.dist-info → unity_devkit-0.3.5.dev261.dist-info}/METADATA +1 -1
- {unity_devkit-0.3.5.dev257.dist-info → unity_devkit-0.3.5.dev261.dist-info}/RECORD +8 -8
- {unity_devkit-0.3.5.dev257.dist-info → unity_devkit-0.3.5.dev261.dist-info}/WHEEL +0 -0
- {unity_devkit-0.3.5.dev257.dist-info → unity_devkit-0.3.5.dev261.dist-info}/entry_points.txt +0 -0
unity_devkit/build_unity.py
CHANGED
|
@@ -12,7 +12,7 @@ from build_artifact_registry.cache import restore, save
|
|
|
12
12
|
from build_artifact_registry.setup_oras import install_oras
|
|
13
13
|
from .identity import builds_registry, cache_key, cache_registry
|
|
14
14
|
from .license_restore import restore_or_activate_license
|
|
15
|
-
from .player_build import build_player,
|
|
15
|
+
from .player_build import build_player, resolve_unity_project
|
|
16
16
|
from .upm_cache import restore_upm_cache, save_upm_cache
|
|
17
17
|
|
|
18
18
|
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
@@ -47,15 +47,7 @@ def build_unity(
|
|
|
47
47
|
),
|
|
48
48
|
] = "",
|
|
49
49
|
development: Annotated[bool, typer.Option("--development", help="Development build column")] = False,
|
|
50
|
-
environment_preset: Annotated[
|
|
51
|
-
str, typer.Option(help="Environment preset name; empty leaves the workspace untouched")
|
|
52
|
-
] = "",
|
|
53
|
-
environment_field: Annotated[
|
|
54
|
-
list[str] | None,
|
|
55
|
-
typer.Option("--environment-field", help="Environment field override as path=value (repeatable)"),
|
|
56
|
-
] = None,
|
|
57
50
|
) -> None:
|
|
58
|
-
fields = parse_environment_fields(environment_field or [])
|
|
59
51
|
parsed_pr_number = int(pr_number) if pr_number else None
|
|
60
52
|
derived_cache_key = cache_key(project, platform, parsed_pr_number)
|
|
61
53
|
library_cache_registry = cache_registry(registry)
|
|
@@ -80,8 +72,6 @@ def build_unity(
|
|
|
80
72
|
version=version,
|
|
81
73
|
commit_count=commit_count,
|
|
82
74
|
development=development,
|
|
83
|
-
environment_preset=environment_preset,
|
|
84
|
-
environment_fields=fields,
|
|
85
75
|
)
|
|
86
76
|
for artifact in artifacts:
|
|
87
77
|
print(f"Built: {artifact}")
|
unity_devkit/matrix.py
CHANGED
|
@@ -5,7 +5,13 @@ from typing import Annotated
|
|
|
5
5
|
|
|
6
6
|
import typer
|
|
7
7
|
|
|
8
|
-
from .player_build import
|
|
8
|
+
from .player_build import (
|
|
9
|
+
LICENSE_IMAGE_MODULE,
|
|
10
|
+
UNITYCI_IMAGE_REVISION,
|
|
11
|
+
platform_build_target,
|
|
12
|
+
read_editor_version,
|
|
13
|
+
unityci_image_module,
|
|
14
|
+
)
|
|
9
15
|
from .projects import ProjectEntry, discover_projects
|
|
10
16
|
|
|
11
17
|
build_app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
@@ -22,11 +28,11 @@ def build_matrix(
|
|
|
22
28
|
matrix: list[dict[str, str]] = []
|
|
23
29
|
|
|
24
30
|
for name, entry in projects.items():
|
|
25
|
-
if not entry.
|
|
31
|
+
if not entry.platforms:
|
|
26
32
|
continue
|
|
27
33
|
version = read_editor_version(entry.path)
|
|
28
|
-
for platform in entry.
|
|
29
|
-
image_module =
|
|
34
|
+
for platform in entry.platforms:
|
|
35
|
+
image_module = unityci_image_module(platform_build_target(platform))
|
|
30
36
|
matrix.append({
|
|
31
37
|
"project": name,
|
|
32
38
|
"platform": platform,
|
unity_devkit/player_build.py
CHANGED
|
@@ -6,28 +6,36 @@ import sys
|
|
|
6
6
|
import tempfile
|
|
7
7
|
from collections.abc import Sequence
|
|
8
8
|
from pathlib import Path
|
|
9
|
-
from typing import TypedDict
|
|
10
9
|
|
|
11
10
|
from bashrun.bash import CalledProcessError, bash, bash_pipe
|
|
12
11
|
|
|
13
12
|
from .projects import ProjectEntry, discover_projects
|
|
14
13
|
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
UNITYCI_IMAGE_MODULES: dict[str, str] = {
|
|
16
|
+
"Android": "android",
|
|
17
|
+
"StandaloneLinux64": "linux-il2cpp",
|
|
18
|
+
"Win64": "windows-mono",
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
"AndroidMobile":
|
|
23
|
-
"MagicLeap2":
|
|
24
|
-
"Linux": {"build_target": "StandaloneLinux64", "unityci_image_module": "linux-il2cpp"},
|
|
25
|
-
"Windows": {"build_target": "Win64", "unityci_image_module": "windows-mono"},
|
|
21
|
+
PLATFORM_BUILD_TARGETS: dict[str, str] = {
|
|
22
|
+
"AndroidMobile": "Android",
|
|
23
|
+
"MagicLeap2": "Android",
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
UNITYCI_IMAGE_REVISION = "3"
|
|
29
27
|
LICENSE_IMAGE_MODULE = "linux-il2cpp"
|
|
30
|
-
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def platform_build_target(platform: str) -> str:
|
|
31
|
+
build_target = PLATFORM_BUILD_TARGETS.get(platform)
|
|
32
|
+
if build_target is None:
|
|
33
|
+
raise SystemExit(
|
|
34
|
+
f"No build target known for platform '{platform}' — add it to PLATFORM_BUILD_TARGETS "
|
|
35
|
+
"beside the matching SharedSpecs factory"
|
|
36
|
+
)
|
|
37
|
+
return build_target
|
|
38
|
+
|
|
31
39
|
|
|
32
40
|
# Pinned to the v2026.07.21 tag of dotnet/install-scripts (raw at the commit SHA, which
|
|
33
41
|
# is immutable, unlike the moving https://dot.net/v1/dotnet-install.sh redirect).
|
|
@@ -222,17 +230,13 @@ def prepare_unity_project(project_path: Path) -> None:
|
|
|
222
230
|
bash(f"dotnet nugetforunity restore {project_path}", env=env)
|
|
223
231
|
|
|
224
232
|
|
|
225
|
-
def
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if not separator or not path:
|
|
233
|
-
raise SystemExit(f"Invalid environment field entry (expected path=value): {entry!r}")
|
|
234
|
-
fields[path] = value
|
|
235
|
-
return fields
|
|
233
|
+
def unityci_image_module(build_target: str) -> str:
|
|
234
|
+
module = UNITYCI_IMAGE_MODULES.get(build_target)
|
|
235
|
+
if module is None:
|
|
236
|
+
raise SystemExit(
|
|
237
|
+
f"Unknown build target '{build_target}' — supported: {', '.join(sorted(UNITYCI_IMAGE_MODULES))}"
|
|
238
|
+
)
|
|
239
|
+
return module
|
|
236
240
|
|
|
237
241
|
|
|
238
242
|
def build_player(
|
|
@@ -242,22 +246,23 @@ def build_player(
|
|
|
242
246
|
version: str = "",
|
|
243
247
|
commit_count: int = 0,
|
|
244
248
|
development: bool = False,
|
|
245
|
-
environment_preset: str = "",
|
|
246
|
-
environment_fields: dict[str, str] | None = None,
|
|
247
249
|
) -> list[Path]:
|
|
248
250
|
project_config = resolve_unity_project(project)
|
|
249
|
-
|
|
250
|
-
if not
|
|
251
|
+
platforms = project_config.platforms
|
|
252
|
+
if not platforms:
|
|
251
253
|
raise SystemExit(
|
|
252
254
|
f"Project '{project}' declares no builds — add platform keys to its unity-devkit.json 'platforms' map"
|
|
253
255
|
)
|
|
254
|
-
if build not in
|
|
255
|
-
raise SystemExit(f"Unknown build '{build}' for project '{project}'. Valid: {', '.join(
|
|
256
|
-
if build not in PLATFORM_CONFIGS:
|
|
257
|
-
raise SystemExit(f"No platform config for build '{build}'. Valid: {', '.join(PLATFORM_CONFIGS)}")
|
|
256
|
+
if build not in platforms:
|
|
257
|
+
raise SystemExit(f"Unknown build '{build}' for project '{project}'. Valid: {', '.join(sorted(platforms))}")
|
|
258
258
|
|
|
259
259
|
project_path = project_config.path
|
|
260
|
-
build_target =
|
|
260
|
+
build_target = platform_build_target(build)
|
|
261
|
+
entry = project_config.entry
|
|
262
|
+
if not entry:
|
|
263
|
+
raise SystemExit(
|
|
264
|
+
f"Project '{project}' declares platforms but no 'entry' executeMethod in its unity-devkit.json"
|
|
265
|
+
)
|
|
261
266
|
prepare_unity_project(project_path)
|
|
262
267
|
|
|
263
268
|
if version:
|
|
@@ -273,17 +278,15 @@ def build_player(
|
|
|
273
278
|
before = snapshot_artifacts(build_directory)
|
|
274
279
|
|
|
275
280
|
env: dict[str, str] = {"PLATFORM": build, "DEVELOPMENT": "true" if development else "false"}
|
|
276
|
-
if environment_preset:
|
|
277
|
-
env["ENVIRONMENT"] = environment_preset
|
|
278
|
-
if environment_fields:
|
|
279
|
-
env["ENVIRONMENT_FIELDS"] = json.dumps(environment_fields)
|
|
280
281
|
run_unity_batchmode(
|
|
281
282
|
project_path,
|
|
282
|
-
f"-buildTarget {build_target} -executeMethod {
|
|
283
|
+
f"-buildTarget {build_target} -executeMethod {entry}",
|
|
283
284
|
nographics=False,
|
|
284
285
|
env=env,
|
|
285
286
|
)
|
|
286
287
|
|
|
288
|
+
verify_platform_record(project_path, build, development)
|
|
289
|
+
|
|
287
290
|
after = snapshot_artifacts(build_directory)
|
|
288
291
|
produced = sorted(path for path, modification_time in after.items() if before.get(path) != modification_time)
|
|
289
292
|
if not produced:
|
|
@@ -295,6 +298,25 @@ def build_player(
|
|
|
295
298
|
return produced
|
|
296
299
|
|
|
297
300
|
|
|
301
|
+
def verify_platform_record(project_path: Path, build: str, development: bool) -> None:
|
|
302
|
+
record_path = project_path / "Assets" / "_LocalWorkspace" / "platform.json"
|
|
303
|
+
if not record_path.is_file():
|
|
304
|
+
raise SystemExit(
|
|
305
|
+
f"No platform record at {record_path} — the project entry never ran the playerbuild Apply step"
|
|
306
|
+
)
|
|
307
|
+
record = json.loads(record_path.read_text(encoding="utf-8"))
|
|
308
|
+
if record.get("platform") != build:
|
|
309
|
+
raise SystemExit(
|
|
310
|
+
f"Platform record says '{record.get('platform')}' but '{build}' was requested — "
|
|
311
|
+
"the entry applied the wrong spec"
|
|
312
|
+
)
|
|
313
|
+
if record.get("development") != development:
|
|
314
|
+
raise SystemExit(
|
|
315
|
+
f"Platform record says development={record.get('development')} but the build ran "
|
|
316
|
+
f"with development={development}"
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
|
|
298
320
|
def replace_serialized_field(text: str, field_name: str, value: str) -> str:
|
|
299
321
|
pattern = re.compile(rf"^(?P<indent>[ \t]*){field_name}:.*$", re.MULTILINE)
|
|
300
322
|
rewritten, count = pattern.subn(lambda match: f"{match.group('indent')}{field_name}: {value}", text)
|
unity_devkit/projects.py
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from collections.abc import Iterator
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Self
|
|
5
5
|
|
|
6
|
-
from pydantic import BaseModel, ConfigDict, field_validator
|
|
6
|
+
from pydantic import BaseModel, ConfigDict, field_validator, model_validator
|
|
7
7
|
|
|
8
8
|
BUILD_CONFIG_FILENAME = "unity-devkit.json"
|
|
9
9
|
PROJECT_MARKER = Path("ProjectSettings") / "ProjectVersion.txt"
|
|
10
10
|
PRUNE_DIRECTORIES = {".git", "Library", "Temp", "obj", "Build", "node_modules", "__pycache__"}
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
class PlatformConfig(BaseModel):
|
|
14
|
+
model_config = ConfigDict(extra="forbid")
|
|
15
|
+
|
|
16
|
+
render_pipeline: str = ""
|
|
17
|
+
|
|
18
|
+
|
|
13
19
|
class BuildConfigFile(BaseModel):
|
|
14
|
-
model_config = ConfigDict(extra="
|
|
20
|
+
model_config = ConfigDict(extra="forbid")
|
|
15
21
|
|
|
16
22
|
name: str
|
|
17
|
-
|
|
23
|
+
entry: str | None = None
|
|
24
|
+
platforms: dict[str, PlatformConfig] | None = None
|
|
18
25
|
|
|
19
26
|
@field_validator("name")
|
|
20
27
|
@classmethod
|
|
@@ -23,10 +30,24 @@ class BuildConfigFile(BaseModel):
|
|
|
23
30
|
raise ValueError("unity-devkit.json 'name' must be a non-empty string")
|
|
24
31
|
return value
|
|
25
32
|
|
|
33
|
+
@model_validator(mode="after")
|
|
34
|
+
def entry_required_with_platforms(self) -> Self:
|
|
35
|
+
if self.platforms and not self.entry:
|
|
36
|
+
raise ValueError(
|
|
37
|
+
"unity-devkit.json declares 'platforms' — an 'entry' executeMethod is required "
|
|
38
|
+
"(a public static parameterless method the build invokes)"
|
|
39
|
+
)
|
|
40
|
+
return self
|
|
41
|
+
|
|
26
42
|
|
|
27
43
|
class ProjectEntry(BaseModel):
|
|
28
44
|
path: Path
|
|
29
|
-
|
|
45
|
+
entry: str | None = None
|
|
46
|
+
platforms: dict[str, PlatformConfig] | None = None
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def builds(self) -> list[str] | None:
|
|
50
|
+
return list(self.platforms) if self.platforms else None
|
|
30
51
|
|
|
31
52
|
|
|
32
53
|
def discover_projects() -> dict[str, ProjectEntry]:
|
|
@@ -49,14 +70,13 @@ def discover_projects() -> dict[str, ProjectEntry]:
|
|
|
49
70
|
f"and previously at {first_seen[parsed.name]}"
|
|
50
71
|
)
|
|
51
72
|
first_seen[parsed.name] = config_path
|
|
52
|
-
|
|
53
|
-
discovered[parsed.name] = ProjectEntry(path=directory, builds=builds)
|
|
73
|
+
discovered[parsed.name] = ProjectEntry(path=directory, entry=parsed.entry, platforms=parsed.platforms)
|
|
54
74
|
|
|
55
75
|
if not discovered:
|
|
56
76
|
raise SystemExit(
|
|
57
77
|
f"No {BUILD_CONFIG_FILENAME} found under {root} — declare Unity projects with a "
|
|
58
78
|
f"{BUILD_CONFIG_FILENAME} per project root (carrying a 'name' field; 'platforms' "
|
|
59
|
-
|
|
79
|
+
"keys are the build targets)"
|
|
60
80
|
)
|
|
61
81
|
return discovered
|
|
62
82
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
unity_devkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
unity_devkit/build_unity.py,sha256=
|
|
2
|
+
unity_devkit/build_unity.py,sha256=v2uTPVP_I_xWd6I7hwX7YpV2InpbZ8A2PbFdJJe95ic,6255
|
|
3
3
|
unity_devkit/check_unity_lock.py,sha256=FJSsEmk2vmpdRGyAOYEqDytu8gcbfPekYOBvX9smW2w,2501
|
|
4
4
|
unity_devkit/compile_check_unity.py,sha256=E3olw0uh9-_F6ocJLgLIcOHaje_fnXj1BEfxbeGa8Ns,2537
|
|
5
5
|
unity_devkit/identity.py,sha256=8uuIU49EEX3FPA3FRBW6XFZZijRBcb3trEQmz0hbiL4,364
|
|
@@ -7,13 +7,13 @@ unity_devkit/install.py,sha256=2KJ3WT3Ljc5dwh-hDlxi7Qem0-Atl7iyG3ZiY9LjIdo,7776
|
|
|
7
7
|
unity_devkit/license.py,sha256=ESst2YYj2h2JWMqcQs07jIZkS9FfG4_g2HEwhZyVssE,813
|
|
8
8
|
unity_devkit/license_restore.py,sha256=tMRxGkn_I0cCKBV8Sg_2NPFS97JJhctAsmRhJ5mcz_0,2417
|
|
9
9
|
unity_devkit/lock_unity.py,sha256=-1d-mHva5XUOlki8LSO5qwABR52q7jzc7FTJnnTH9f8,1012
|
|
10
|
-
unity_devkit/matrix.py,sha256=
|
|
11
|
-
unity_devkit/player_build.py,sha256=
|
|
12
|
-
unity_devkit/projects.py,sha256=
|
|
10
|
+
unity_devkit/matrix.py,sha256=Sqvbsc2fkR8Nmf-AdUhfbMLjkIYIfPBlgO0rthQBgn0,2397
|
|
11
|
+
unity_devkit/player_build.py,sha256=pQhHwF3o7ciUnuTvvWDJwgFyAwkTgSNCeCoickfX3wU,13832
|
|
12
|
+
unity_devkit/projects.py,sha256=4pLhbKoif5yE_awe3bZjppyW_Pjf4HADOT2yz_yDuRw,3332
|
|
13
13
|
unity_devkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
unity_devkit/test_unity.py,sha256=SpeWnV2hpdZBaGsstL8RTO50C2HEAcvantzBQYeaTpE,1075
|
|
15
15
|
unity_devkit/upm_cache.py,sha256=s4-Op9aIebcjk5pFTciSomHfAAR8KDp2nMzIZlC5icg,1158
|
|
16
|
-
unity_devkit-0.3.5.
|
|
17
|
-
unity_devkit-0.3.5.
|
|
18
|
-
unity_devkit-0.3.5.
|
|
19
|
-
unity_devkit-0.3.5.
|
|
16
|
+
unity_devkit-0.3.5.dev261.dist-info/METADATA,sha256=q1YoRSez0yt26kOH8YpWJ4ZL82zwqQzHLAr1FgcYPA0,315
|
|
17
|
+
unity_devkit-0.3.5.dev261.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
18
|
+
unity_devkit-0.3.5.dev261.dist-info/entry_points.txt,sha256=QgnvRYXFbq3QUd93EGqFyYuE1xfW1jGA7fE99D4uKwg,524
|
|
19
|
+
unity_devkit-0.3.5.dev261.dist-info/RECORD,,
|
|
File without changes
|
{unity_devkit-0.3.5.dev257.dist-info → unity_devkit-0.3.5.dev261.dist-info}/entry_points.txt
RENAMED
|
File without changes
|