configs: Fix relative import in non-package in configs
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Wed, 8 Jan 2020 08:19:42 +0000 (09:19 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Mon, 9 Mar 2020 22:28:00 +0000 (22:28 +0000)
Fix "ValueError: Attempted relative import in non-package"

Python "compilation" fails when running, among other configs:
    ./build/X86/gem5.fast ./configs/example/ruby_random_test.py

The files in the configs/folder_name folder that are not named
"folder_name.py" are not packages, and thus Python does not allow
relative imports in them.

This fixes the bug reported in
    https://gem5.atlassian.net/projects/GEM5/issues/GEM5-188

Change-Id: Ic8befc30e4cff1d6e8d2f5db1b7f9b89b0fc1395
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24163
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
15 files changed:
configs/common/Benchmarks.py
configs/common/CacheConfig.py
configs/common/FSConfig.py
configs/common/MemConfig.py
configs/common/Options.py
configs/common/Simulation.py
configs/ruby/GPU_RfO.py
configs/ruby/MI_example.py
configs/topologies/Cluster.py
configs/topologies/Crossbar.py
configs/topologies/CrossbarGarnet.py
configs/topologies/MeshDirCorners_XY.py
configs/topologies/Mesh_XY.py
configs/topologies/Mesh_westfirst.py
configs/topologies/Pt2Pt.py

index 5d73fc394ba6abb76d88a174974f8b25bf559fc3..4c905e3e16c49bd2a800aaf35340eca507ac196e 100644 (file)
@@ -27,7 +27,7 @@
 from __future__ import print_function
 from __future__ import absolute_import
 
-from .SysPaths import script, disk, binary
+from common.SysPaths import script, disk, binary
 from os import environ as env
 from m5.defines import buildEnv
 
index ff2f0dab77d73225fe57b232bf990080243116ed..91087fb8254674688f3c03650b52467bb76b8efa 100644 (file)
@@ -44,7 +44,7 @@ from __future__ import absolute_import
 
 import m5
 from m5.objects import *
-from .Caches import *
+from common.Caches import *
 from common import ObjectList
 
 def config_cache(options, system):
index c200e61ffc1bde0f48e161f2349f53907e14d0be..691a04a27b3fa9a99a0a0eaa5fd46e08ae1cf848 100644 (file)
@@ -43,8 +43,8 @@ from __future__ import absolute_import
 import m5
 from m5.objects import *
 from m5.util import *
-from .Benchmarks import *
-from . import ObjectList
+from common.Benchmarks import *
+from common import ObjectList
 
 # Populate to reflect supported os types per target ISA
 os_types = { 'mips'  : [ 'linux' ],
index e186ea58de4b96b554c0f0179948977b21ab725a..85494d3f3cb43e080f64e4ee639fc08763cf41e3 100644 (file)
@@ -38,7 +38,7 @@ from __future__ import absolute_import
 
 import m5.objects
 from common import ObjectList
-from . import HMC
+from common import HMC
 
 def create_mem_ctrl(cls, r, i, nbr_mem_ctrls, intlv_bits, intlv_size):
     """
index ef71fd3e14793565773ddfc0b3f29118b23a456a..b2db1ebd267fdd5d0d9c7c91b20a1bbb6f708772 100644 (file)
@@ -43,8 +43,8 @@ import m5
 from m5.defines import buildEnv
 from m5.objects import *
 
-from .Benchmarks import *
-from . import ObjectList
+from common.Benchmarks import *
+from common import ObjectList
 
 vio_9p_help = """\
 Enable the Virtio 9P device and set the path to share. The default 9p path is
@@ -407,7 +407,7 @@ def addSEOptions(parser):
 
 
 def addFSOptions(parser):
-    from .FSConfig import os_types
+    from common.FSConfig import os_types
 
     # Simulation options
     parser.add_option("--timesync", action="store_true",
index eadc8defbb09fd2a2062f3c94d2fc4fb89c58740..73a0ff5413b9ec397fed0893e62d36daa4d6ef6f 100644 (file)
@@ -45,7 +45,7 @@ from os import getcwd
 from os.path import join as joinpath
 
 from common import CpuConfig
-from . import ObjectList
+from common import ObjectList
 
 import m5
 from m5.defines import buildEnv
index 8714a6a2558641ae8aa9c021d374937e54742547..449c169b2886f31e5d24a2fc40357690df64cec8 100644 (file)
@@ -34,8 +34,8 @@ import m5
 from m5.objects import *
 from m5.defines import buildEnv
 from m5.util import addToPath
-from .Ruby import create_topology
-from .Ruby import send_evicts
+from Ruby import create_topology
+from Ruby import send_evicts
 
 addToPath('../')
 
index dcdb974e8848a667637d6004007218184b18ad10..4f17f51b0975fbb56ca0a21f4130f30dc77c0c0d 100644 (file)
@@ -29,8 +29,8 @@ import math
 import m5
 from m5.objects import *
 from m5.defines import buildEnv
-from .Ruby import create_topology, create_directories
-from .Ruby import send_evicts
+from Ruby import create_topology, create_directories
+from Ruby import send_evicts
 
 #
 # Declare caches used by the protocol
index 9d7f41e7685c9a775ca51de59ecac801fc39a02b..76ee50cc5236f28b4d55f384e4043818c65bd291 100644 (file)
@@ -27,7 +27,7 @@
 from __future__ import print_function
 from __future__ import absolute_import
 
-from .BaseTopology import BaseTopology
+from topologies.BaseTopology import BaseTopology
 
 class Cluster(BaseTopology):
     """ A cluster is a group of nodes which are all one hop from eachother
index a2ddf49977f9a5cbbe404abcb60d1b9211763263..8248fdf399e50f94df2f7f973edb65968b1d8bdd 100644 (file)
@@ -30,7 +30,7 @@ from __future__ import absolute_import
 from m5.params import *
 from m5.objects import *
 
-from .BaseTopology import SimpleTopology
+from topologies.BaseTopology import SimpleTopology
 
 class Crossbar(SimpleTopology):
     description='Crossbar'
index 418150c5b8dae42823158d3a5d95a8b72fa117c2..ef58f710a9d6debd47e2edc90ae558cf31a218e0 100644 (file)
@@ -30,7 +30,7 @@ from __future__ import absolute_import
 from m5.params import *
 from m5.objects import *
 
-from .BaseTopology import SimpleTopology
+from topologies.BaseTopology import SimpleTopology
 
 class CrossbarGarnet(SimpleTopology):
     description='CrossbarGarnet'
index 586f3c205c0bc9338eeeac9dfb24a724b21c2000..6d97f8228db7b16592768bf9ba69b7407e4eb0f6 100644 (file)
@@ -32,7 +32,7 @@ from m5.objects import *
 
 from common import FileSystemConfig
 
-from .BaseTopology import SimpleTopology
+from topologies.BaseTopology import SimpleTopology
 
 # Creates a Mesh topology with 4 directories, one at each corner.
 # One L1 (and L2, depending on the protocol) are connected to each router.
index aa16a14b97aaa3162362865bc9e79cb1dbebbf7f..3ae34857ad77167756ac44caeace84c6935240ac 100644 (file)
@@ -33,7 +33,7 @@ from m5.objects import *
 
 from common import FileSystemConfig
 
-from .BaseTopology import SimpleTopology
+from topologies.BaseTopology import SimpleTopology
 
 # Creates a generic Mesh assuming an equal number of cache
 # and directory controllers.
index 57de1135b0b868076cb6a08ff0a3371028844ae3..057fe12408a89c5250f070a9657753719faf9692 100644 (file)
@@ -31,7 +31,7 @@ from __future__ import absolute_import
 from m5.params import *
 from m5.objects import *
 
-from .BaseTopology import SimpleTopology
+from topologies.BaseTopology import SimpleTopology
 
 # Creates a generic Mesh assuming an equal number of cache
 # and directory controllers.
index b1aed2065e4827b96e21aace7938ceaf15794dc4..335ff1518dbcdd0b9412d886a1357814eb707b12 100644 (file)
@@ -31,7 +31,7 @@ from __future__ import absolute_import
 from m5.params import *
 from m5.objects import *
 
-from .BaseTopology import SimpleTopology
+from topologies.BaseTopology import SimpleTopology
 
 class Pt2Pt(SimpleTopology):
     description='Pt2Pt'