Skip to content

Commit 1fae70f

Browse files
committed
Fix packaged PDK bundle installer imports
1 parent f3e6c93 commit 1fae70f

4 files changed

Lines changed: 49 additions & 8 deletions

File tree

app/data/dependency_manifest.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@
5858
"bundle": {
5959
"enabled": true,
6060
"name": "tt-pdk-sky130a",
61-
"version": "0.2.0-beta.3",
61+
"version": "0.2.0-beta.4",
6262
"install_root": "~/pdk",
6363
"cache_root": "~/.cache/sky130-flow-gui/pdk",
6464
"minimum_free_gb": 10,
65-
"asset_url": "https://github.com/ROMERUU-dev/sky130-flow-gui/releases/download/v0.2.0-beta.3/tt-pdk-sky130a_0.2.0-beta.3.tar.gz",
66-
"asset_filename": "tt-pdk-sky130a_0.2.0-beta.3.tar.gz",
65+
"asset_url": "https://github.com/ROMERUU-dev/sky130-flow-gui/releases/download/v0.2.0-beta.4/tt-pdk-sky130a_0.2.0-beta.4.tar.gz",
66+
"asset_filename": "tt-pdk-sky130a_0.2.0-beta.4.tar.gz",
6767
"asset_sha256": "25acfcdaace6e6b8ca0ca828407ecf1a896a1c0e04560465d2259cda8b9b4c24"
6868
},
6969
"preferred_sources": [
@@ -139,12 +139,12 @@
139139
"bundle": {
140140
"enabled": true,
141141
"name": "tt-pdk-sky130a",
142-
"version": "0.2.0-beta.3",
142+
"version": "0.2.0-beta.4",
143143
"install_root": "~/pdk",
144144
"cache_root": "~/.cache/sky130-flow-gui/pdk",
145145
"minimum_free_gb": 10,
146-
"asset_url": "https://github.com/ROMERUU-dev/sky130-flow-gui/releases/download/v0.2.0-beta.3/tt-pdk-sky130a_0.2.0-beta.3.tar.gz",
147-
"asset_filename": "tt-pdk-sky130a_0.2.0-beta.3.tar.gz",
146+
"asset_url": "https://github.com/ROMERUU-dev/sky130-flow-gui/releases/download/v0.2.0-beta.4/tt-pdk-sky130a_0.2.0-beta.4.tar.gz",
147+
"asset_filename": "tt-pdk-sky130a_0.2.0-beta.4.tar.gz",
148148
"asset_sha256": "25acfcdaace6e6b8ca0ca828407ecf1a896a1c0e04560465d2259cda8b9b4c24"
149149
},
150150
"preferred_sources": [

scripts/install_tt_pdk_bundle.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
import urllib.request
1212
from pathlib import Path
1313

14+
REPO_ROOT = Path(__file__).resolve().parents[1]
15+
if str(REPO_ROOT) not in sys.path:
16+
sys.path.insert(0, str(REPO_ROOT))
17+
1418
from app.core.dependency_manifest import DependencyManifest
1519
from app.core.env_validator import REQUIRED_PDK_SUBDIRS
1620

tests/test_dependency_manifest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def test_loads_default_channel_and_packages(self) -> None:
2424
self.assertEqual(channel.pdk_bundle_install_root, "~/pdk")
2525
self.assertEqual(channel.pdk_bundle_name, "tt-pdk-sky130a")
2626
self.assertTrue(channel.pdk_bundle_enabled)
27-
self.assertEqual(channel.pdk_bundle_version, "0.2.0-beta.3")
28-
self.assertTrue(channel.pdk_bundle_asset_url.endswith("tt-pdk-sky130a_0.2.0-beta.3.tar.gz"))
27+
self.assertEqual(channel.pdk_bundle_version, "0.2.0-beta.4")
28+
self.assertTrue(channel.pdk_bundle_asset_url.endswith("tt-pdk-sky130a_0.2.0-beta.4.tar.gz"))
2929

3030
def test_unknown_channel_raises(self) -> None:
3131
manifest = DependencyManifest()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Regression tests for the bundled PDK installer script."""
2+
3+
from __future__ import annotations
4+
5+
import importlib.util
6+
import os
7+
import sys
8+
import tempfile
9+
import unittest
10+
from pathlib import Path
11+
12+
13+
class InstallTTPdkBundleScriptTest(unittest.TestCase):
14+
def test_script_bootstraps_repo_root_for_app_imports(self) -> None:
15+
script_path = Path(__file__).resolve().parents[1] / "scripts" / "install_tt_pdk_bundle.py"
16+
repo_root = str(script_path.resolve().parents[1])
17+
original_sys_path = list(sys.path)
18+
original_cwd = os.getcwd()
19+
20+
try:
21+
with tempfile.TemporaryDirectory() as tmpdir:
22+
os.chdir(tmpdir)
23+
sys.path[:] = [entry for entry in sys.path if Path(entry or ".").resolve() != Path(repo_root).resolve()]
24+
spec = importlib.util.spec_from_file_location("tt_pdk_bundle_installer_test", script_path)
25+
self.assertIsNotNone(spec)
26+
module = importlib.util.module_from_spec(spec)
27+
assert spec.loader is not None
28+
spec.loader.exec_module(module)
29+
self.assertEqual(Path(module.REPO_ROOT).resolve(), Path(repo_root).resolve())
30+
self.assertEqual(Path(sys.path[0]).resolve(), Path(repo_root).resolve())
31+
finally:
32+
os.chdir(original_cwd)
33+
sys.path[:] = original_sys_path
34+
35+
36+
if __name__ == "__main__":
37+
unittest.main()

0 commit comments

Comments
 (0)