unity-devkit 0.3.4.dev252__py3-none-any.whl → 0.3.5__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.
@@ -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, parse_environment_fields, resolve_unity_project
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}")
@@ -0,0 +1,68 @@
1
+ import json
2
+ from pathlib import Path
3
+ from typing import Annotated, Any
4
+
5
+ import typer
6
+
7
+ from .projects import discover_projects
8
+
9
+ app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
10
+
11
+
12
+ @app.command()
13
+ def check_unity_lock(project: Annotated[str | None, typer.Option(help="Limit to a specific project.")] = None) -> None:
14
+ config = discover_projects()
15
+
16
+ if project is not None and project not in config:
17
+ raise typer.BadParameter(f"Unknown project '{project}'. Valid: {', '.join(config)}")
18
+
19
+ projects = {project: config[project]} if project else config
20
+ failures: list[str] = []
21
+
22
+ for name, project_config in projects.items():
23
+ print(f"Checking {name} ({project_config.path / 'Packages' / 'packages-lock.json'})...")
24
+ failures.extend(check_project_lock(name, project_config.path))
25
+
26
+ if failures:
27
+ for failure in failures:
28
+ print(f" {failure}")
29
+
30
+ raise SystemExit(
31
+ "packages-lock.json disagrees with Packages/manifest.json — run 'uv run lock-unity' "
32
+ "to regenerate the lock, then commit it."
33
+ )
34
+
35
+ print("Every packages-lock.json agrees with its manifest.")
36
+
37
+
38
+ def check_project_lock(name: str, project_path: Path) -> list[str]:
39
+ packages_directory = project_path / "Packages"
40
+ manifest_path = packages_directory / "manifest.json"
41
+ lock_path = packages_directory / "packages-lock.json"
42
+
43
+ if not manifest_path.is_file():
44
+ return [f"{name}: {manifest_path} does not exist"]
45
+
46
+ if not lock_path.is_file():
47
+ return [f"{name}: {lock_path} does not exist — run 'uv run lock-unity' to generate it."]
48
+
49
+ try:
50
+ manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
51
+ lock = json.loads(lock_path.read_text(encoding="utf-8"))
52
+ except json.JSONDecodeError as error:
53
+ return [f"{name}: unparseable manifest/lock JSON: {error.msg} at line {error.lineno}"]
54
+
55
+ requirements: dict[str, Any] = manifest.get("dependencies", {})
56
+ locked: dict[str, Any] = lock.get("dependencies", {})
57
+
58
+ failures: list[str] = []
59
+
60
+ for package, requirement in sorted(requirements.items()):
61
+ entry = locked.get(package)
62
+
63
+ if entry is None:
64
+ failures.append(f"{name}: '{package}' ({requirement}) is absent from packages-lock.json")
65
+ elif entry.get("version") != requirement:
66
+ failures.append(f"{name}: '{package}' manifest wants {requirement}, lock recorded {entry.get('version')}")
67
+
68
+ return failures
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 LICENSE_IMAGE_MODULE, PLATFORM_CONFIGS, UNITYCI_IMAGE_REVISION, read_editor_version
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.builds:
31
+ if not entry.platforms:
26
32
  continue
27
33
  version = read_editor_version(entry.path)
28
- for platform in entry.builds:
29
- image_module = PLATFORM_CONFIGS[platform]["unityci_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,
@@ -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
- class PlatformConfig(TypedDict):
17
- build_target: str
18
- unityci_image_module: str
19
-
15
+ UNITYCI_IMAGE_MODULES: dict[str, str] = {
16
+ "Android": "android",
17
+ "StandaloneLinux64": "linux-il2cpp",
18
+ "Win64": "windows-mono",
19
+ }
20
20
 
21
- PLATFORM_CONFIGS: dict[str, PlatformConfig] = {
22
- "AndroidMobile": {"build_target": "Android", "unityci_image_module": "android"},
23
- "MagicLeap2": {"build_target": "Android", "unityci_image_module": "android"},
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
- PLAYERBUILD_ENTRY = "Outernet.PlayerBuild.Entry"
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 parse_environment_fields(entries: Sequence[str]) -> dict[str, str]:
226
- fields: dict[str, str] = {}
227
- for entry in entries:
228
- line = entry.strip()
229
- if not line:
230
- continue
231
- path, separator, value = line.partition("=")
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
- valid_builds = project_config.builds or []
250
- if not valid_builds:
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 valid_builds:
255
- raise SystemExit(f"Unknown build '{build}' for project '{project}'. Valid: {', '.join(valid_builds)}")
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 = PLATFORM_CONFIGS[build]["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 {PLAYERBUILD_ENTRY}",
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 Any
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="ignore")
20
+ model_config = ConfigDict(extra="forbid")
15
21
 
16
22
  name: str
17
- platforms: dict[str, Any] | None = None
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
- builds: list[str] | None = None
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
- builds = list(parsed.platforms.keys()) if parsed.platforms else None
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
- f"keys are the build targets)"
79
+ "keys are the build targets)"
60
80
  )
61
81
  return discovered
62
82
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: unity-devkit
3
- Version: 0.3.4.dev252
3
+ Version: 0.3.5
4
4
  Summary: Unity build, license, and CI tooling
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: bashrun>=0.1.0
@@ -1,18 +1,19 @@
1
1
  unity_devkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- unity_devkit/build_unity.py,sha256=saKXpZSEz-OMxwu1PHHInYtU1t2qtiu8VOpONoO-emA,6750
2
+ unity_devkit/build_unity.py,sha256=v2uTPVP_I_xWd6I7hwX7YpV2InpbZ8A2PbFdJJe95ic,6255
3
+ unity_devkit/check_unity_lock.py,sha256=FJSsEmk2vmpdRGyAOYEqDytu8gcbfPekYOBvX9smW2w,2501
3
4
  unity_devkit/compile_check_unity.py,sha256=E3olw0uh9-_F6ocJLgLIcOHaje_fnXj1BEfxbeGa8Ns,2537
4
5
  unity_devkit/identity.py,sha256=8uuIU49EEX3FPA3FRBW6XFZZijRBcb3trEQmz0hbiL4,364
5
6
  unity_devkit/install.py,sha256=2KJ3WT3Ljc5dwh-hDlxi7Qem0-Atl7iyG3ZiY9LjIdo,7776
6
7
  unity_devkit/license.py,sha256=ESst2YYj2h2JWMqcQs07jIZkS9FfG4_g2HEwhZyVssE,813
7
8
  unity_devkit/license_restore.py,sha256=tMRxGkn_I0cCKBV8Sg_2NPFS97JJhctAsmRhJ5mcz_0,2417
8
9
  unity_devkit/lock_unity.py,sha256=-1d-mHva5XUOlki8LSO5qwABR52q7jzc7FTJnnTH9f8,1012
9
- unity_devkit/matrix.py,sha256=URDN-UJ-Q9SaU_qBhl-Koc2lEeIJkE6IpwyKnfsxlMw,2336
10
- unity_devkit/player_build.py,sha256=YXHolDPjU4w4H-fquchhrWhSuxN56ewfM2KjyLbI1UI,13248
11
- unity_devkit/projects.py,sha256=PO5plIj-mn8KkKOUhGRRIL_sDdd6ohl12neS2poILhs,2665
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
12
13
  unity_devkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
14
  unity_devkit/test_unity.py,sha256=SpeWnV2hpdZBaGsstL8RTO50C2HEAcvantzBQYeaTpE,1075
14
15
  unity_devkit/upm_cache.py,sha256=s4-Op9aIebcjk5pFTciSomHfAAR8KDp2nMzIZlC5icg,1158
15
- unity_devkit-0.3.4.dev252.dist-info/METADATA,sha256=1EEoqcly6vjaBws0Cef1o5f9tO57TlTeREzqTF0Vcx4,315
16
- unity_devkit-0.3.4.dev252.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
17
- unity_devkit-0.3.4.dev252.dist-info/entry_points.txt,sha256=_GfnlOh8IWYzCh2Z8QVXMiJqppcNx8_sj0MX1d_Vky0,471
18
- unity_devkit-0.3.4.dev252.dist-info/RECORD,,
16
+ unity_devkit-0.3.5.dist-info/METADATA,sha256=dc3wDrzWF8P_d2ySc5AEqA8ehdXAZG45jyM6biRTUb4,308
17
+ unity_devkit-0.3.5.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
+ unity_devkit-0.3.5.dist-info/entry_points.txt,sha256=QgnvRYXFbq3QUd93EGqFyYuE1xfW1jGA7fE99D4uKwg,524
19
+ unity_devkit-0.3.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.4
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -2,6 +2,7 @@
2
2
  activate-unity-license = unity_devkit.license:activate_app
3
3
  build-unity = unity_devkit.build_unity:app
4
4
  build-unity-matrix = unity_devkit.matrix:build_app
5
+ check-unity-lock = unity_devkit.check_unity_lock:app
5
6
  compile-check-unity = unity_devkit.compile_check_unity:app
6
7
  compile-check-unity-matrix = unity_devkit.matrix:compile_check_app
7
8
  install = unity_devkit.install:app