From 11a40e5484a69c1d06d65172ee151cfd29133b0e Mon Sep 17 00:00:00 2001 From: Olof Kindgren <olof.kindgren@gmail.com> Date: Fri, 1 Dec 2023 13:36:19 +0100 Subject: [PATCH] Remove all __init__.py for PEP0420 compatibility --- doc/source/conf.py | 7 ++++++- fusesoc/__init__.py | 8 -------- fusesoc/capi2/__init__.py | 3 --- fusesoc/capi2/core.py | 2 +- fusesoc/config.py | 2 +- fusesoc/librarymanager.py | 2 +- fusesoc/main.py | 5 ++++- fusesoc/parser/__init__.py | 3 --- fusesoc/provider/__init__.py | 9 --------- fusesoc/provider/provider.py | 6 ++++++ 10 files changed, 19 insertions(+), 28 deletions(-) delete mode 100644 fusesoc/__init__.py delete mode 100644 fusesoc/capi2/__init__.py delete mode 100644 fusesoc/parser/__init__.py delete mode 100644 fusesoc/provider/__init__.py diff --git a/doc/source/conf.py b/doc/source/conf.py index b7b3089b..7eb1108f 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -36,7 +36,12 @@ author = "Olof Kindgren" # The full version, including alpha/beta/rc tags. -release = fusesoc.__version__ +try: + from fusesoc.version import version as __version__ +except ImportError: + __version__ = "unknown" + +release = __version__ # The short X.Y version. v_major, v_minor = LooseVersion(release).version[:2] version = f"{v_major}.{v_minor}" diff --git a/fusesoc/__init__.py b/fusesoc/__init__.py deleted file mode 100644 index c0997d37..00000000 --- a/fusesoc/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright FuseSoC contributors -# Licensed under the 2-Clause BSD License, see LICENSE for details. -# SPDX-License-Identifier: BSD-2-Clause - -try: - from fusesoc.version import version as __version__ -except ImportError: - __version__ = "unknown" diff --git a/fusesoc/capi2/__init__.py b/fusesoc/capi2/__init__.py deleted file mode 100644 index 9458a24a..00000000 --- a/fusesoc/capi2/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright FuseSoC contributors -# Licensed under the 2-Clause BSD License, see LICENSE for details. -# SPDX-License-Identifier: BSD-2-Clause diff --git a/fusesoc/capi2/core.py b/fusesoc/capi2/core.py index c7e0de21..795f161f 100644 --- a/fusesoc/capi2/core.py +++ b/fusesoc/capi2/core.py @@ -13,7 +13,7 @@ from fusesoc import utils from fusesoc.capi2.coredata import CoreData -from fusesoc.provider import get_provider +from fusesoc.provider.provider import get_provider from fusesoc.vlnv import Vlnv logger = logging.getLogger(__name__) diff --git a/fusesoc/config.py b/fusesoc/config.py index 55671f46..40068b47 100644 --- a/fusesoc/config.py +++ b/fusesoc/config.py @@ -263,7 +263,7 @@ def write(self): self._cp.write(conf_file) def add_library(self, library): - from fusesoc.provider import get_provider + from fusesoc.provider.provider import get_provider section_name = "library." + library.name diff --git a/fusesoc/librarymanager.py b/fusesoc/librarymanager.py index c56b181a..bbacceed 100644 --- a/fusesoc/librarymanager.py +++ b/fusesoc/librarymanager.py @@ -5,7 +5,7 @@ import logging import os -from fusesoc.provider import get_provider +from fusesoc.provider.provider import get_provider logger = logging.getLogger(__name__) diff --git a/fusesoc/main.py b/fusesoc/main.py index 89debc63..fdbdd3f2 100644 --- a/fusesoc/main.py +++ b/fusesoc/main.py @@ -11,7 +11,10 @@ import warnings from pathlib import Path -from fusesoc import __version__ +try: + from fusesoc.version import version as __version__ +except ImportError: + __version__ = "unknown" # Check if this is run from a local installation fusesocdir = os.path.abspath( diff --git a/fusesoc/parser/__init__.py b/fusesoc/parser/__init__.py deleted file mode 100644 index 9458a24a..00000000 --- a/fusesoc/parser/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright FuseSoC contributors -# Licensed under the 2-Clause BSD License, see LICENSE for details. -# SPDX-License-Identifier: BSD-2-Clause diff --git a/fusesoc/provider/__init__.py b/fusesoc/provider/__init__.py deleted file mode 100644 index 09813df0..00000000 --- a/fusesoc/provider/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright FuseSoC contributors -# Licensed under the 2-Clause BSD License, see LICENSE for details. -# SPDX-License-Identifier: BSD-2-Clause - -from importlib import import_module - - -def get_provider(name): - return getattr(import_module(f"{__name__}.{name}"), name.capitalize()) diff --git a/fusesoc/provider/provider.py b/fusesoc/provider/provider.py index 865a0fbd..2a1f7498 100644 --- a/fusesoc/provider/provider.py +++ b/fusesoc/provider/provider.py @@ -11,6 +11,12 @@ logger = logging.getLogger(__name__) +from importlib import import_module + + +def get_provider(name): + return getattr(import_module(f"fusesoc.provider.{name}"), name.capitalize()) + class Provider: def __init__(self, config, core_root, files_root):