siliconcompiler 0.35.2__py3-none-any.whl → 0.35.3__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.
- siliconcompiler/_metadata.py +1 -1
- siliconcompiler/apps/smake.py +106 -100
- siliconcompiler/flowgraph.py +418 -129
- siliconcompiler/library.py +5 -4
- siliconcompiler/package/https.py +10 -5
- siliconcompiler/project.py +83 -32
- siliconcompiler/remote/client.py +17 -6
- siliconcompiler/scheduler/scheduler.py +204 -55
- siliconcompiler/scheduler/schedulernode.py +63 -70
- siliconcompiler/schema/__init__.py +3 -2
- siliconcompiler/schema/_metadata.py +1 -1
- siliconcompiler/schema/baseschema.py +205 -93
- siliconcompiler/schema/namedschema.py +21 -13
- siliconcompiler/schema/safeschema.py +18 -7
- siliconcompiler/schema_support/dependencyschema.py +4 -3
- siliconcompiler/schema_support/pathschema.py +7 -2
- siliconcompiler/schema_support/record.py +5 -4
- siliconcompiler/targets/asap7_demo.py +4 -1
- siliconcompiler/tool.py +9 -4
- siliconcompiler/tools/builtin/__init__.py +2 -0
- siliconcompiler/tools/builtin/filter.py +8 -1
- siliconcompiler/tools/builtin/importfiles.py +2 -0
- siliconcompiler/tools/klayout/scripts/klayout_show.py +1 -1
- siliconcompiler/tools/klayout/show.py +17 -5
- siliconcompiler/tools/yosys/prepareLib.py +7 -2
- siliconcompiler/tools/yosys/syn_asic.py +20 -2
- siliconcompiler/toolscripts/_tools.json +4 -4
- {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.3.dist-info}/METADATA +2 -2
- {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.3.dist-info}/RECORD +33 -33
- {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.3.dist-info}/WHEEL +0 -0
- {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.3.dist-info}/entry_points.txt +0 -0
- {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.3.dist-info}/licenses/LICENSE +0 -0
- {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.3.dist-info}/top_level.txt +0 -0
siliconcompiler/_metadata.py
CHANGED
siliconcompiler/apps/smake.py
CHANGED
|
@@ -12,8 +12,8 @@ Python without the need for complex boilerplate code.
|
|
|
12
12
|
"""
|
|
13
13
|
import argparse
|
|
14
14
|
import sys
|
|
15
|
+
import tempfile
|
|
15
16
|
|
|
16
|
-
import importlib.util
|
|
17
17
|
import os.path
|
|
18
18
|
|
|
19
19
|
from typing import Union, Tuple, Optional, Dict
|
|
@@ -29,7 +29,7 @@ from siliconcompiler.schema import utils
|
|
|
29
29
|
__default_source_file = "make.py"
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def __process_file(path: Union[Path, str]) -> Tuple[Dict, Optional[str], Optional[str]]:
|
|
32
|
+
def __process_file(path: Union[Path, str], dir: str) -> Tuple[Dict, Optional[str], Optional[str]]:
|
|
33
33
|
"""
|
|
34
34
|
Dynamically loads a Python module and inspects it for runnable targets.
|
|
35
35
|
|
|
@@ -54,16 +54,18 @@ def __process_file(path: Union[Path, str]) -> Tuple[Dict, Optional[str], Optiona
|
|
|
54
54
|
if not os.path.exists(path):
|
|
55
55
|
return {}, None, None
|
|
56
56
|
|
|
57
|
+
mod_name, _ = os.path.splitext(os.path.basename(path))
|
|
58
|
+
|
|
57
59
|
# Dynamically load the specified file as a Python module.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
sys.modules[mod_name] = make
|
|
62
|
-
# Temporarily add CWD to path to allow the makefile to import local modules.
|
|
63
|
-
syspath = sys.path.copy()
|
|
60
|
+
with open(os.path.join(dir, "sc_module_load.py"), "w") as f:
|
|
61
|
+
f.write(f"import {mod_name} as make\n")
|
|
62
|
+
|
|
64
63
|
sys.path.insert(0, os.getcwd())
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
sys.path.insert(0, os.path.dirname(path))
|
|
65
|
+
|
|
66
|
+
# Load newly created file
|
|
67
|
+
import sc_module_load
|
|
68
|
+
make = sc_module_load.make
|
|
67
69
|
|
|
68
70
|
# Inspect the module for public functions to treat as targets.
|
|
69
71
|
args = {}
|
|
@@ -172,100 +174,104 @@ To run a target with arguments, use:
|
|
|
172
174
|
print(f"Error: Unable to change directory to {source_dir}")
|
|
173
175
|
return 1
|
|
174
176
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if module_help:
|
|
180
|
-
description += f"\n\n{module_help}\n\n"
|
|
181
|
-
description += "-----------------------------------------------------------"
|
|
182
|
-
|
|
183
|
-
# --- Set up the main argument parser ---
|
|
184
|
-
parser = argparse.ArgumentParser(
|
|
185
|
-
progname,
|
|
186
|
-
description=description,
|
|
187
|
-
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
188
|
-
|
|
189
|
-
parser.add_argument(
|
|
190
|
-
'--file', '-f',
|
|
191
|
-
metavar='<file>',
|
|
192
|
-
help=f'Use file as makefile, default is {__default_source_file}')
|
|
193
|
-
parser.add_argument(
|
|
194
|
-
'--directory', '-C',
|
|
195
|
-
metavar='<directory>',
|
|
196
|
-
help='Change to directory <directory> before reading the makefile.')
|
|
197
|
-
parser.add_argument(
|
|
198
|
-
'--version', '-v',
|
|
199
|
-
action='version',
|
|
200
|
-
version=f"%(prog)s {version}")
|
|
201
|
-
|
|
202
|
-
# --- Create subparsers for each discovered target ---
|
|
203
|
-
targetparsers = parser.add_subparsers(
|
|
204
|
-
dest='target',
|
|
205
|
-
metavar='<target>',
|
|
206
|
-
help='Target to execute')
|
|
207
|
-
|
|
208
|
-
for arg, info in make_args.items():
|
|
209
|
-
subparse = targetparsers.add_parser(
|
|
210
|
-
arg,
|
|
211
|
-
description=info['full_help'],
|
|
212
|
-
help=info['help'],
|
|
213
|
-
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
177
|
+
with tempfile.TemporaryDirectory(prefix="smake") as dir:
|
|
178
|
+
# Add temp dir to path
|
|
179
|
+
sys.path.insert(0, dir)
|
|
214
180
|
|
|
215
|
-
#
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if "default" not in subarg_info:
|
|
219
|
-
add_args["required"] = True
|
|
220
|
-
else:
|
|
221
|
-
add_args["default"] = subarg_info["default"]
|
|
222
|
-
|
|
223
|
-
# Handle boolean arguments correctly.
|
|
224
|
-
arg_type = subarg_info["type"]
|
|
225
|
-
if arg_type is bool:
|
|
226
|
-
# Use a custom string-to-boolean converter.
|
|
227
|
-
def str2bool(v):
|
|
228
|
-
val = str(v).lower()
|
|
229
|
-
if val in ('y', 'yes', 't', 'true', 'on', '1'):
|
|
230
|
-
return True
|
|
231
|
-
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
|
|
232
|
-
return False
|
|
233
|
-
raise ValueError(f"invalid truth value {val!r}")
|
|
234
|
-
arg_type = str2bool
|
|
235
|
-
|
|
236
|
-
subparse.add_argument(
|
|
237
|
-
f'--{subarg}',
|
|
238
|
-
dest=f'sub_{subarg}',
|
|
239
|
-
metavar=f'<{subarg}>',
|
|
240
|
-
type=arg_type,
|
|
241
|
-
**add_args)
|
|
242
|
-
|
|
243
|
-
# --- Parse arguments and execute the target ---
|
|
244
|
-
args = parser.parse_args()
|
|
245
|
-
target = args.target or default_arg
|
|
246
|
-
|
|
247
|
-
if not target:
|
|
248
|
-
if make_args:
|
|
249
|
-
print("Error: No target specified and no default target found.")
|
|
250
|
-
parser.print_help()
|
|
251
|
-
else:
|
|
252
|
-
print(f"Error: Unable to load makefile '{source_file}'.")
|
|
253
|
-
return 1
|
|
181
|
+
# --- Process the source file to discover targets ---
|
|
182
|
+
make_args, default_arg, module_help = __process_file(source_file, dir) \
|
|
183
|
+
if source_file else ({}, None, None)
|
|
254
184
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
185
|
+
if module_help:
|
|
186
|
+
description += f"\n\n{module_help}\n\n"
|
|
187
|
+
description += "-----------------------------------------------------------"
|
|
258
188
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if arg_key in args_vars and args_vars[arg_key] is not None:
|
|
265
|
-
call_args[arg] = args_vars[arg_key]
|
|
189
|
+
# --- Set up the main argument parser ---
|
|
190
|
+
parser = argparse.ArgumentParser(
|
|
191
|
+
progname,
|
|
192
|
+
description=description,
|
|
193
|
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
266
194
|
|
|
267
|
-
|
|
268
|
-
|
|
195
|
+
parser.add_argument(
|
|
196
|
+
'--file', '-f',
|
|
197
|
+
metavar='<file>',
|
|
198
|
+
help=f'Use file as makefile, default is {__default_source_file}')
|
|
199
|
+
parser.add_argument(
|
|
200
|
+
'--directory', '-C',
|
|
201
|
+
metavar='<directory>',
|
|
202
|
+
help='Change to directory <directory> before reading the makefile.')
|
|
203
|
+
parser.add_argument(
|
|
204
|
+
'--version', '-v',
|
|
205
|
+
action='version',
|
|
206
|
+
version=f"%(prog)s {version}")
|
|
207
|
+
|
|
208
|
+
# --- Create subparsers for each discovered target ---
|
|
209
|
+
targetparsers = parser.add_subparsers(
|
|
210
|
+
dest='target',
|
|
211
|
+
metavar='<target>',
|
|
212
|
+
help='Target to execute')
|
|
213
|
+
|
|
214
|
+
for arg, info in make_args.items():
|
|
215
|
+
subparse = targetparsers.add_parser(
|
|
216
|
+
arg,
|
|
217
|
+
description=info['full_help'],
|
|
218
|
+
help=info['help'],
|
|
219
|
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
220
|
+
|
|
221
|
+
# Add arguments for each parameter of the target function.
|
|
222
|
+
for subarg, subarg_info in info['args'].items():
|
|
223
|
+
add_args = {}
|
|
224
|
+
if "default" not in subarg_info:
|
|
225
|
+
add_args["required"] = True
|
|
226
|
+
else:
|
|
227
|
+
add_args["default"] = subarg_info["default"]
|
|
228
|
+
|
|
229
|
+
# Handle boolean arguments correctly.
|
|
230
|
+
arg_type = subarg_info["type"]
|
|
231
|
+
if arg_type is bool:
|
|
232
|
+
# Use a custom string-to-boolean converter.
|
|
233
|
+
def str2bool(v):
|
|
234
|
+
val = str(v).lower()
|
|
235
|
+
if val in ('y', 'yes', 't', 'true', 'on', '1'):
|
|
236
|
+
return True
|
|
237
|
+
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
|
|
238
|
+
return False
|
|
239
|
+
raise ValueError(f"invalid truth value {val!r}")
|
|
240
|
+
arg_type = str2bool
|
|
241
|
+
|
|
242
|
+
subparse.add_argument(
|
|
243
|
+
f'--{subarg}',
|
|
244
|
+
dest=f'sub_{subarg}',
|
|
245
|
+
metavar=f'<{subarg}>',
|
|
246
|
+
type=arg_type,
|
|
247
|
+
**add_args)
|
|
248
|
+
|
|
249
|
+
# --- Parse arguments and execute the target ---
|
|
250
|
+
args = parser.parse_args()
|
|
251
|
+
target = args.target or default_arg
|
|
252
|
+
|
|
253
|
+
if not target:
|
|
254
|
+
if make_args:
|
|
255
|
+
print("Error: No target specified and no default target found.")
|
|
256
|
+
parser.print_help()
|
|
257
|
+
else:
|
|
258
|
+
print(f"Error: Unable to load makefile '{source_file}'.")
|
|
259
|
+
return 1
|
|
260
|
+
|
|
261
|
+
if target not in make_args:
|
|
262
|
+
print(f"Error: Target '{target}' not found in '{source_file}'.")
|
|
263
|
+
return 1
|
|
264
|
+
|
|
265
|
+
# Prepare arguments to pass to the target function.
|
|
266
|
+
call_args = {}
|
|
267
|
+
args_vars = vars(args)
|
|
268
|
+
for arg in make_args[target]["args"]:
|
|
269
|
+
arg_key = f'sub_{arg}'
|
|
270
|
+
if arg_key in args_vars and args_vars[arg_key] is not None:
|
|
271
|
+
call_args[arg] = args_vars[arg_key]
|
|
272
|
+
|
|
273
|
+
# Call the selected function with its arguments.
|
|
274
|
+
make_args[target]["function"](**call_args)
|
|
269
275
|
|
|
270
276
|
return 0
|
|
271
277
|
|