siliconcompiler 0.36.2__py3-none-any.whl → 0.36.4__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.
Files changed (120) hide show
  1. siliconcompiler/_metadata.py +1 -1
  2. siliconcompiler/apps/sc_install.py +23 -2
  3. siliconcompiler/apps/sc_issue.py +4 -0
  4. siliconcompiler/flows/dvflow.py +13 -0
  5. siliconcompiler/package/__init__.py +17 -12
  6. siliconcompiler/package/git.py +2 -1
  7. siliconcompiler/project.py +6 -4
  8. siliconcompiler/schema/baseschema.py +18 -6
  9. siliconcompiler/schema/docschema.py +3 -3
  10. siliconcompiler/schema/editableschema.py +1 -1
  11. siliconcompiler/schema/namedschema.py +6 -6
  12. siliconcompiler/schema_support/cmdlineschema.py +8 -5
  13. siliconcompiler/tool.py +4 -2
  14. siliconcompiler/tools/_common/cocotb/__init__.py +0 -0
  15. siliconcompiler/tools/_common/cocotb/cocotb_task.py +286 -0
  16. siliconcompiler/tools/builtin/wait.py +152 -0
  17. siliconcompiler/tools/icarus/cocotb_exec.py +53 -0
  18. siliconcompiler/tools/icarus/compile.py +47 -1
  19. siliconcompiler/tools/klayout/export.py +0 -2
  20. siliconcompiler/tools/klayout/merge.py +95 -0
  21. siliconcompiler/tools/klayout/scripts/klayout_merge.py +79 -0
  22. siliconcompiler/tools/openroad/_apr.py +13 -0
  23. siliconcompiler/tools/openroad/scripts/apr/sc_write_data.tcl +9 -2
  24. siliconcompiler/tools/verilator/cocotb_compile.py +55 -0
  25. siliconcompiler/tools/verilator/cocotb_exec.py +52 -0
  26. siliconcompiler/tools/verilator/compile.py +12 -8
  27. siliconcompiler/tools/vpr/__init__.py +1 -1
  28. siliconcompiler/tools/yosys/scripts/sc_synth_asic.tcl +1 -1
  29. siliconcompiler/tools/yosys/syn_asic.py +3 -3
  30. siliconcompiler/toolscripts/_tools.json +4 -4
  31. siliconcompiler/toolscripts/rhel8/install-icarus.sh +2 -2
  32. siliconcompiler/toolscripts/rhel8/install-magic.sh +1 -1
  33. siliconcompiler/toolscripts/rhel8/install-netgen.sh +1 -1
  34. siliconcompiler/toolscripts/rhel8/install-surelog.sh +1 -1
  35. siliconcompiler/toolscripts/rhel8/install-sv2v.sh +1 -1
  36. siliconcompiler/toolscripts/rhel8/install-verilator.sh +2 -2
  37. siliconcompiler/toolscripts/rhel8/install-xyce.sh +3 -3
  38. siliconcompiler/toolscripts/rhel9/install-ghdl.sh +1 -1
  39. siliconcompiler/toolscripts/rhel9/install-gtkwave.sh +2 -2
  40. siliconcompiler/toolscripts/rhel9/install-icarus.sh +2 -2
  41. siliconcompiler/toolscripts/rhel9/install-magic.sh +1 -1
  42. siliconcompiler/toolscripts/rhel9/install-netgen.sh +1 -1
  43. siliconcompiler/toolscripts/rhel9/install-openroad.sh +1 -1
  44. siliconcompiler/toolscripts/rhel9/install-opensta.sh +5 -5
  45. siliconcompiler/toolscripts/rhel9/install-surelog.sh +1 -1
  46. siliconcompiler/toolscripts/rhel9/install-sv2v.sh +1 -1
  47. siliconcompiler/toolscripts/rhel9/install-verilator.sh +2 -2
  48. siliconcompiler/toolscripts/rhel9/install-vpr.sh +1 -1
  49. siliconcompiler/toolscripts/rhel9/install-wildebeest.sh +1 -1
  50. siliconcompiler/toolscripts/rhel9/install-xyce.sh +3 -3
  51. siliconcompiler/toolscripts/rhel9/install-yosys-moosic.sh +1 -1
  52. siliconcompiler/toolscripts/rhel9/install-yosys-slang.sh +1 -1
  53. siliconcompiler/toolscripts/rhel9/install-yosys.sh +1 -1
  54. siliconcompiler/toolscripts/ubuntu20/install-bambu.sh +1 -1
  55. siliconcompiler/toolscripts/ubuntu20/install-bluespec.sh +1 -1
  56. siliconcompiler/toolscripts/ubuntu20/install-ghdl.sh +1 -1
  57. siliconcompiler/toolscripts/ubuntu20/install-gtkwave.sh +1 -1
  58. siliconcompiler/toolscripts/ubuntu20/install-icarus.sh +1 -1
  59. siliconcompiler/toolscripts/ubuntu20/install-icepack.sh +1 -1
  60. siliconcompiler/toolscripts/ubuntu20/install-magic.sh +1 -1
  61. siliconcompiler/toolscripts/ubuntu20/install-netgen.sh +1 -1
  62. siliconcompiler/toolscripts/ubuntu20/install-openroad.sh +1 -1
  63. siliconcompiler/toolscripts/ubuntu20/install-opensta.sh +5 -5
  64. siliconcompiler/toolscripts/ubuntu20/install-slurm.sh +1 -1
  65. siliconcompiler/toolscripts/ubuntu20/install-surelog.sh +1 -1
  66. siliconcompiler/toolscripts/ubuntu20/install-sv2v.sh +1 -1
  67. siliconcompiler/toolscripts/ubuntu20/install-verilator.sh +1 -1
  68. siliconcompiler/toolscripts/ubuntu20/install-xyce.sh +3 -3
  69. siliconcompiler/toolscripts/ubuntu22/install-bambu.sh +1 -1
  70. siliconcompiler/toolscripts/ubuntu22/install-bluespec.sh +1 -1
  71. siliconcompiler/toolscripts/ubuntu22/install-ghdl.sh +1 -1
  72. siliconcompiler/toolscripts/ubuntu22/install-gtkwave.sh +1 -1
  73. siliconcompiler/toolscripts/ubuntu22/install-icarus.sh +1 -1
  74. siliconcompiler/toolscripts/ubuntu22/install-icepack.sh +1 -1
  75. siliconcompiler/toolscripts/ubuntu22/install-keplerformal.sh +1 -1
  76. siliconcompiler/toolscripts/ubuntu22/install-magic.sh +1 -1
  77. siliconcompiler/toolscripts/ubuntu22/install-netgen.sh +1 -1
  78. siliconcompiler/toolscripts/ubuntu22/install-nextpnr.sh +1 -1
  79. siliconcompiler/toolscripts/ubuntu22/install-openroad.sh +1 -1
  80. siliconcompiler/toolscripts/ubuntu22/install-opensta.sh +5 -5
  81. siliconcompiler/toolscripts/ubuntu22/install-slurm.sh +1 -1
  82. siliconcompiler/toolscripts/ubuntu22/install-surelog.sh +1 -1
  83. siliconcompiler/toolscripts/ubuntu22/install-surfer.sh +1 -1
  84. siliconcompiler/toolscripts/ubuntu22/install-sv2v.sh +1 -1
  85. siliconcompiler/toolscripts/ubuntu22/install-verilator.sh +1 -1
  86. siliconcompiler/toolscripts/ubuntu22/install-vpr.sh +1 -1
  87. siliconcompiler/toolscripts/ubuntu22/install-wildebeest.sh +1 -1
  88. siliconcompiler/toolscripts/ubuntu22/install-xyce.sh +3 -3
  89. siliconcompiler/toolscripts/ubuntu22/install-yosys-moosic.sh +1 -1
  90. siliconcompiler/toolscripts/ubuntu22/install-yosys-slang.sh +1 -1
  91. siliconcompiler/toolscripts/ubuntu22/install-yosys.sh +1 -1
  92. siliconcompiler/toolscripts/ubuntu24/install-bambu.sh +1 -1
  93. siliconcompiler/toolscripts/ubuntu24/install-bluespec.sh +1 -1
  94. siliconcompiler/toolscripts/ubuntu24/install-ghdl.sh +1 -1
  95. siliconcompiler/toolscripts/ubuntu24/install-gtkwave.sh +1 -1
  96. siliconcompiler/toolscripts/ubuntu24/install-icarus.sh +1 -1
  97. siliconcompiler/toolscripts/ubuntu24/install-icepack.sh +1 -1
  98. siliconcompiler/toolscripts/ubuntu24/install-keplerformal.sh +1 -1
  99. siliconcompiler/toolscripts/ubuntu24/install-magic.sh +1 -1
  100. siliconcompiler/toolscripts/ubuntu24/install-netgen.sh +1 -1
  101. siliconcompiler/toolscripts/ubuntu24/install-nextpnr.sh +1 -1
  102. siliconcompiler/toolscripts/ubuntu24/install-openroad.sh +1 -1
  103. siliconcompiler/toolscripts/ubuntu24/install-opensta.sh +5 -5
  104. siliconcompiler/toolscripts/ubuntu24/install-slurm.sh +1 -1
  105. siliconcompiler/toolscripts/ubuntu24/install-surelog.sh +1 -1
  106. siliconcompiler/toolscripts/ubuntu24/install-surfer.sh +1 -1
  107. siliconcompiler/toolscripts/ubuntu24/install-sv2v.sh +1 -1
  108. siliconcompiler/toolscripts/ubuntu24/install-verilator.sh +1 -1
  109. siliconcompiler/toolscripts/ubuntu24/install-vpr.sh +1 -1
  110. siliconcompiler/toolscripts/ubuntu24/install-wildebeest.sh +1 -1
  111. siliconcompiler/toolscripts/ubuntu24/install-xyce.sh +3 -3
  112. siliconcompiler/toolscripts/ubuntu24/install-yosys-moosic.sh +1 -1
  113. siliconcompiler/toolscripts/ubuntu24/install-yosys-slang.sh +1 -1
  114. siliconcompiler/toolscripts/ubuntu24/install-yosys.sh +1 -1
  115. {siliconcompiler-0.36.2.dist-info → siliconcompiler-0.36.4.dist-info}/METADATA +4 -2
  116. {siliconcompiler-0.36.2.dist-info → siliconcompiler-0.36.4.dist-info}/RECORD +120 -112
  117. {siliconcompiler-0.36.2.dist-info → siliconcompiler-0.36.4.dist-info}/WHEEL +1 -1
  118. {siliconcompiler-0.36.2.dist-info → siliconcompiler-0.36.4.dist-info}/entry_points.txt +0 -0
  119. {siliconcompiler-0.36.2.dist-info → siliconcompiler-0.36.4.dist-info}/licenses/LICENSE +0 -0
  120. {siliconcompiler-0.36.2.dist-info → siliconcompiler-0.36.4.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  # Version number following semver standard.
2
- version = '0.36.2'
2
+ version = '0.36.4'
3
3
 
4
4
  # Default server address for remote runs, if unspecified.
5
5
  default_server = 'https://server.siliconcompiler.com'
@@ -92,7 +92,8 @@ class ChoiceOptional(Container):
92
92
  return sorted(items)
93
93
 
94
94
 
95
- def install_tool(tool: str, script: str, build_dir: str, prefix: str) -> bool:
95
+ def install_tool(tool: str, script: str, build_dir: str, prefix: str,
96
+ jobs: Optional[int] = None) -> bool:
96
97
  """
97
98
  Prepare a build directory, configure the environment, and execute an install script for a tool.
98
99
 
@@ -102,6 +103,8 @@ def install_tool(tool: str, script: str, build_dir: str, prefix: str) -> bool:
102
103
  build_dir (str): Base directory where a per-tool build directory will be created.
103
104
  prefix (str): Installation prefix; added to PATH and used to determine whether
104
105
  sudo is required.
106
+ jobs (Optional[int]): Maximum number of parallel jobs to use during build. If None,
107
+ defaults to the number of CPU cores.
105
108
 
106
109
  Returns:
107
110
  bool: `True` if the install script exited with status 0, `False` otherwise.
@@ -117,6 +120,8 @@ def install_tool(tool: str, script: str, build_dir: str, prefix: str) -> bool:
117
120
  env["PATH"] = ":".join(path)
118
121
  env["PREFIX"] = prefix
119
122
  env["USE_SUDO_INSTALL"] = "no"
123
+ if jobs is not None:
124
+ env["NPROC"] = str(jobs)
120
125
  try:
121
126
  os.makedirs(prefix, exist_ok=True)
122
127
  except PermissionError:
@@ -312,6 +317,12 @@ To install tools in a different location:
312
317
  To build tools in a different location:
313
318
  sc-install -build_dir /tmp yosys
314
319
 
320
+ To limit parallel build jobs (useful for memory-constrained systems):
321
+ sc-install yosys -jobs 4
322
+
323
+ To combine options (custom location with limited parallelism):
324
+ sc-install -prefix /opt/tools -jobs 8 openroad yosys
325
+
315
326
  To show the install script:
316
327
  sc-install -show openroad
317
328
 
@@ -359,6 +370,13 @@ Tool groups:
359
370
  help="Directory to build the tool in",
360
371
  metavar="<path>")
361
372
 
373
+ parser.add_argument(
374
+ "-jobs",
375
+ type=int,
376
+ default=None,
377
+ help="Maximum number of parallel build jobs (default: number of CPU cores)",
378
+ metavar="<int>")
379
+
362
380
  parser.add_argument(
363
381
  "-show",
364
382
  action="store_true",
@@ -389,6 +407,9 @@ Tool groups:
389
407
 
390
408
  tools_handled = set()
391
409
  tools_completed = set()
410
+ if args.jobs is not None and args.jobs < 1:
411
+ print("Error: -jobs must be a positive integer", file=sys.stderr)
412
+ return 1
392
413
  for tool in args.tool:
393
414
  if tool in tools_handled:
394
415
  continue
@@ -396,7 +417,7 @@ Tool groups:
396
417
  if args.show:
397
418
  show_tool(tool, tools[tool])
398
419
  else:
399
- if not install_tool(tool, tools[tool], args.build_dir, args.prefix):
420
+ if not install_tool(tool, tools[tool], args.build_dir, args.prefix, args.jobs):
400
421
  notstarted = set(args.tool) - tools_completed - tools_handled
401
422
  __print_summary(tools_completed, tool, notstarted)
402
423
  return 1
@@ -70,6 +70,10 @@ To run a testcase, use:
70
70
  switchlist=switchlist)
71
71
 
72
72
  if not issue.get("cmdarg", "run"):
73
+ if not issue.get("cmdarg", "cfg"):
74
+ issue.logger.error('-cfg must be provided')
75
+ return 1
76
+
73
77
  project: Project = Project.from_manifest(filepath=issue.get("cmdarg", "cfg"))
74
78
 
75
79
  # Determine abs path for build dir
@@ -1,5 +1,8 @@
1
1
  from siliconcompiler.tools.icarus import compile as icarus_compile
2
+ from siliconcompiler.tools.icarus import cocotb_exec as icarus_cocotb
2
3
  from siliconcompiler.tools.verilator import compile as verilator_compile
4
+ from siliconcompiler.tools.verilator import cocotb_compile as verilator_cocotb_compile
5
+ from siliconcompiler.tools.verilator import cocotb_exec as verilator_cocotb
3
6
  from siliconcompiler.tools.execute import exec_input
4
7
  from siliconcompiler.tools.xyce import simulate as xyce_simulate
5
8
  from siliconcompiler.tools.xdm import convert as xdm_convert
@@ -24,7 +27,9 @@ class DVFlow(Flowgraph):
24
27
  Supported tools are:
25
28
 
26
29
  * 'icarus': Compiles and simulates with the Icarus Verilog simulator.
30
+ * 'icarus-cocotb': Compiles with Icarus and runs cocotb Python testbenches.
27
31
  * 'verilator': Compiles and simulates with Verilator.
32
+ * 'verilator-cocotb': Compiles with Verilator and runs cocotb Python testbenches.
28
33
  * 'xyce': Simulates a netlist with the Xyce circuit simulator.
29
34
  * 'xdm-xyce': Converts a design to a Xyce-compatible format and simulates.
30
35
  '''
@@ -50,10 +55,18 @@ class DVFlow(Flowgraph):
50
55
  self.node("compile", icarus_compile.CompileTask())
51
56
  sim_task = exec_input.ExecInputTask()
52
57
  com_name = "compile"
58
+ elif tool == "icarus-cocotb":
59
+ self.node("compile", icarus_compile.CompileTask())
60
+ sim_task = icarus_cocotb.CocotbExecTask()
61
+ com_name = "compile"
53
62
  elif tool == "verilator":
54
63
  self.node("compile", verilator_compile.CompileTask())
55
64
  sim_task = exec_input.ExecInputTask()
56
65
  com_name = "compile"
66
+ elif tool == "verilator-cocotb":
67
+ self.node("compile", verilator_cocotb_compile.CocotbCompileTask())
68
+ sim_task = verilator_cocotb.CocotbExecTask()
69
+ com_name = "compile"
57
70
  elif tool == "xyce":
58
71
  sim_task = xyce_simulate.SimulateTask()
59
72
  com_name = None
@@ -16,6 +16,7 @@ import logging
16
16
  import os
17
17
  import random
18
18
  import re
19
+ import site
19
20
  import shutil
20
21
  import time
21
22
  import threading
@@ -27,7 +28,7 @@ from typing import Optional, List, Dict, Type, Union, TYPE_CHECKING, Final
27
28
 
28
29
  from fasteners import InterProcessLock
29
30
  from importlib.metadata import distributions, distribution
30
- from pathlib import Path
31
+ from pathlib import Path, PureWindowsPath
31
32
  from urllib import parse as url_parse
32
33
 
33
34
  from siliconcompiler.utils import get_plugins, default_cache_dir
@@ -647,21 +648,25 @@ class PythonPathResolver(Resolver):
647
648
  return False
648
649
  dist_name = dist_map[module_name][0]
649
650
 
650
- is_editable = False
651
651
  dist_obj = distribution(dist_name)
652
- if not dist_obj or not dist_obj.files:
652
+ if not dist_obj:
653
653
  return False
654
654
 
655
- for f in dist_obj.files:
656
- if f.name == 'direct_url.json':
657
- info = None
658
- with open(f.locate(), 'r') as fp:
659
- info = json.load(fp)
660
-
661
- if "dir_info" in info:
662
- is_editable = info["dir_info"].get("editable", False)
655
+ direct_url_content = dist_obj.read_text('direct_url.json')
656
+ if direct_url_content:
657
+ direct_url = json.loads(direct_url_content)
658
+ return direct_url.get('dir_info', {}).get('editable', False)
659
+
660
+ dist_loc = dist_obj.locate_file('')
661
+ site_paths = site.getsitepackages()
662
+ user_site_path = site.getusersitepackages()
663
+ if user_site_path:
664
+ site_paths.append(user_site_path)
665
+ if not dist_loc or not site_paths:
666
+ return False
663
667
 
664
- return is_editable
668
+ dist_loc = PureWindowsPath(dist_loc).as_posix()
669
+ return dist_loc not in [PureWindowsPath(site_path).as_posix() for site_path in site_paths]
665
670
 
666
671
  @staticmethod
667
672
  def set_dataroot(root: "PathSchema",
@@ -151,7 +151,8 @@ class GitResolver(RemoteResolver):
151
151
  for submodule in repo.submodules:
152
152
  submodule.update(recursive=True, init=True, force=True)
153
153
  except GitCommandError as e:
154
- if 'Permission denied' in repr(e) or 'could not read Username' in repr(e):
154
+ error_msg = str(e)
155
+ if 'Permission denied' in error_msg or 'could not read Username' in error_msg:
155
156
  if self.urlscheme in ('ssh', 'git+ssh'):
156
157
  raise RuntimeError('Failed to authenticate with Git. Please ensure your SSH '
157
158
  'keys are set up correctly.')
@@ -4,7 +4,7 @@ import uuid
4
4
 
5
5
  import os.path
6
6
 
7
- from typing import Union, List, Tuple, TextIO, Optional, Dict, Set
7
+ from typing import Type, Union, List, Tuple, TextIO, Optional, Dict, Set, TypeVar
8
8
 
9
9
  from siliconcompiler.schema import BaseSchema, NamedSchema, EditableSchema, Parameter, Scope, \
10
10
  __version__ as schema_version, \
@@ -33,6 +33,8 @@ from siliconcompiler.utils.multiprocessing import MPManager
33
33
  from siliconcompiler.utils.paths import jobdir, workdir
34
34
  from siliconcompiler.flows.showflow import ShowFlow
35
35
 
36
+ TProject = TypeVar("TProject", bound="Project")
37
+
36
38
 
37
39
  class Project(PathSchemaBase, CommandLineSchema, BaseSchema):
38
40
  """
@@ -236,7 +238,7 @@ class Project(PathSchemaBase, CommandLineSchema, BaseSchema):
236
238
  return self.get("option", field="schema")
237
239
 
238
240
  @classmethod
239
- def convert(cls, obj: "Project") -> "Project":
241
+ def convert(cls: Type[TProject], obj: "Project") -> TProject:
240
242
  """
241
243
  Converts a project from one type to another (e.g., Project to Sim).
242
244
 
@@ -526,7 +528,7 @@ class Project(PathSchemaBase, CommandLineSchema, BaseSchema):
526
528
  f"{', '.join([f'{step}/{index}' for step, index in breakpoints])}")
527
529
  self.__dashboard.stop()
528
530
 
529
- def run(self) -> "Project":
531
+ def run(self) -> TProject:
530
532
  '''
531
533
  Executes the compilation flow defined in the project's flowgraph.
532
534
 
@@ -1238,7 +1240,7 @@ class Project(PathSchemaBase, CommandLineSchema, BaseSchema):
1238
1240
  return None
1239
1241
 
1240
1242
  # Create copy of project to avoid changing user project
1241
- proj: Project = self.copy()
1243
+ proj = self.copy()
1242
1244
  proj.set_flow(ShowFlow(task))
1243
1245
 
1244
1246
  # Setup options:
@@ -8,6 +8,7 @@ import contextlib
8
8
  import copy
9
9
  import importlib
10
10
  import logging
11
+ import pathlib
11
12
 
12
13
  try:
13
14
  import gzip
@@ -26,12 +27,15 @@ import os.path
26
27
 
27
28
  from enum import Enum, auto
28
29
  from functools import cache
29
- from typing import Dict, Type, Tuple, Union, Set, Callable, List, Optional, TextIO, Iterable, Any
30
+ from typing import Dict, Type, Tuple, TypeVar, Union, Set, Callable, List, Optional, \
31
+ TextIO, Iterable, Any
30
32
 
31
33
  from .parameter import Parameter, NodeValue
32
34
  from .journal import Journal
33
35
  from ._metadata import version
34
36
 
37
+ TSchema = TypeVar('TSchema', bound='BaseSchema')
38
+
35
39
 
36
40
  class LazyLoad(Enum):
37
41
  """
@@ -286,10 +290,10 @@ class BaseSchema:
286
290
 
287
291
  # Manifest methods
288
292
  @classmethod
289
- def from_manifest(cls,
293
+ def from_manifest(cls: Type[TSchema],
290
294
  filepath: Union[None, str] = None,
291
295
  cfg: Union[None, Dict] = None,
292
- lazyload: bool = True) -> "BaseSchema":
296
+ lazyload: bool = True) -> TSchema:
293
297
  '''
294
298
  Create a new schema based on the provided source files.
295
299
 
@@ -382,10 +386,18 @@ class BaseSchema:
382
386
  fout = BaseSchema.__open_file(filepath, is_read=False)
383
387
 
384
388
  try:
389
+ def default(obj: Any) -> Any:
390
+ if isinstance(obj, pathlib.PurePath):
391
+ # Cast everything to a windows path and convert to posix.
392
+ # https://stackoverflow.com/questions/73682260
393
+ return pathlib.PureWindowsPath(obj).as_posix()
394
+ raise TypeError
395
+
385
396
  if _has_orjson:
386
- manifest_str = json.dumps(self.getdict(), option=json.OPT_INDENT_2).decode()
397
+ manifest_str = json.dumps(self.getdict(), option=json.OPT_INDENT_2,
398
+ default=default).decode()
387
399
  else:
388
- manifest_str = json.dumps(self.getdict(), indent=2)
400
+ manifest_str = json.dumps(self.getdict(), indent=2, default=default)
389
401
  fout.write(manifest_str)
390
402
  finally:
391
403
  fout.close()
@@ -849,7 +861,7 @@ class BaseSchema:
849
861
  return manifest
850
862
 
851
863
  # Utility functions
852
- def copy(self, key: Optional[Tuple[str, ...]] = None) -> "BaseSchema":
864
+ def copy(self: TSchema, key: Optional[Tuple[str, ...]] = None) -> TSchema:
853
865
  """
854
866
  Returns a copy of this schema.
855
867
 
@@ -1,6 +1,6 @@
1
- from typing import Union, List
1
+ from typing import Type, Union, List
2
2
 
3
- from .baseschema import BaseSchema
3
+ from .baseschema import BaseSchema, TSchema
4
4
 
5
5
 
6
6
  class DocsSchema(BaseSchema):
@@ -11,7 +11,7 @@ class DocsSchema(BaseSchema):
11
11
  """
12
12
 
13
13
  @classmethod
14
- def make_docs(cls) -> Union[BaseSchema, List[BaseSchema]]:
14
+ def make_docs(cls: Type[TSchema]) -> Union[TSchema, List[TSchema]]:
15
15
  """Generate the documentation representation for this schema.
16
16
 
17
17
  By default, this method returns a standard instance of the class itself.
@@ -163,7 +163,7 @@ class EditableSchema:
163
163
  new_schema._BaseSchema__parent = None
164
164
  return new_schema
165
165
 
166
- def rename(self, name: str):
166
+ def rename(self, name: str) -> None:
167
167
  '''
168
168
  Renames a named schema
169
169
  '''
@@ -4,9 +4,9 @@
4
4
  # SC dependencies outside of its directory, since it may be used by tool drivers
5
5
  # that have isolated Python environments.
6
6
 
7
- from typing import Dict, Tuple, Optional, Set, Union, List
7
+ from typing import Dict, Tuple, Optional, Set, Type, Union, List
8
8
 
9
- from .baseschema import BaseSchema, LazyLoad
9
+ from .baseschema import BaseSchema, LazyLoad, TSchema
10
10
 
11
11
 
12
12
  class NamedSchema(BaseSchema):
@@ -76,11 +76,11 @@ class NamedSchema(BaseSchema):
76
76
  return cfg.get("__meta__", {}).get("name", None)
77
77
 
78
78
  @classmethod
79
- def from_manifest(cls,
79
+ def from_manifest(cls: Type[TSchema],
80
80
  filepath: Union[None, str] = None,
81
81
  cfg: Union[None, Dict] = None,
82
82
  lazyload: bool = True,
83
- name: Optional[str] = None):
83
+ name: Optional[str] = None) -> TSchema:
84
84
  '''
85
85
  Create a new schema based on the provided source files.
86
86
 
@@ -115,8 +115,8 @@ class NamedSchema(BaseSchema):
115
115
 
116
116
  return super()._from_dict(manifest, keypath, version=version, lazyload=lazyload)
117
117
 
118
- def copy(self, key: Optional[Tuple[str, ...]] = None) -> "NamedSchema":
119
- copy: NamedSchema = super().copy(key=key)
118
+ def copy(self: TSchema, key: Optional[Tuple[str, ...]] = None) -> TSchema:
119
+ copy = super().copy(key=key)
120
120
 
121
121
  if key and key[-1] != "default":
122
122
  copy.__name = key[-1]
@@ -4,12 +4,14 @@ import sys
4
4
 
5
5
  import os.path
6
6
 
7
- from typing import Set, List, Optional, Union
7
+ from typing import Set, List, Optional, Type, Union, TypeVar
8
8
 
9
9
  from siliconcompiler.schema import BaseSchema, EditableSchema, Parameter, Scope, PerNode
10
10
  from siliconcompiler.schema.utils import trim
11
11
  from siliconcompiler import _metadata
12
12
 
13
+ TCmdSchema = TypeVar("TCmdSchema", bound="CommandLineSchema")
14
+
13
15
 
14
16
  class CommandLineSchema(BaseSchema):
15
17
  '''
@@ -68,14 +70,14 @@ class CommandLineSchema(BaseSchema):
68
70
  EditableSchema(self).insert("cmdarg", name, Parameter(type, **kwargs))
69
71
 
70
72
  @classmethod
71
- def create_cmdline(cls,
73
+ def create_cmdline(cls: Type[TCmdSchema],
72
74
  progname: Optional[str] = None,
73
75
  description: Optional[str] = None,
74
76
  switchlist: Optional[Union[List[str], Set[str]]] = None,
75
77
  version: Optional[str] = None,
76
78
  print_banner: bool = True,
77
79
  use_cfg: bool = False,
78
- use_sources: bool = True) -> BaseSchema:
80
+ use_sources: bool = True) -> TCmdSchema:
79
81
  """
80
82
  Creates an SC command line interface.
81
83
 
@@ -141,7 +143,7 @@ class CommandLineSchema(BaseSchema):
141
143
  # Grab config from argv
142
144
  try:
143
145
  cfg_index = sys.argv.index("-cfg", 1)
144
- if cfg_index < len(sys.argv):
146
+ if cfg_index + 1 < len(sys.argv):
145
147
  cfg_file = sys.argv[cfg_index + 1]
146
148
  except ValueError:
147
149
  pass
@@ -159,7 +161,8 @@ class CommandLineSchema(BaseSchema):
159
161
  # Add commandline key for input files
160
162
  if not isinstance(schema, CommandLineSchema):
161
163
  raise TypeError("Schema is not a commandline class")
162
- if "cmdarg" not in schema.getkeys() or "file" not in schema.getkeys("cmdarg"):
164
+
165
+ if not schema.valid("cmdarg", "input"):
163
166
  schema._add_commandline_argument("input", "[file]", "input files", ...)
164
167
  keyschema._add_commandline_argument("input", "[file]", "input files", ...)
165
168
 
siliconcompiler/tool.py CHANGED
@@ -53,7 +53,8 @@ if TYPE_CHECKING:
53
53
  from siliconcompiler.scheduler import SchedulerNode
54
54
  from siliconcompiler import Project
55
55
 
56
- TTask = TypeVar('TTask')
56
+ TTask = TypeVar('TTask', bound='Task')
57
+ TShowTask = TypeVar('TShowTask', bound='ShowTask')
57
58
 
58
59
 
59
60
  class TaskError(Exception):
@@ -2177,7 +2178,8 @@ class ShowTask(Task):
2177
2178
  cls.register_task(c)
2178
2179
 
2179
2180
  @classmethod
2180
- def get_task(cls, ext: Optional[str]) -> Union[Optional["ShowTask"], Set[Type["ShowTask"]]]:
2181
+ def get_task(cls: Type[TShowTask], ext: Optional[str]) -> \
2182
+ Union[Optional[TShowTask], Set[Type[TShowTask]]]:
2181
2183
  """
2182
2184
  Retrieves a suitable show task instance for a given file extension.
2183
2185
 
File without changes