devlab-fpga 0.1.1__tar.gz → 0.1.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devlab-fpga
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: FPGA development helper for installing OSS CAD Suite and running build/flash flows.
5
5
  Author-email: Mrju10 <name@email.com>
6
6
  License: MIT
@@ -64,14 +64,28 @@ YosysHQ. The installer selects the correct asset for:
64
64
  The default install location is `~/.devlab`. Set `DEVLAB_HOME` to use a
65
65
  different directory.
66
66
 
67
- On Windows, OSS CAD Suite is distributed as an `.exe` installer. Run:
67
+ `devlab build`, `devlab flash`, and `devlab flash --detect` automatically run
68
+ OSS CAD Suite tools with the installed suite environment, including the
69
+ official `bin`, `py3bin`, `VIRTUAL_ENV`, `VERILATOR_ROOT`, and `GHDL_PREFIX`
70
+ settings. You do not need to manually source `environment` for those commands.
71
+
72
+ On Windows, OSS CAD Suite may be distributed as a 7-Zip self-extracting `.exe`
73
+ archive. `devlab install` extracts it automatically into `~/.devlab/toolchains`
74
+ without opening an installer:
68
75
 
69
76
  ```powershell
70
- devlab install --run-installer
77
+ devlab install
71
78
  ```
72
79
 
73
- The compatibility shortcut `devlab --run-installer` also runs the Windows
74
- installer.
80
+ The installed tree keeps the official OSS CAD Suite layout:
81
+
82
+ ```text
83
+ ~/.devlab/toolchains/oss-cad-suite-2026-07-06-windows-x64/
84
+ oss-cad-suite/
85
+ bin/
86
+ environment.bat
87
+ environment.ps1
88
+ ```
75
89
 
76
90
  ## OSS CAD Suite Source
77
91
 
@@ -167,6 +181,7 @@ run detection:
167
181
 
168
182
  ```bash
169
183
  devlab flash --detect
184
+ devlab flash --detect --board tangnano9k
170
185
  ```
171
186
 
172
187
  Persistent flash can also be configured in `devlab.toml`:
@@ -40,14 +40,28 @@ YosysHQ. The installer selects the correct asset for:
40
40
  The default install location is `~/.devlab`. Set `DEVLAB_HOME` to use a
41
41
  different directory.
42
42
 
43
- On Windows, OSS CAD Suite is distributed as an `.exe` installer. Run:
43
+ `devlab build`, `devlab flash`, and `devlab flash --detect` automatically run
44
+ OSS CAD Suite tools with the installed suite environment, including the
45
+ official `bin`, `py3bin`, `VIRTUAL_ENV`, `VERILATOR_ROOT`, and `GHDL_PREFIX`
46
+ settings. You do not need to manually source `environment` for those commands.
47
+
48
+ On Windows, OSS CAD Suite may be distributed as a 7-Zip self-extracting `.exe`
49
+ archive. `devlab install` extracts it automatically into `~/.devlab/toolchains`
50
+ without opening an installer:
44
51
 
45
52
  ```powershell
46
- devlab install --run-installer
53
+ devlab install
47
54
  ```
48
55
 
49
- The compatibility shortcut `devlab --run-installer` also runs the Windows
50
- installer.
56
+ The installed tree keeps the official OSS CAD Suite layout:
57
+
58
+ ```text
59
+ ~/.devlab/toolchains/oss-cad-suite-2026-07-06-windows-x64/
60
+ oss-cad-suite/
61
+ bin/
62
+ environment.bat
63
+ environment.ps1
64
+ ```
51
65
 
52
66
  ## OSS CAD Suite Source
53
67
 
@@ -143,6 +157,7 @@ run detection:
143
157
 
144
158
  ```bash
145
159
  devlab flash --detect
160
+ devlab flash --detect --board tangnano9k
146
161
  ```
147
162
 
148
163
  Persistent flash can also be configured in `devlab.toml`:
@@ -2,4 +2,4 @@
2
2
 
3
3
  __all__ = ["__version__"]
4
4
 
5
- __version__ = "0.1.1"
5
+ __version__ = "0.1.2"
@@ -27,7 +27,7 @@ def build_parser() -> argparse.ArgumentParser:
27
27
  parser.add_argument(
28
28
  "--run-installer",
29
29
  action="store_true",
30
- help="Shortcut for `devlab install --run-installer` on Windows.",
30
+ help="Deprecated compatibility flag. Windows install is automatic.",
31
31
  )
32
32
 
33
33
  commands = parser.add_subparsers(dest="command")
@@ -45,7 +45,7 @@ def build_parser() -> argparse.ArgumentParser:
45
45
  install_parser.add_argument(
46
46
  "--run-installer",
47
47
  action="store_true",
48
- help="On Windows, execute the downloaded OSS CAD Suite installer.",
48
+ help="Deprecated compatibility flag. Windows install is automatic.",
49
49
  )
50
50
  install_parser.set_defaults(func=_install)
51
51
 
@@ -166,8 +166,8 @@ def detect_flash(
166
166
  board: str | None = None,
167
167
  dry_run: bool = False,
168
168
  ) -> None:
169
- config = load_config(config_path)
170
- selected_board = board or config.board
169
+ config = load_config(config_path) if config_path or not board else None
170
+ selected_board = board or (config.board if config else None)
171
171
  if not selected_board:
172
172
  raise DevlabError(
173
173
  "No flash board configured. Add [flash] board = \"...\" "
@@ -9,6 +9,7 @@ import sys
9
9
  import tarfile
10
10
  import tempfile
11
11
  import urllib.request
12
+ import zipfile
12
13
  from dataclasses import dataclass
13
14
  from pathlib import Path
14
15
 
@@ -104,18 +105,34 @@ def archive_path(asset: ToolchainAsset | None = None, home: Path | None = None)
104
105
 
105
106
  def bin_dir(path: Path | None = None) -> Path:
106
107
  path = path or install_path()
107
- return path / "bin"
108
+ return path / "oss-cad-suite" / "bin"
108
109
 
109
110
 
110
111
  def bin_dirs(path: Path | None = None) -> list[Path]:
111
112
  path = path or install_path()
112
- return [path / "bin", path / "oss-cad-suite" / "bin"]
113
+ return [path / "oss-cad-suite" / "bin", path / "bin"]
114
+
115
+
116
+ def _toolchain_root(path: Path) -> Path:
117
+ nested_root = path / "oss-cad-suite"
118
+ if nested_root.exists():
119
+ return nested_root
120
+ return path
113
121
 
114
122
 
115
123
  def env_with_toolchain(path: Path | None = None) -> dict[str, str]:
124
+ path = path or install_path()
125
+ root = _toolchain_root(path)
116
126
  env = os.environ.copy()
117
- binary_dirs = os.pathsep.join(str(candidate) for candidate in bin_dirs(path))
127
+ tool_dirs = [*bin_dirs(path), root / "py3bin"]
128
+ binary_dirs = os.pathsep.join(str(candidate) for candidate in tool_dirs)
118
129
  env["PATH"] = binary_dirs + os.pathsep + env.get("PATH", "")
130
+ env["VIRTUAL_ENV"] = str(root)
131
+ env["VIRTUAL_ENV_PROMPT"] = "OSS CAD Suite"
132
+ env["VERILATOR_ROOT"] = str(root / "share" / "verilator")
133
+ env["GHDL_PREFIX"] = str(root / "lib" / "ghdl")
134
+ env["OPENFPGALOADER_SOJ_DIR"] = str(root / "share" / "openFPGALoader")
135
+ env.pop("PYTHONHOME", None)
119
136
  return env
120
137
 
121
138
 
@@ -190,46 +207,69 @@ def install_oss_cad_suite(
190
207
  archive = download_asset(asset, archive_path(asset, home), force=force)
191
208
 
192
209
  if asset.name.endswith(".exe"):
193
- if not run_windows_installer:
194
- raise DevlabError(
195
- "Windows uses the OSS CAD Suite .exe installer. "
196
- f"The file was downloaded to {archive}. Re-run with "
197
- "`devlab install --run-installer` to execute it."
198
- )
199
- subprocess.check_call([str(archive)])
210
+ _extract_windows_sfx(archive, destination, force=force)
200
211
  if not find_executable("yosys", destination):
201
212
  raise DevlabError(
202
- "The Windows installer finished, but yosys was not found in "
203
- f"{destination}\\bin or {destination}\\oss-cad-suite\\bin. "
204
- "Install or extract OSS CAD Suite into that toolchain directory, "
205
- "then run `devlab doctor`."
213
+ "The Windows OSS CAD Suite archive was extracted, "
214
+ "but yosys was not found in "
215
+ f"{destination}\\oss-cad-suite\\bin or {destination}\\bin. "
216
+ "Check the extracted files, then run `devlab doctor`."
206
217
  )
207
218
  return destination
208
219
 
220
+ if asset.name.endswith(".zip"):
221
+ _extract_zip(archive, destination, force=force)
222
+ return destination
223
+
209
224
  _extract_tarball(archive, destination, force=force)
210
- _mark_executables(bin_dir(destination))
225
+ for binary_dir in bin_dirs(destination):
226
+ _mark_executables(binary_dir)
211
227
  return destination
212
228
 
213
229
 
214
- def _extract_tarball(archive: Path, destination: Path, force: bool) -> None:
230
+ def _move_extracted_tree(source: Path, destination: Path, force: bool) -> None:
215
231
  destination.parent.mkdir(parents=True, exist_ok=True)
216
232
  if destination.exists():
217
- if not force:
233
+ if not force and find_executable("yosys", destination):
218
234
  raise DevlabError(f"Install destination already exists: {destination}")
219
235
  shutil.rmtree(destination)
220
236
 
237
+ destination.mkdir(parents=True)
238
+ for child in source.iterdir():
239
+ shutil.move(str(child), destination / child.name)
240
+
241
+
242
+ def _extract_windows_sfx(archive: Path, destination: Path, force: bool) -> None:
243
+ destination.parent.mkdir(parents=True, exist_ok=True)
244
+ with tempfile.TemporaryDirectory(
245
+ prefix="devlab-oss-cad-suite-", dir=destination.parent
246
+ ) as tmp:
247
+ tmp_path = Path(tmp)
248
+ try:
249
+ subprocess.check_call([str(archive), f"-o{tmp_path}", "-y"], cwd=tmp_path)
250
+ except subprocess.CalledProcessError as exc:
251
+ raise DevlabError(
252
+ f"Could not extract Windows OSS CAD Suite archive: {exc}"
253
+ ) from exc
254
+ _move_extracted_tree(tmp_path, destination, force=force)
255
+
256
+
257
+ def _extract_zip(archive: Path, destination: Path, force: bool) -> None:
258
+ with tempfile.TemporaryDirectory(prefix="devlab-oss-cad-suite-") as tmp:
259
+ tmp_path = Path(tmp)
260
+ with zipfile.ZipFile(archive) as zip_file:
261
+ _safe_extract_zip(zip_file, tmp_path)
262
+
263
+ _move_extracted_tree(tmp_path, destination, force=force)
264
+
265
+
266
+ def _extract_tarball(archive: Path, destination: Path, force: bool) -> None:
221
267
  with tempfile.TemporaryDirectory(prefix="devlab-oss-cad-suite-") as tmp:
222
268
  tmp_path = Path(tmp)
223
269
  with tarfile.open(archive, "r:gz") as tar:
224
270
  _safe_extract(tar, tmp_path)
225
271
 
226
- children = [child for child in tmp_path.iterdir()]
227
- if len(children) == 1 and children[0].is_dir():
228
- shutil.move(str(children[0]), destination)
229
- else:
230
- destination.mkdir(parents=True)
231
- for child in children:
232
- shutil.move(str(child), destination / child.name)
272
+ _move_extracted_tree(tmp_path, destination, force=force)
233
273
 
234
274
 
235
275
  def _safe_extract(tar: tarfile.TarFile, destination: Path) -> None:
@@ -244,6 +284,15 @@ def _safe_extract(tar: tarfile.TarFile, destination: Path) -> None:
244
284
  tar.extractall(destination)
245
285
 
246
286
 
287
+ def _safe_extract_zip(zip_file: zipfile.ZipFile, destination: Path) -> None:
288
+ destination = destination.resolve()
289
+ for member in zip_file.infolist():
290
+ target = (destination / member.filename).resolve()
291
+ if destination != target and destination not in target.parents:
292
+ raise DevlabError(f"Unsafe path in archive: {member.filename}")
293
+ zip_file.extractall(destination)
294
+
295
+
247
296
  def _mark_executables(path: Path) -> None:
248
297
  if not path.exists():
249
298
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devlab-fpga
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: FPGA development helper for installing OSS CAD Suite and running build/flash flows.
5
5
  Author-email: Mrju10 <name@email.com>
6
6
  License: MIT
@@ -64,14 +64,28 @@ YosysHQ. The installer selects the correct asset for:
64
64
  The default install location is `~/.devlab`. Set `DEVLAB_HOME` to use a
65
65
  different directory.
66
66
 
67
- On Windows, OSS CAD Suite is distributed as an `.exe` installer. Run:
67
+ `devlab build`, `devlab flash`, and `devlab flash --detect` automatically run
68
+ OSS CAD Suite tools with the installed suite environment, including the
69
+ official `bin`, `py3bin`, `VIRTUAL_ENV`, `VERILATOR_ROOT`, and `GHDL_PREFIX`
70
+ settings. You do not need to manually source `environment` for those commands.
71
+
72
+ On Windows, OSS CAD Suite may be distributed as a 7-Zip self-extracting `.exe`
73
+ archive. `devlab install` extracts it automatically into `~/.devlab/toolchains`
74
+ without opening an installer:
68
75
 
69
76
  ```powershell
70
- devlab install --run-installer
77
+ devlab install
71
78
  ```
72
79
 
73
- The compatibility shortcut `devlab --run-installer` also runs the Windows
74
- installer.
80
+ The installed tree keeps the official OSS CAD Suite layout:
81
+
82
+ ```text
83
+ ~/.devlab/toolchains/oss-cad-suite-2026-07-06-windows-x64/
84
+ oss-cad-suite/
85
+ bin/
86
+ environment.bat
87
+ environment.ps1
88
+ ```
75
89
 
76
90
  ## OSS CAD Suite Source
77
91
 
@@ -167,6 +181,7 @@ run detection:
167
181
 
168
182
  ```bash
169
183
  devlab flash --detect
184
+ devlab flash --detect --board tangnano9k
170
185
  ```
171
186
 
172
187
  Persistent flash can also be configured in `devlab.toml`:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "devlab-fpga"
7
- version = "0.1.1"
7
+ version = "0.1.3"
8
8
  description = "FPGA development helper for installing OSS CAD Suite and running build/flash flows."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
File without changes
File without changes
File without changes
File without changes