unity-devkit 0.3.4__tar.gz → 0.3.5.dev257__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 (26) hide show
  1. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/PKG-INFO +1 -1
  2. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/pyproject.toml +2 -1
  3. unity_devkit-0.3.5.dev257/src/unity_devkit/check_unity_lock.py +68 -0
  4. unity_devkit-0.3.5.dev257/tests/test_check_unity_lock.py +140 -0
  5. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/.gitignore +0 -0
  6. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/__init__.py +0 -0
  7. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/build_unity.py +0 -0
  8. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/compile_check_unity.py +0 -0
  9. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/identity.py +0 -0
  10. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/install.py +0 -0
  11. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/license.py +0 -0
  12. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/license_restore.py +0 -0
  13. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/lock_unity.py +0 -0
  14. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/matrix.py +0 -0
  15. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/player_build.py +0 -0
  16. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/projects.py +0 -0
  17. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/py.typed +0 -0
  18. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/test_unity.py +0 -0
  19. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/src/unity_devkit/upm_cache.py +0 -0
  20. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/tests/test_build_player.py +0 -0
  21. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/tests/test_identity.py +0 -0
  22. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/tests/test_matrix.py +0 -0
  23. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/tests/test_prepare.py +0 -0
  24. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/tests/test_projects.py +0 -0
  25. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/tests/test_run_unity_batchmode.py +0 -0
  26. {unity_devkit-0.3.4 → unity_devkit-0.3.5.dev257}/tests/test_upm_cache.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: unity-devkit
3
- Version: 0.3.4
3
+ Version: 0.3.5.dev257
4
4
  Summary: Unity build, license, and CI tooling
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: bashrun>=0.1.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "unity-devkit"
3
- version = "0.3.4"
3
+ version = "0.3.5.dev257"
4
4
  description = "Unity build, license, and CI tooling"
5
5
  requires-python = ">=3.13"
6
6
  dependencies = [
@@ -15,6 +15,7 @@ dependencies = [
15
15
  activate-unity-license = "unity_devkit.license:activate_app"
16
16
  build-unity = "unity_devkit.build_unity:app"
17
17
  build-unity-matrix = "unity_devkit.matrix:build_app"
18
+ check-unity-lock = "unity_devkit.check_unity_lock:app"
18
19
  compile-check-unity = "unity_devkit.compile_check_unity:app"
19
20
  compile-check-unity-matrix = "unity_devkit.matrix:compile_check_app"
20
21
  install = "unity_devkit.install:app"
@@ -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
@@ -0,0 +1,140 @@
1
+ import json
2
+ from pathlib import Path
3
+
4
+ import pytest
5
+ import typer
6
+
7
+ from unity_devkit.check_unity_lock import check_project_lock, check_unity_lock
8
+
9
+ MANIFEST = {
10
+ "dependencies": {
11
+ "com.unity.xr.management": "4.5.3",
12
+ "org.outernet.lbetoolkit": "https://github.com/outernet-foundation/lbe-toolkit.git?path=/Core#3783af528365f8dfc98d3fff0f0717fa5e7019",
13
+ }
14
+ }
15
+
16
+ MATCHING_LOCK = {
17
+ "dependencies": {
18
+ "com.unity.xr.management": {"version": "4.5.3", "depth": 0, "source": "registry"},
19
+ "com.unity.mathematics": {"version": "1.3.2", "depth": 1, "source": "registry"},
20
+ "org.outernet.lbetoolkit": {
21
+ "version": "https://github.com/outernet-foundation/lbe-toolkit.git?path=/Core#3783af528365f8dfc98d3fff0f0717fa5e7019",
22
+ "depth": 0,
23
+ "source": "git",
24
+ "hash": "3783af528365f8dfc98d3fff0f0717fa5e7019",
25
+ },
26
+ }
27
+ }
28
+
29
+
30
+ def write_packages(
31
+ tmp_path: Path,
32
+ manifest: str = json.dumps(MANIFEST),
33
+ lock: str | None = json.dumps(MATCHING_LOCK),
34
+ ) -> Path:
35
+ packages = tmp_path / "Packages"
36
+ packages.mkdir(parents=True)
37
+ (packages / "manifest.json").write_text(manifest, encoding="utf-8")
38
+
39
+ if lock is not None:
40
+ (packages / "packages-lock.json").write_text(lock, encoding="utf-8")
41
+
42
+ return tmp_path
43
+
44
+
45
+ def test_matching_lock_reports_nothing(tmp_path: Path) -> None:
46
+ write_packages(tmp_path)
47
+
48
+ assert check_project_lock("tool", tmp_path) == []
49
+
50
+
51
+ def test_ignores_lock_entries_without_manifest_dependencies(tmp_path: Path) -> None:
52
+ assert check_project_lock("tool", write_packages(tmp_path, manifest=json.dumps({"dependencies": {}}))) == []
53
+
54
+
55
+ def test_version_mismatch_is_reported(tmp_path: Path) -> None:
56
+ stale = json.loads(json.dumps(MATCHING_LOCK))
57
+ stale["dependencies"]["org.outernet.lbetoolkit"] = {"version": "1.1.0-dev.39", "depth": 0, "source": "registry"}
58
+ write_packages(tmp_path, lock=json.dumps(stale))
59
+
60
+ failures = check_project_lock("tool", tmp_path)
61
+
62
+ assert len(failures) == 1
63
+ assert "org.outernet.lbetoolkit" in failures[0]
64
+ assert "1.1.0-dev.39" in failures[0]
65
+ assert "3783af528365f8dfc98d3fff0f0717fa5e7019" in failures[0]
66
+
67
+
68
+ def test_manifest_dependency_absent_from_lock_is_reported(tmp_path: Path) -> None:
69
+ stale = json.loads(json.dumps(MATCHING_LOCK))
70
+ del stale["dependencies"]["com.unity.xr.management"]
71
+ write_packages(tmp_path, lock=json.dumps(stale))
72
+
73
+ failures = check_project_lock("tool", tmp_path)
74
+
75
+ assert len(failures) == 1
76
+ assert "com.unity.xr.management" in failures[0]
77
+ assert "4.5.3" in failures[0]
78
+
79
+
80
+ def test_missing_lock_file_is_reported(tmp_path: Path) -> None:
81
+ write_packages(tmp_path, lock=None)
82
+
83
+ failures = check_project_lock("tool", tmp_path)
84
+
85
+ assert len(failures) == 1
86
+ assert "lock-unity" in failures[0]
87
+
88
+
89
+ def test_missing_manifest_is_reported(tmp_path: Path) -> None:
90
+ project = write_packages(tmp_path)
91
+ (project / "Packages" / "manifest.json").unlink()
92
+
93
+ assert check_project_lock("tool", tmp_path) == [f"tool: {project / 'Packages' / 'manifest.json'} does not exist"]
94
+
95
+
96
+ def test_unparseable_lock_is_reported(tmp_path: Path) -> None:
97
+ write_packages(tmp_path, lock="{")
98
+
99
+ failures = check_project_lock("tool", tmp_path)
100
+
101
+ assert len(failures) == 1
102
+ assert "unparseable" in failures[0]
103
+
104
+
105
+ def test_cli_passes_when_every_project_agrees(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
106
+ project = tmp_path / "Tool"
107
+ (project / "ProjectSettings").mkdir(parents=True)
108
+ (project / "ProjectSettings" / "ProjectVersion.txt").write_text("m_EditorVersion: 6000.0.66f1\n")
109
+ (project / "unity-devkit.json").write_text(json.dumps({"name": "Tool", "platforms": {"Linux": {}}}))
110
+ packages = project / "Packages"
111
+ packages.mkdir()
112
+ (packages / "manifest.json").write_text(json.dumps(MANIFEST), encoding="utf-8")
113
+ (packages / "packages-lock.json").write_text(json.dumps(MATCHING_LOCK), encoding="utf-8")
114
+ monkeypatch.chdir(tmp_path)
115
+
116
+ check_unity_lock(project=None)
117
+
118
+
119
+ def test_cli_exits_non_zero_on_drift(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
120
+ project = tmp_path / "Tool"
121
+ (project / "ProjectSettings").mkdir(parents=True)
122
+ (project / "ProjectSettings" / "ProjectVersion.txt").write_text("m_EditorVersion: 6000.0.66f1\n")
123
+ (project / "unity-devkit.json").write_text(json.dumps({"name": "Tool", "platforms": {"Linux": {}}}))
124
+ packages = project / "Packages"
125
+ packages.mkdir()
126
+ (packages / "manifest.json").write_text(json.dumps(MANIFEST), encoding="utf-8")
127
+ monkeypatch.chdir(tmp_path)
128
+
129
+ with pytest.raises(SystemExit, match="lock-unity"):
130
+ check_unity_lock(project=None)
131
+
132
+
133
+ def test_cli_rejects_unknown_project(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
134
+ monkeypatch.chdir(tmp_path)
135
+ (tmp_path / "ProjectSettings").mkdir()
136
+ (tmp_path / "ProjectSettings" / "ProjectVersion.txt").write_text("m_EditorVersion: 6000.0.66f1\n")
137
+ (tmp_path / "unity-devkit.json").write_text(json.dumps({"name": "Tool"}))
138
+
139
+ with pytest.raises(typer.BadParameter):
140
+ check_unity_lock(project="other")