unity-devkit 0.1.13__py3-none-any.whl → 0.1.14__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.
@@ -7,6 +7,7 @@ from pathlib import Path
7
7
  from typing import Annotated
8
8
 
9
9
  import typer
10
+ from bashrun.bash import bash_output
10
11
  from pydantic_settings import BaseSettings
11
12
 
12
13
  from ci_devkit.cache import restore, save
@@ -15,15 +16,12 @@ from .license_restore import restore_license
15
16
  from ci_devkit.setup import configure_git, install_dotnet
16
17
  from ci_devkit.setup_oras import install_oras
17
18
  from .unity import prepare_unity_project, resolve_unity_build, run_unity_batchmode
18
- from ci_devkit.git_tags import get_latest_tag_version
19
19
 
20
20
 
21
21
  class Settings(BaseSettings):
22
22
  github_workspace: str
23
23
 
24
24
 
25
- settings = Settings.model_validate({})
26
-
27
25
  app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
28
26
 
29
27
 
@@ -40,6 +38,8 @@ def main(
40
38
  str, typer.Option(help="Newline-separated KEY=VALUE pairs injected into the Unity build process environment")
41
39
  ] = "",
42
40
  ) -> None:
41
+ settings = Settings.model_validate({})
42
+
43
43
  for line in build_env.splitlines():
44
44
  entry = line.strip()
45
45
  if not entry:
@@ -66,14 +66,18 @@ def main(
66
66
  with ci_step("Prepare build"):
67
67
  project_config, build_flag, execute_method = resolve_unity_build(project, platform)
68
68
  unity_project_path = project_config.path
69
+ if unity_project_path.resolve() != project_path.resolve():
70
+ raise SystemExit(
71
+ f"--project-path {project_path} does not match catalog entry '{project}' at {unity_project_path}"
72
+ )
69
73
 
70
74
  with ci_step("Prepare project"):
71
75
  prepare_unity_project(unity_project_path)
72
76
 
73
- with ci_step(f"Build {unity_project_path.name} [{platform}]"):
77
+ with ci_step(f"Build {project} [{platform}]"):
74
78
  tag_prefix = project_config.tag_prefix
75
79
  if tag_prefix:
76
- version = get_latest_tag_version(f"{tag_prefix}-v") or "0.0.0"
80
+ version = latest_tag_version(f"{tag_prefix}-v") or "0.0.0"
77
81
  full_version = f"{version}-dev+{run_number}" if branch != "main" else f"{version}+{run_number}"
78
82
  version_file = unity_project_path / ".build-version.json"
79
83
  version_file.write_text(json.dumps({"version": full_version, "runNumber": run_number}))
@@ -100,3 +104,10 @@ def main(
100
104
  for file in build_directory.rglob("*"):
101
105
  if file.suffix in {".apk", ".exe"}:
102
106
  shutil.copy2(file, artifact_directory / file.name)
107
+
108
+
109
+ def latest_tag_version(prefix: str) -> str | None:
110
+ output = bash_output(f'git tag --list "{prefix}*" --sort=-v:refname').strip()
111
+ if not output:
112
+ return None
113
+ return output.splitlines()[0][len(prefix) :]
@@ -10,9 +10,7 @@ app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
10
10
 
11
11
  @app.command()
12
12
  def compile_unity(
13
- project: Annotated[
14
- str, typer.Option(help="Unity project name (directory containing ProjectSettings/ProjectVersion.txt)")
15
- ],
13
+ project: Annotated[str, typer.Option(help="Unity project name (catalog key in unity-devkit.json)")],
16
14
  build: Annotated[str, typer.Option(help="Build target from the project's builds list (e.g. android-mobile)")],
17
15
  ) -> None:
18
16
  for artifact in build_unity_project(project, build):
unity_devkit/install.py CHANGED
@@ -9,7 +9,7 @@ import typer
9
9
  from bashrun.bash import bash, bash_check, bash_handoff, bash_output
10
10
 
11
11
  from .compile_unity import build_unity_project
12
- from .projects import load_unity_projects
12
+ from .projects import load_catalog
13
13
 
14
14
  INSTALLABLE_TARGETS = {"android-mobile", "magicleap", "linux64"}
15
15
  ADB_TARGETS = {"android-mobile", "magicleap"}
@@ -37,7 +37,7 @@ def main(
37
37
  "--no-grant-permissions",
38
38
  help=(
39
39
  "Skip the post-install `adb shell pm grant` calls listed under `grant_permissions` "
40
- "for the project in its unity-build.json manifest. Permissions are granted by default."
40
+ "for the project's entry in unity-devkit.json. Permissions are granted by default."
41
41
  ),
42
42
  ),
43
43
  ] = False,
@@ -53,7 +53,7 @@ def main(
53
53
  ),
54
54
  ] = False,
55
55
  ) -> None:
56
- projects = load_unity_projects()
56
+ projects = load_catalog()
57
57
 
58
58
  project_name = next((name for name in projects if name.lower() == project.lower()), None)
59
59
  if project_name is None:
@@ -156,7 +156,7 @@ def main(
156
156
  if permissions and not no_grant_permissions:
157
157
  if not package:
158
158
  raise typer.BadParameter(
159
- f"{project_name} has grant_permissions but no 'package' field in unity-build.json"
159
+ f"{project_name} has grant_permissions but no 'package' field in its unity-devkit.json entry"
160
160
  )
161
161
  for permission in permissions:
162
162
  print(f"Granting {permission} to {package}")
@@ -2,7 +2,7 @@ from typing import Annotated
2
2
 
3
3
  import typer
4
4
 
5
- from .projects import load_unity_projects
5
+ from .projects import load_catalog
6
6
  from .unity import prepare_unity_project, run_unity_batchmode
7
7
 
8
8
  app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
@@ -10,7 +10,7 @@ app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
10
10
 
11
11
  @app.command()
12
12
  def lock_unity(project: Annotated[str | None, typer.Option(help="Limit to a specific project.")] = None) -> None:
13
- config = load_unity_projects()
13
+ config = load_catalog()
14
14
 
15
15
  if project is not None and project not in config:
16
16
  raise typer.BadParameter(f"Unknown project '{project}'. Valid: {', '.join(config)}")
unity_devkit/matrix.py CHANGED
@@ -1,12 +1,12 @@
1
1
  import json
2
2
  from pathlib import Path
3
3
 
4
- from .projects import load_unity_projects
4
+ from .projects import load_catalog
5
5
  from .unity import LICENSE_MODULE, PLATFORM_CONFIGS, UNITYCI_IMAGE_REVISION, read_editor_version
6
6
 
7
7
 
8
8
  def main() -> None:
9
- projects = load_unity_projects()
9
+ projects = load_catalog()
10
10
  matrix: list[dict[str, str]] = []
11
11
  editor_versions: set[str] = set()
12
12
 
@@ -28,7 +28,7 @@ def main() -> None:
28
28
 
29
29
  if not editor_versions:
30
30
  raise SystemExit(
31
- "No projects with builds declared — unity-matrix needs at least one unity-build.json with a 'builds' list"
31
+ "No projects with builds declared — unity-matrix needs at least one unity-devkit.json entry with a 'builds' list"
32
32
  )
33
33
  license_version = max(editor_versions)
34
34
  print(f"matrix={json.dumps({'include': matrix})}")
unity_devkit/projects.py CHANGED
@@ -1,55 +1,50 @@
1
- import json
2
1
  import os
3
2
  from collections.abc import Iterator
4
3
  from pathlib import Path
5
4
 
6
- from pydantic import BaseModel
5
+ from pydantic import BaseModel, ConfigDict, Field, TypeAdapter, field_validator
7
6
 
8
- MANIFEST_FILENAME = "unity-build.json"
7
+ CATALOG_FILENAME = "unity-devkit.json"
9
8
  PROJECT_MARKER = Path("ProjectSettings") / "ProjectVersion.txt"
10
9
  PRUNE_DIRECTORIES = {".git", "Library", "Temp", "obj", "Build", "node_modules", "__pycache__"}
11
10
 
12
11
 
13
- class UnityBuildManifest(BaseModel, extra="forbid"):
12
+ class CatalogEntry(BaseModel):
13
+ model_config = ConfigDict(extra="forbid")
14
+
15
+ path: Path
14
16
  builds: list[str] | None = None
15
17
  execute_methods: dict[str, str] | None = None
16
18
  package: str | None = None
17
- grant_permissions: list[str] = []
19
+ grant_permissions: list[str] = Field(default_factory=list)
18
20
  tag_prefix: str | None = None
19
21
 
22
+ @field_validator("path")
23
+ @classmethod
24
+ def anchor_relative_path(cls, value: Path) -> Path:
25
+ return value if value.is_absolute() else Path.cwd() / value
20
26
 
21
- class UnityProject(UnityBuildManifest):
22
- path: Path
23
-
24
-
25
- def load_unity_projects() -> dict[str, UnityProject]:
26
- root = Path.cwd()
27
- project_directories = {directory.resolve() for directory in unity_project_directories(root)}
28
- manifest_directories = {directory.resolve() for directory in directories_containing(root, MANIFEST_FILENAME)}
29
-
30
- projects: dict[str, UnityProject] = {}
31
- for project_path in sorted(project_directories | manifest_directories):
32
- if project_path not in project_directories:
33
- raise SystemExit(
34
- f"{project_path / MANIFEST_FILENAME} is not inside a Unity project: missing {PROJECT_MARKER}"
35
- )
36
27
 
37
- manifest_path = project_path / MANIFEST_FILENAME
38
- if manifest_path.exists():
39
- manifest = UnityBuildManifest(**json.loads(manifest_path.read_text()))
40
- else:
41
- manifest = UnityBuildManifest()
28
+ CATALOG_ADAPTER = TypeAdapter(dict[str, CatalogEntry])
42
29
 
43
- name = project_path.name
44
- if name in projects:
45
- raise SystemExit(f"Duplicate Unity project name '{name}': {projects[name].path} and {project_path}")
46
- projects[name] = UnityProject(path=project_path, **manifest.model_dump())
47
30
 
48
- if not projects:
31
+ def load_catalog() -> dict[str, CatalogEntry]:
32
+ catalog_path = Path.cwd() / CATALOG_FILENAME
33
+ if not catalog_path.is_file():
49
34
  raise SystemExit(
50
- f"No Unity projects found under {root} — a project is a directory containing {PROJECT_MARKER}. Run from the repo root"
35
+ f"No {CATALOG_FILENAME} catalog at {catalog_path} — declare Unity projects as catalog entries at the repo root"
51
36
  )
52
- return projects
37
+
38
+ catalog = CATALOG_ADAPTER.validate_json(catalog_path.read_text(encoding="utf-8"))
39
+ if not catalog:
40
+ raise SystemExit(f"{catalog_path} declares no projects — at least one catalog entry is required")
41
+
42
+ for name, entry in catalog.items():
43
+ if not (entry.path / PROJECT_MARKER).is_file():
44
+ raise SystemExit(
45
+ f"Catalog entry '{name}' points at {entry.path}, which is not a Unity project: missing {PROJECT_MARKER}"
46
+ )
47
+ return catalog
53
48
 
54
49
 
55
50
  def visible_directories(root: Path) -> Iterator[Path]:
@@ -60,9 +55,5 @@ def visible_directories(root: Path) -> Iterator[Path]:
60
55
  yield Path(directory)
61
56
 
62
57
 
63
- def unity_project_directories(root: Path) -> list[Path]:
64
- return [directory for directory in visible_directories(root) if (directory / PROJECT_MARKER).is_file()]
65
-
66
-
67
58
  def directories_containing(root: Path, filename: str) -> list[Path]:
68
59
  return [directory for directory in visible_directories(root) if (directory / filename).is_file()]
@@ -5,7 +5,7 @@ from typing import Annotated
5
5
 
6
6
  import typer
7
7
 
8
- from .projects import load_unity_projects
8
+ from .projects import load_catalog
9
9
  from .unity import run_unity_batchmode
10
10
 
11
11
  app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
@@ -13,15 +13,13 @@ app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
13
13
 
14
14
  @app.command()
15
15
  def main(
16
- project: Annotated[
17
- str, typer.Option(help="Unity project name (directory containing ProjectSettings/ProjectVersion.txt)")
18
- ],
16
+ project: Annotated[str, typer.Option(help="Unity project name (catalog key in unity-devkit.json)")],
19
17
  test_platform: Annotated[str, typer.Option(help="Unity test platform (EditMode or PlayMode)")] = "EditMode",
20
18
  results: Annotated[Path, typer.Option(help="Output path for NUnit XML results")] = Path(
21
19
  "artifacts/unity-test-results.xml"
22
20
  ),
23
21
  ) -> None:
24
- projects = load_unity_projects()
22
+ projects = load_catalog()
25
23
  if project not in projects:
26
24
  raise SystemExit(f"Unknown project '{project}'. Valid: {', '.join(projects)}")
27
25
 
unity_devkit/unity.py CHANGED
@@ -6,7 +6,7 @@ from typing import TypedDict
6
6
 
7
7
  from bashrun.bash import CalledProcessError, bash, bash_pipe
8
8
 
9
- from .projects import UnityProject, load_unity_projects
9
+ from .projects import CatalogEntry, load_catalog
10
10
 
11
11
 
12
12
  class PlatformConfig(TypedDict):
@@ -134,8 +134,8 @@ def editor_version(project_path: Path) -> str | None:
134
134
  return None
135
135
 
136
136
 
137
- def resolve_unity_build(project: str, build: str) -> tuple[UnityProject, str, str]:
138
- projects = load_unity_projects()
137
+ def resolve_unity_build(project: str, build: str) -> tuple[CatalogEntry, str, str]:
138
+ projects = load_catalog()
139
139
  if project not in projects:
140
140
  raise SystemExit(f"Unknown project '{project}'. Valid: {', '.join(projects)}")
141
141
 
@@ -143,7 +143,7 @@ def resolve_unity_build(project: str, build: str) -> tuple[UnityProject, str, st
143
143
  valid_builds = project_config.builds or []
144
144
  if not valid_builds:
145
145
  raise SystemExit(
146
- f"Project '{project}' declares no builds — add a unity-build.json with a 'builds' list to {project_config.path}"
146
+ f"Project '{project}' declares no builds — add a 'builds' list to its entry in unity-devkit.json"
147
147
  )
148
148
  if build not in valid_builds:
149
149
  raise SystemExit(f"Unknown build '{build}' for project '{project}'. Valid: {', '.join(valid_builds)}")
@@ -151,7 +151,7 @@ def resolve_unity_build(project: str, build: str) -> tuple[UnityProject, str, st
151
151
  execute_method = (project_config.execute_methods or {}).get(build)
152
152
  if not execute_method:
153
153
  raise SystemExit(
154
- f"No execute method for '{build}' — declare 'execute_methods' in {project_config.path / 'unity-build.json'}"
154
+ f"No execute method for '{build}' — declare it under 'execute_methods' for '{project}' in unity-devkit.json"
155
155
  )
156
156
 
157
157
  if build not in PLATFORM_CONFIGS:
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: unity-devkit
3
- Version: 0.1.13
4
- Summary: Unity project discovery, build, license, and CI tooling
3
+ Version: 0.1.14
4
+ Summary: Unity build, license, and CI tooling
5
5
  License-File: LICENSE
6
6
  License-File: NOTICE
7
7
  Requires-Python: >=3.13
@@ -0,0 +1,18 @@
1
+ unity_devkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ unity_devkit/build_unity.py,sha256=N4cN8r2IpJBAlkKecwJ3TrrkAQTDZTditZMGW3nE_Qo,4612
3
+ unity_devkit/compile_unity.py,sha256=tW0iSmjhjsJE3Nr_JozeJQZFKD1Ht-EXvSJgqXQKdOI,1784
4
+ unity_devkit/install.py,sha256=emtTnc6TeiACIuQkrk66f5zEVVD3dNUI5SIaZFmMgpE,6954
5
+ unity_devkit/license.py,sha256=iiMdos8kMk4p5uYYroIWUzxvusXtcMRdPkIDXsYTC9c,1484
6
+ unity_devkit/license_restore.py,sha256=Tbt2Kt1axszqj4H6K5Fx9_nqRL-dpL5XTVnxnmP4PZw,1077
7
+ unity_devkit/lock_unity.py,sha256=nxZKAYd73wkOc9zWRhzywG-oDXVB88lxX7WwSVNP0Iw,995
8
+ unity_devkit/matrix.py,sha256=VzIiX4jBgu0DK2i5fmzmNsCdI_9M9evQQAZNPj5tafM,1336
9
+ unity_devkit/projects.py,sha256=DQsudfDOL7loCkGmQyleelzrrarwzJyMMbC4zrfoLS4,2156
10
+ unity_devkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ unity_devkit/test_unity.py,sha256=Rpd_sV9gSd4-_TNhSZt_QiF32sHYN2rcHQEdiQIuGjY,1049
12
+ unity_devkit/unity.py,sha256=ebxRLwuFfbh7P4ztWgu5qT6zIYkUESfk8XuFhSt83bk,7012
13
+ unity_devkit-0.1.14.dist-info/METADATA,sha256=eGyhNUjb5m9-6uMsWezRSRWB6ldZlQa7SvBWG3Q2TKw,333
14
+ unity_devkit-0.1.14.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
15
+ unity_devkit-0.1.14.dist-info/entry_points.txt,sha256=RKjFLiz02NSodLcgVDp8pnYX6zEa7VhrH_1GXnnt9d8,381
16
+ unity_devkit-0.1.14.dist-info/licenses/LICENSE,sha256=RFhQPdSOiMTguUX7JSoIuTxA7HVzCbj_p8WU36HjUQQ,10947
17
+ unity_devkit-0.1.14.dist-info/licenses/NOTICE,sha256=jvglZza3GCdN7v4_TLuXUqX9C_uABlwAKUkcIeKwk_8,26
18
+ unity_devkit-0.1.14.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- unity_devkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- unity_devkit/build_unity.py,sha256=2DWbaI8UROzGS_iKa-mXjD7jzNxPNyQvHSa6F_2t-c0,4197
3
- unity_devkit/compile_unity.py,sha256=PgLiHLiaFFXAuFsu2NLjVSJcvs_QFUyiHVp47nFDwdY,1821
4
- unity_devkit/install.py,sha256=k0AXeFt-B1yj-Aq5vgvcol9X1KnNa3x74tQNjV1-XSc,6961
5
- unity_devkit/license.py,sha256=iiMdos8kMk4p5uYYroIWUzxvusXtcMRdPkIDXsYTC9c,1484
6
- unity_devkit/license_restore.py,sha256=Tbt2Kt1axszqj4H6K5Fx9_nqRL-dpL5XTVnxnmP4PZw,1077
7
- unity_devkit/lock_unity.py,sha256=9UNMTj5ekFqqyXpRZ4fSru6SeyTda23jqtJ48rb0HOs,1009
8
- unity_devkit/matrix.py,sha256=fveZkT7O2Q9UD9SW4fL59X6dTfk87RswWLuIs9NwKUM,1343
9
- unity_devkit/projects.py,sha256=4JJimKo6-GB0EhhVddO-DbbYfNYPKRJfMFbw8_ZgpQY,2577
10
- unity_devkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- unity_devkit/test_unity.py,sha256=DaWItN6CqEaPHJRg8fkGTVx9whZt-rLzR1pY9Qhj9DE,1100
12
- unity_devkit/unity.py,sha256=TDIhW9LVMmBmuJF17QgB3XWjBMHrr2sHp5TAw4Eq-Po,7041
13
- unity_devkit-0.1.13.dist-info/METADATA,sha256=IA23T3RKoVzwSwMLMw1wgVlgmqweC6A0aOlJd0hU_Us,352
14
- unity_devkit-0.1.13.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
15
- unity_devkit-0.1.13.dist-info/entry_points.txt,sha256=RKjFLiz02NSodLcgVDp8pnYX6zEa7VhrH_1GXnnt9d8,381
16
- unity_devkit-0.1.13.dist-info/licenses/LICENSE,sha256=RFhQPdSOiMTguUX7JSoIuTxA7HVzCbj_p8WU36HjUQQ,10947
17
- unity_devkit-0.1.13.dist-info/licenses/NOTICE,sha256=jvglZza3GCdN7v4_TLuXUqX9C_uABlwAKUkcIeKwk_8,26
18
- unity_devkit-0.1.13.dist-info/RECORD,,