-
Notifications
You must be signed in to change notification settings - Fork 810
fix/sdk source install #4043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
fix/sdk source install #4043
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
73c2fd8
fix(packaging): build SDK assets during source installation
TomCC7 599e1a9
Merge branch 'feat/dimup-setup' into fix/sdk-source-install
TomCC7 3d4ce56
Merge branch 'feat/dimup-setup' into fix/sdk-source-install
TomCC7 f01e5a6
Merge branch 'feat/dimup-setup' into fix/sdk-source-install
TomCC7 0d6b0c4
Merge branch 'feat/dimup-setup' into fix/sdk-source-install
TomCC7 e1db3b9
Merge branch 'feat/dimup-setup' into fix/sdk-source-install
TomCC7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Build-time helpers that do not import the DimOS runtime.""" | ||
|
|
||
| from pathlib import Path | ||
| import shutil | ||
| import subprocess | ||
|
|
||
|
|
||
| def ensure_web_dist(root: Path) -> None: | ||
| """Build the web assets for Git installs and source distributions.""" | ||
| for project, artifact in (("sdk", "sdk.js"), ("cockpit", "index.html")): | ||
| source = root / "web" / project | ||
| if (source / "dist" / artifact).is_file(): | ||
| continue | ||
| deno = shutil.which("deno") | ||
| if deno is None: | ||
| raise RuntimeError( | ||
| "Deno is required to build DimOS web assets from source. " | ||
| "Run dimup setup, then retry dependency installation." | ||
| ) | ||
| subprocess.run([deno, "task", "--cwd", str(source), "build"], check=True) | ||
| if not (source / "dist" / artifact).is_file(): | ||
| raise RuntimeError(f"Deno build did not produce {source / 'dist' / artifact}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Read the consumer dependency policy from the selected SDK revision.""" | ||
|
|
||
| from copy import deepcopy | ||
| from typing import Any | ||
|
|
||
| from dimup.process import SetupError | ||
|
|
||
| SDK_URL = "https://github.com/dimensionalOS/dimos.git" | ||
|
|
||
|
|
||
| def consumer_policy(manifest: dict[str, Any]) -> tuple[list[str], dict[str, Any]]: | ||
| extras = sorted(set(manifest["project"]["optional-dependencies"]) - {"dds", "unitree-dds"}) | ||
| if not extras: | ||
| raise SetupError("Selected SDK has no desktop extras.") | ||
| upstream = manifest.get("tool", {}).get("uv", {}) | ||
| policy = { | ||
| key: deepcopy(upstream[key]) | ||
| for key in ( | ||
| "required-version", | ||
| "override-dependencies", | ||
| "constraint-dependencies", | ||
| "exclude-newer", | ||
| "exclude-newer-package", | ||
| "sources", | ||
| "index", | ||
| "extra-build-dependencies", | ||
| "extra-build-variables", | ||
| ) | ||
| if key in upstream | ||
| } | ||
| for name, source in policy.get("sources", {}).items(): | ||
| entries = source if isinstance(source, list) else [source] | ||
| if any("path" in entry or "workspace" in entry for entry in entries): | ||
| raise SetupError(f"Selected SDK source {name!r} requires a checkout-local dependency.") | ||
| return extras, policy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import pytest | ||
|
|
||
| from dimup.process import SetupError | ||
| from dimup.sdk import consumer_policy | ||
|
|
||
|
|
||
| def test_consumer_policy_keeps_sdk_extras_and_sources_without_dev_groups(): | ||
| manifest = { | ||
| "project": { | ||
| "optional-dependencies": { | ||
| "all": [], | ||
| "spot": [], | ||
| "learning": [], | ||
| "dds": [], | ||
| "unitree-dds": [], | ||
| } | ||
| }, | ||
| "dependency-groups": {"docs": ["sphinx"]}, | ||
| "tool": { | ||
| "uv": { | ||
| "sources": {"graspgenx": {"git": "https://example.com/grasp", "rev": "abc"}}, | ||
| "override-dependencies": ["numpy>=2"], | ||
| "default-groups": ["docs"], | ||
| } | ||
| }, | ||
| } | ||
| extras, policy = consumer_policy(manifest) | ||
| assert extras == ["all", "learning", "spot"] | ||
| assert policy == { | ||
| "sources": {"graspgenx": {"git": "https://example.com/grasp", "rev": "abc"}}, | ||
| "override-dependencies": ["numpy>=2"], | ||
| } | ||
| policy["sources"]["graspgenx"]["rev"] = "changed" | ||
| assert manifest["tool"]["uv"]["sources"]["graspgenx"]["rev"] == "abc" | ||
|
|
||
|
|
||
| def test_consumer_policy_rejects_nonportable_sources(): | ||
| with pytest.raises(SetupError, match="checkout-local"): | ||
| consumer_policy( | ||
| { | ||
| "project": {"optional-dependencies": {"all": []}}, | ||
| "tool": {"uv": {"sources": {"local": {"path": "../local"}}}}, | ||
| } | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from pathlib import Path | ||
| import subprocess | ||
|
|
||
| import pytest | ||
|
|
||
| from dimos_build import ensure_web_dist | ||
|
|
||
|
|
||
| def test_bundled_assets_need_no_deno(tmp_path, monkeypatch): | ||
| for project, artifact in (("sdk", "sdk.js"), ("cockpit", "index.html")): | ||
| dist = tmp_path / "web" / project / "dist" | ||
| dist.mkdir(parents=True) | ||
| (dist / artifact).write_text("built") | ||
| monkeypatch.setattr("shutil.which", lambda name: None) | ||
| ensure_web_dist(tmp_path) | ||
|
|
||
|
|
||
| def test_missing_deno_explains_machine_setup(tmp_path, monkeypatch): | ||
| monkeypatch.setattr("shutil.which", lambda name: None) | ||
| with pytest.raises(RuntimeError, match="dimup setup"): | ||
| ensure_web_dist(tmp_path) | ||
|
|
||
|
|
||
| def test_source_build_produces_both_bundles(tmp_path, monkeypatch): | ||
| commands = [] | ||
|
|
||
| def build(command, *, check): | ||
| commands.append(command) | ||
| project = Path(command[3]) | ||
| dist = project / "dist" | ||
| dist.mkdir(parents=True) | ||
| (dist / ("sdk.js" if project.name == "sdk" else "index.html")).write_text("built") | ||
|
|
||
| monkeypatch.setattr("shutil.which", lambda name: "/bin/deno") | ||
| monkeypatch.setattr(subprocess, "run", build) | ||
| ensure_web_dist(tmp_path) | ||
| assert [Path(command[3]).name for command in commands] == ["sdk", "cockpit"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need the web stuff?