diff --git a/f4pga/__init__.py b/f4pga/__init__.py index 4b91f25..a99dfe1 100755 --- a/f4pga/__init__.py +++ b/f4pga/__init__.py @@ -28,18 +28,29 @@ from os import environ import json from typing import Iterable from colorama import Fore, Style -from f4pga.sf_common import ResolutionEnv, fatal, scan_modules, set_verbosity_level, \ - sfprint -from f4pga.sf_module import * -from f4pga.sf_cache import SymbiCache -import f4pga.sf_ugly as sf_ugly -from f4pga.sf_flow_config import ProjectFlowConfig, FlowConfig, FlowDefinition, \ - open_project_flow_cfg, verify_platform_name, \ - verify_stage -from f4pga.sf_module_runner import * -from f4pga.sf_module_inspector import get_module_info -from f4pga.sf_stage import Stage -from f4pga.sf_argparse import setup_argparser, get_cli_flow_config + +from f4pga.common import ( + ResolutionEnv, + fatal, + scan_modules, + set_verbosity_level, + sfprint +) +from f4pga.module import * +from f4pga.cache import SymbiCache +import f4pga.ugly as ugly +from f4pga.flow_config import ( + ProjectFlowConfig, + FlowConfig, + FlowDefinition, + open_project_flow_cfg, + verify_platform_name, + verify_stage +) +from f4pga.module_runner import * +from f4pga.module_inspector import get_module_info +from f4pga.stage import Stage +from f4pga.argparser import setup_argparser, get_cli_flow_config SYMBICACHEPATH = '.symbicache' @@ -462,7 +473,7 @@ def setup_resolution_env(): 'shareDir': share_dir_path, 'binDir': os.path.realpath(os.path.join(share_dir_path, '../../bin')) }) - r_env.add_values(sf_ugly.generate_values()) + r_env.add_values(ugly.generate_values()) return r_env def open_project_flow_config(path: str) -> ProjectFlowConfig: diff --git a/f4pga/sf_argparse.py b/f4pga/argparser.py similarity index 99% rename from f4pga/sf_argparse.py rename to f4pga/argparser.py index 1f7ba2e..b9e3b6b 100644 --- a/f4pga/sf_argparse.py +++ b/f4pga/argparser.py @@ -53,7 +53,7 @@ def setup_argparser(): parser.add_argument('-v', '--verbose', action='count', default=0) parser.add_argument('-s', '--silent', action='store_true') - + subparsers = parser.add_subparsers(dest='command') build = subparsers.add_parser('build') _setup_build_parser(build) @@ -74,13 +74,13 @@ def _parse_depval(depvalstr: str): d = { 'name': None, 'stage': None, 'value': None } splitted = list(_unescaped_separated('=', depvalstr)) - + if len(splitted) != 2: raise Exception('Too many components') - + pathstr = splitted[0] valstr = splitted[1] - + path_components = pathstr.split('.') if len(path_components) < 1: raise Exception('Missing value') @@ -89,9 +89,9 @@ def _parse_depval(depvalstr: str): d['stage'] = path_components.pop(0) if len(path_components) > 0: raise Exception('Too many path components') - + d['value'] = _parse_cli_value(valstr) - + return d def _unescaped_matches(regexp: str, s: str, escape_chr='\\'): @@ -99,7 +99,7 @@ def _unescaped_matches(regexp: str, s: str, escape_chr='\\'): Find all occurences of a pattern in a string that contains escape sequences. Yields pairs of starting and ending indices of the pattern. """ - + noescapes = '' # We remove all escape sequnces from a string, so it will match only with @@ -117,7 +117,7 @@ def _unescaped_matches(regexp: str, s: str, escape_chr='\\'): offsets.append(offset) offset += 2 noescapes += noescape - + iter = re.finditer(regexp, noescapes) for m in iter: @@ -164,7 +164,7 @@ def _parse_cli_value(s: str): if len(s) == 0: return '' - + # List if s[0] == '[': if len(s) < 2 or s[len(s)-1] != ']': @@ -191,15 +191,15 @@ def _parse_cli_value(s: str): key = k_v[0] value = _parse_cli_value(k_v[1]) d[key] = value - + return d - + # Bool hack if s == '\\True': return True if s == '\\False': return False - + # Number hack if len(s) >= 3 and s[0:1] == '\\N': return int(s[2:]) @@ -213,9 +213,9 @@ def get_cli_flow_config(args: Namespace, platform: str): 'dependencies': {}, 'values': {}, } - + platform_flow_config = create_defdict() - + def add_entries(arglist: 'list[str]', dict_name: str): for value_def in (_parse_depval(cliv) for cliv in arglist): stage = value_def['stage'] @@ -227,7 +227,7 @@ def get_cli_flow_config(args: Namespace, platform: str): platform_flow_config[stage] = create_defdict() platform_flow_config[stage][dict_name][value_def['name']] = \ value_def['value'] - + add_entries(args.dep, 'dependencies') add_entries(args.val, 'values') diff --git a/f4pga/sf_cache.py b/f4pga/cache.py similarity index 100% rename from f4pga/sf_cache.py rename to f4pga/cache.py diff --git a/f4pga/sf_common.py b/f4pga/common.py similarity index 98% rename from f4pga/sf_common.py rename to f4pga/common.py index efb1e88..6cfd2db 100644 --- a/f4pga/sf_common.py +++ b/f4pga/common.py @@ -31,9 +31,9 @@ def scan_modules(mypath: str): sfbuild_home = mypath sfbuild_home_dirs = os.listdir(sfbuild_home) sfbuild_module_dirs = \ - [dir for dir in sfbuild_home_dirs if re.match('sf_.*_modules$', dir)] + [dir for dir in sfbuild_home_dirs if re.match('.*_modules$', dir)] _sfbuild_module_collection_name_to_path = \ - dict([(re.match('sf_(.*)_modules$', moddir).groups()[0], + dict([(re.match('(.*)_modules$', moddir).groups()[0], os.path.join(sfbuild_home, moddir)) for moddir in sfbuild_module_dirs]) diff --git a/f4pga/sf_common_modules/__init__.py b/f4pga/common_modules/__init__.py similarity index 100% rename from f4pga/sf_common_modules/__init__.py rename to f4pga/common_modules/__init__.py diff --git a/f4pga/sf_common_modules/fasm.py b/f4pga/common_modules/fasm.py similarity index 97% rename from f4pga/sf_common_modules/fasm.py rename to f4pga/common_modules/fasm.py index 7446f95..cfee9b4 100644 --- a/f4pga/sf_common_modules/fasm.py +++ b/f4pga/common_modules/fasm.py @@ -5,8 +5,8 @@ # ----------------------------------------------------------------------------- # import os -from f4pga.sf_common import * -from f4pga.sf_module import * +from f4pga.common import * +from f4pga.module import * # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_common_modules/generic_script_wrapper.py b/f4pga/common_modules/generic_script_wrapper.py similarity index 99% rename from f4pga/sf_common_modules/generic_script_wrapper.py rename to f4pga/common_modules/generic_script_wrapper.py index 632c9ec..d93c6ac 100644 --- a/f4pga/sf_common_modules/generic_script_wrapper.py +++ b/f4pga/common_modules/generic_script_wrapper.py @@ -49,8 +49,8 @@ import os import shutil import re -from f4pga.sf_common import * -from f4pga.sf_module import * +from f4pga.common import * +from f4pga.module import * # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_common_modules/io_rename.py b/f4pga/common_modules/io_rename.py similarity index 97% rename from f4pga/sf_common_modules/io_rename.py rename to f4pga/common_modules/io_rename.py index f14c0be..da1f196 100644 --- a/f4pga/sf_common_modules/io_rename.py +++ b/f4pga/common_modules/io_rename.py @@ -27,9 +27,9 @@ Accepted module parameters: # ----------------------------------------------------------------------------- # -from f4pga.sf_common import * -from f4pga.sf_module import * -from f4pga.sf_module_runner import get_module +from f4pga.common import * +from f4pga.module import * +from f4pga.module_runner import get_module # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_common_modules/mkdirs.py b/f4pga/common_modules/mkdirs.py similarity index 95% rename from f4pga/sf_common_modules/mkdirs.py rename to f4pga/common_modules/mkdirs.py index 065549f..8b3d105 100644 --- a/f4pga/sf_common_modules/mkdirs.py +++ b/f4pga/common_modules/mkdirs.py @@ -12,8 +12,8 @@ lazily create the directories if they become necessary. """ # ----------------------------------------------------------------------------- # import os -from f4pga.sf_common import * -from f4pga.sf_module import * +from f4pga.common import * +from f4pga.module import * # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_common_modules/pack.py b/f4pga/common_modules/pack.py similarity index 97% rename from f4pga/sf_common_modules/pack.py rename to f4pga/common_modules/pack.py index 816cbfd..1aeec69 100644 --- a/f4pga/sf_common_modules/pack.py +++ b/f4pga/common_modules/pack.py @@ -6,8 +6,8 @@ import os import re -from f4pga.sf_common import * -from f4pga.sf_module import * +from f4pga.common import * +from f4pga.module import * # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_common_modules/place.py b/f4pga/common_modules/place.py similarity index 97% rename from f4pga/sf_common_modules/place.py rename to f4pga/common_modules/place.py index 16bc007..1cefd10 100644 --- a/f4pga/sf_common_modules/place.py +++ b/f4pga/common_modules/place.py @@ -5,8 +5,8 @@ # ----------------------------------------------------------------------------- # import os -from f4pga.sf_common import * -from f4pga.sf_module import * +from f4pga.common import * +from f4pga.module import * # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_common_modules/place_constraints.py b/f4pga/common_modules/place_constraints.py similarity index 96% rename from f4pga/sf_common_modules/place_constraints.py rename to f4pga/common_modules/place_constraints.py index b489471..04495f2 100644 --- a/f4pga/sf_common_modules/place_constraints.py +++ b/f4pga/common_modules/place_constraints.py @@ -5,8 +5,8 @@ # ----------------------------------------------------------------------------- # import os -from f4pga.sf_common import * -from f4pga.sf_module import * +from f4pga.common import * +from f4pga.module import * # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_common_modules/route.py b/f4pga/common_modules/route.py similarity index 96% rename from f4pga/sf_common_modules/route.py rename to f4pga/common_modules/route.py index a73dd7b..7ffb8eb 100644 --- a/f4pga/sf_common_modules/route.py +++ b/f4pga/common_modules/route.py @@ -6,8 +6,8 @@ import os import shutil -from f4pga.sf_common import * -from f4pga.sf_module import * +from f4pga.common import * +from f4pga.module import * # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_common_modules/synth.py b/f4pga/common_modules/synth.py similarity index 98% rename from f4pga/sf_common_modules/synth.py rename to f4pga/common_modules/synth.py index b72ff18..48cac76 100755 --- a/f4pga/sf_common_modules/synth.py +++ b/f4pga/common_modules/synth.py @@ -5,8 +5,8 @@ # ----------------------------------------------------------------------------- # import os -from f4pga.sf_common import * -from f4pga.sf_module import * +from f4pga.common import * +from f4pga.module import * # ----------------------------------------------------------------------------- # diff --git a/f4pga/sf_flow_config.py b/f4pga/flow_config.py similarity index 99% rename from f4pga/sf_flow_config.py rename to f4pga/flow_config.py index 5ed5941..43329f0 100644 --- a/f4pga/sf_flow_config.py +++ b/f4pga/flow_config.py @@ -1,8 +1,8 @@ import os import json -from f4pga.sf_common import file_noext, ResolutionEnv, deep -from f4pga.sf_stage import Stage +from f4pga.common import file_noext, ResolutionEnv, deep +from f4pga.stage import Stage from copy import copy _realpath_deep = deep(os.path.realpath) diff --git a/f4pga/sf_module.py b/f4pga/module.py similarity index 99% rename from f4pga/sf_module.py rename to f4pga/module.py index a9a785e..e4a2569 100644 --- a/f4pga/sf_module.py +++ b/f4pga/module.py @@ -2,7 +2,7 @@ import abc from types import SimpleNamespace -from f4pga.sf_common import * +from f4pga.common import * from colorama import Fore, Style class Module: diff --git a/f4pga/sf_module_inspector.py b/f4pga/module_inspector.py similarity index 94% rename from f4pga/sf_module_inspector.py rename to f4pga/module_inspector.py index dc62d6c..b4f1bdd 100644 --- a/f4pga/sf_module_inspector.py +++ b/f4pga/module_inspector.py @@ -1,5 +1,5 @@ -from f4pga.sf_module import Module -from f4pga.sf_common import decompose_depname +from f4pga.module import Module +from f4pga.common import decompose_depname from colorama import Style def _get_if_qualifier(deplist: 'list[str]', qualifier: str): diff --git a/f4pga/sf_module_runner.py b/f4pga/module_runner.py similarity index 96% rename from f4pga/sf_module_runner.py rename to f4pga/module_runner.py index 9dcb665..33acf0e 100644 --- a/f4pga/sf_module_runner.py +++ b/f4pga/module_runner.py @@ -4,8 +4,8 @@ from contextlib import contextmanager import importlib import importlib.util import os -from f4pga.sf_module import Module, ModuleContext, get_mod_metadata -from f4pga.sf_common import ResolutionEnv, deep, sfprint +from f4pga.module import Module, ModuleContext, get_mod_metadata +from f4pga.common import ResolutionEnv, deep, sfprint from colorama import Fore, Style _realpath_deep = deep(os.path.realpath) diff --git a/f4pga/setup.py b/f4pga/setup.py index ef32f45..fac3b53 100644 --- a/f4pga/setup.py +++ b/f4pga/setup.py @@ -78,7 +78,7 @@ setuptools_setup( url="https://github.com/chipsalliance/f4pga", packages=[ "f4pga", - "f4pga.sf_common_modules", + "f4pga.common_modules", "f4pga.wrappers.sh", ], package_dir={"f4pga": "."}, diff --git a/f4pga/sf_stage.py b/f4pga/stage.py similarity index 94% rename from f4pga/sf_stage.py rename to f4pga/stage.py index 5aa9fe6..373087c 100644 --- a/f4pga/sf_stage.py +++ b/f4pga/stage.py @@ -1,6 +1,6 @@ -from f4pga.sf_common import decompose_depname, resolve_modstr -from f4pga.sf_module import Module -from f4pga.sf_module_runner import get_module, module_io +from f4pga.common import decompose_depname, resolve_modstr +from f4pga.module import Module +from f4pga.module_runner import get_module, module_io class StageIO: """ diff --git a/f4pga/sf_ugly.py b/f4pga/ugly.py similarity index 92% rename from f4pga/sf_ugly.py rename to f4pga/ugly.py index 5502137..fdb0ec3 100644 --- a/f4pga/sf_ugly.py +++ b/f4pga/ugly.py @@ -1,7 +1,7 @@ """ The "ugly" module is dedicated for some *ugly* workarounds """ import os -from f4pga.sf_common import sub as common_sub +from f4pga.common import sub as common_sub def noisy_warnings(): """ Emit some noisy warnings """