From b4eefa6c33ca6a8047da7cafc777d4caa254a34e Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 3 Sep 2019 15:23:40 +0200 Subject: [PATCH] import: allow importing directly from litex_boards.platforms or litex_boards.targets --- litex_boards/community/platforms/__init__.py | 6 ------ litex_boards/community/targets/__init__.py | 5 ----- litex_boards/official/platforms/__init__.py | 12 ------------ litex_boards/official/targets/__init__.py | 10 ---------- litex_boards/partner/platforms/__init__.py | 10 ---------- litex_boards/partner/targets/__init__.py | 6 ------ litex_boards/platforms.py | 18 +++++++++++++++--- litex_boards/targets.py | 18 +++++++++++++++--- 8 files changed, 30 insertions(+), 55 deletions(-) diff --git a/litex_boards/community/platforms/__init__.py b/litex_boards/community/platforms/__init__.py index dd11bf3..e69de29 100644 --- a/litex_boards/community/platforms/__init__.py +++ b/litex_boards/community/platforms/__init__.py @@ -1,6 +0,0 @@ -from litex_boards.community.platforms import ac701 -from litex_boards.community.platforms import de10lite -from litex_boards.community.platforms import de1soc -from litex_boards.community.platforms import de2_115 -from litex_boards.community.platforms import ecp5_evn -from litex_boards.community.platforms import sp605 diff --git a/litex_boards/community/targets/__init__.py b/litex_boards/community/targets/__init__.py index a1fcf29..e69de29 100644 --- a/litex_boards/community/targets/__init__.py +++ b/litex_boards/community/targets/__init__.py @@ -1,5 +0,0 @@ -#from litex_boards.community.targets import ac701 -#from litex_boards.community.targets import de10lite -#from litex_boards.community.targets import de1soc -#from litex_boards.community.targets import de2_115 -#from litex_boards.community.targets import ecp5_evn diff --git a/litex_boards/official/platforms/__init__.py b/litex_boards/official/platforms/__init__.py index 7661cf1..e69de29 100644 --- a/litex_boards/official/platforms/__init__.py +++ b/litex_boards/official/platforms/__init__.py @@ -1,12 +0,0 @@ -from litex_boards.official.platforms import arty -from litex_boards.official.platforms import avalanche -from litex_boards.official.platforms import de0nano -from litex_boards.official.platforms import genesys2 -from litex_boards.official.platforms import kc705 -from litex_boards.official.platforms import kcu105 -from litex_boards.official.platforms import machxo3 -from litex_boards.official.platforms import minispartan6 -from litex_boards.official.platforms import nexys4ddr -from litex_boards.official.platforms import nexys_video -from litex_boards.official.platforms import versa_ecp3 -from litex_boards.official.platforms import versa_ecp5 diff --git a/litex_boards/official/targets/__init__.py b/litex_boards/official/targets/__init__.py index 985dbcd..e69de29 100644 --- a/litex_boards/official/targets/__init__.py +++ b/litex_boards/official/targets/__init__.py @@ -1,10 +0,0 @@ -#from litex_boards.official.targets import arty -#from litex_boards.official.targets import de0nano -#from litex_boards.official.targets import genesys2 -#from litex_boards.official.targets import kc705 -#from litex_boards.official.targets import kcu105 -#from litex_boards.official.targets import minispartan6 -#from litex_boards.official.targets import nexys4ddr -#from litex_boards.official.targets import nexys_video -#from litex_boards.official.targets import simple -#from litex_boards.official.targets import versa_ecp5 diff --git a/litex_boards/partner/platforms/__init__.py b/litex_boards/partner/platforms/__init__.py index d5aef64..e69de29 100644 --- a/litex_boards/partner/platforms/__init__.py +++ b/litex_boards/partner/platforms/__init__.py @@ -1,10 +0,0 @@ -from litex_boards.partner.platforms import aller -from litex_boards.partner.platforms import fomu_evt -from litex_boards.partner.platforms import fomu_hacker -from litex_boards.partner.platforms import fomu_pvt -from litex_boards.partner.platforms import nereid -from litex_boards.partner.platforms import netv2 -from litex_boards.partner.platforms import tagus -from litex_boards.partner.platforms import tinyfpga_bx -from litex_boards.partner.platforms import trellisboard -from litex_boards.partner.platforms import ulx3s diff --git a/litex_boards/partner/targets/__init__.py b/litex_boards/partner/targets/__init__.py index e0b9ba5..e69de29 100644 --- a/litex_boards/partner/targets/__init__.py +++ b/litex_boards/partner/targets/__init__.py @@ -1,6 +0,0 @@ -#from litex_boards.partner.targets import aller -#from litex_boards.partner.targets import nereid -#from litex_boards.partner.targets import netv2 -#from litex_boards.partner.targets import tagus -#from litex_boards.partner.targets import trellisboard -#from litex_boards.partner.targets import ulx3s diff --git a/litex_boards/platforms.py b/litex_boards/platforms.py index 363554b..ffa4b03 100644 --- a/litex_boards/platforms.py +++ b/litex_boards/platforms.py @@ -1,3 +1,15 @@ -from litex_boards.official.platforms import * -from litex_boards.partner.platforms import * -from litex_boards.community.platforms import * +import sys +import importlib + +class Platforms: + def __getattr__(self, name): + if name == "__path__": + return [] + for support in ["official", "partner", "community"]: + try: + return importlib.import_module("litex_boards." + support + ".platforms." + name) + except: + pass + raise ModuleNotFoundError + +sys.modules[__name__] = Platforms() diff --git a/litex_boards/targets.py b/litex_boards/targets.py index 9f35cde..8ae7041 100644 --- a/litex_boards/targets.py +++ b/litex_boards/targets.py @@ -1,3 +1,15 @@ -from litex_boards.official.targets import * -from litex_boards.partner.targets import * -from litex_boards.community.targets import * +import sys +import importlib + +class Targets: + def __getattr__(self, name): + if name == "__path__": + return [] + for support in ["official", "partner", "community"]: + try: + return importlib.import_module("litex_boards." + support + ".targets." + name) + except: + pass + raise ModuleNotFoundError + +sys.modules[__name__] = Targets()