configs: Use absolute import paths

Use absoluate import paths to be Python 3 compatible. This also
imports absolute_import from __future__ to ensure that Python 2.7
behaves the same way as Python 3.

Change-Id: Ica06ed95814e9cd3e768b3e1785075e36f6e56d0
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/16708
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
diff --git a/configs/common/BPConfig.py b/configs/common/BPConfig.py
index c4e40e7..65e6d65 100644
--- a/configs/common/BPConfig.py
+++ b/configs/common/BPConfig.py
@@ -30,6 +30,7 @@
 # hanle branch predictors instead of memory controllers / CPUs
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 from m5 import fatal
 import m5.objects
diff --git a/configs/common/Benchmarks.py b/configs/common/Benchmarks.py
index f7d1b4d..3cf963b 100644
--- a/configs/common/Benchmarks.py
+++ b/configs/common/Benchmarks.py
@@ -27,8 +27,9 @@
 # Authors: Ali Saidi
 
 from __future__ import print_function
+from __future__ import absolute_import
 
-from SysPaths import script, disk, binary
+from .SysPaths import script, disk, binary
 from os import environ as env
 from m5.defines import buildEnv
 
diff --git a/configs/common/CacheConfig.py b/configs/common/CacheConfig.py
index 368356f..ab9d267 100644
--- a/configs/common/CacheConfig.py
+++ b/configs/common/CacheConfig.py
@@ -42,10 +42,11 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import m5
 from m5.objects import *
-from Caches import *
+from .Caches import *
 
 def config_cache(options, system):
     if options.external_memory_system and (options.caches or options.l2cache):
@@ -57,13 +58,14 @@
 
     if options.cpu_type == "O3_ARM_v7a_3":
         try:
-            from cores.arm.O3_ARM_v7a import *
+            import cores.arm.O3_ARM_v7a as core
         except:
             print("O3_ARM_v7a_3 is unavailable. Did you compile the O3 model?")
             sys.exit(1)
 
         dcache_class, icache_class, l2_cache_class, walk_cache_class = \
-            O3_ARM_v7a_DCache, O3_ARM_v7a_ICache, O3_ARM_v7aL2, \
+            core.O3_ARM_v7a_DCache, core.O3_ARM_v7a_ICache, \
+            core.O3_ARM_v7aL2, \
             O3_ARM_v7aWalkCache
     else:
         dcache_class, icache_class, l2_cache_class, walk_cache_class = \
diff --git a/configs/common/Caches.py b/configs/common/Caches.py
index 926a41d..f8edc8b 100644
--- a/configs/common/Caches.py
+++ b/configs/common/Caches.py
@@ -38,6 +38,9 @@
 #
 # Authors: Lisa Hsu
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.defines import buildEnv
 from m5.objects import *
 
diff --git a/configs/common/CpuConfig.py b/configs/common/CpuConfig.py
index 80e3766..831287d 100644
--- a/configs/common/CpuConfig.py
+++ b/configs/common/CpuConfig.py
@@ -36,6 +36,7 @@
 # Authors: Andreas Sandberg
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 from m5 import fatal
 import m5.objects
@@ -134,7 +135,8 @@
 from importlib import import_module
 for package in [ "generic", buildEnv['TARGET_ISA']]:
     try:
-        package = import_module(".cores." + package, package=__package__)
+        package = import_module(".cores." + package,
+                                package=__name__.rpartition('.')[0])
     except ImportError:
         # No timing models for this ISA
         continue
diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py
index 13c29ef..8b67c85 100644
--- a/configs/common/FSConfig.py
+++ b/configs/common/FSConfig.py
@@ -40,11 +40,12 @@
 # Authors: Kevin Lim
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 from m5.objects import *
-from Benchmarks import *
 from m5.util import *
-from common import PlatformConfig
+from .Benchmarks import *
+from . import PlatformConfig
 
 # Populate to reflect supported os types per target ISA
 os_types = { 'alpha' : [ 'linux' ],
diff --git a/configs/common/GPUTLBConfig.py b/configs/common/GPUTLBConfig.py
index 80aad0b..d93b68e 100644
--- a/configs/common/GPUTLBConfig.py
+++ b/configs/common/GPUTLBConfig.py
@@ -32,6 +32,7 @@
 # Authors: Lisa Hsu
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 # Configure the TLB hierarchy
 # Places which would probably need to be modified if you
diff --git a/configs/common/GPUTLBOptions.py b/configs/common/GPUTLBOptions.py
index 9e370c1..fdcec5d 100644
--- a/configs/common/GPUTLBOptions.py
+++ b/configs/common/GPUTLBOptions.py
@@ -31,6 +31,9 @@
 #
 #  Authors: Myrto Papadopoulou
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 def tlb_options(parser):
 
     #===================================================================
diff --git a/configs/common/HMC.py b/configs/common/HMC.py
index 61e521d..08b217d 100644
--- a/configs/common/HMC.py
+++ b/configs/common/HMC.py
@@ -122,6 +122,9 @@
 #   2 Crossbars are connected to only local vaults. From other 2 crossbar, a
 #   request can be forwarded to any other vault.
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import argparse
 
 import m5
diff --git a/configs/common/MemConfig.py b/configs/common/MemConfig.py
index b6e6663..29c4138 100644
--- a/configs/common/MemConfig.py
+++ b/configs/common/MemConfig.py
@@ -37,12 +37,13 @@
 #          Andreas Hansson
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import m5.objects
 import inspect
 import sys
-import HMC
 from textwrap import  TextWrapper
+from . import HMC
 
 # Dictionary of mapping names of real memory controller models to
 # classes.
diff --git a/configs/common/Options.py b/configs/common/Options.py
index 7b231c7..6d9c9cf 100644
--- a/configs/common/Options.py
+++ b/configs/common/Options.py
@@ -38,15 +38,18 @@
 #
 # Authors: Lisa Hsu
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import m5
 from m5.defines import buildEnv
 from m5.objects import *
-from common.Benchmarks import *
 
-from common import CpuConfig
-from common import BPConfig
-from common import MemConfig
-from common import PlatformConfig
+from .Benchmarks import *
+from . import CpuConfig
+from . import BPConfig
+from . import MemConfig
+from . import PlatformConfig
 
 def _listCpuTypes(option, opt, value, parser):
     CpuConfig.print_cpu_list()
@@ -330,7 +333,7 @@
                       help="Redirect stderr to a file.")
 
 def addFSOptions(parser):
-    from FSConfig import os_types
+    from .FSConfig import os_types
 
     # Simulation options
     parser.add_option("--timesync", action="store_true",
diff --git a/configs/common/PlatformConfig.py b/configs/common/PlatformConfig.py
index ae55d1a..0c2ef36 100644
--- a/configs/common/PlatformConfig.py
+++ b/configs/common/PlatformConfig.py
@@ -39,6 +39,7 @@
 #          Pierre-Yves Peneau
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import m5.objects
 import inspect
diff --git a/configs/common/SimpleOpts.py b/configs/common/SimpleOpts.py
index e2f122e..32e3447 100644
--- a/configs/common/SimpleOpts.py
+++ b/configs/common/SimpleOpts.py
@@ -27,6 +27,9 @@
 #
 # Authors: Jason Power
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 """ Options wrapper for simple gem5 configuration scripts
 
 This module wraps the optparse class so that we can register options
diff --git a/configs/common/Simulation.py b/configs/common/Simulation.py
index 5b1ab01..d1b623d 100644
--- a/configs/common/Simulation.py
+++ b/configs/common/Simulation.py
@@ -40,14 +40,15 @@
 # Authors: Lisa Hsu
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import sys
 from os import getcwd
 from os.path import join as joinpath
 
-from common import CpuConfig
-from common import BPConfig
-from common import MemConfig
+from . import CpuConfig
+from . import BPConfig
+from . import MemConfig
 
 import m5
 from m5.defines import buildEnv
diff --git a/configs/common/SysPaths.py b/configs/common/SysPaths.py
index 17d5fb8..e5d9f83 100644
--- a/configs/common/SysPaths.py
+++ b/configs/common/SysPaths.py
@@ -26,6 +26,8 @@
 #
 # Authors: Ali Saidi
 
+from __future__ import print_function
+from __future__ import absolute_import
 
 from six import string_types
 import os, sys
diff --git a/configs/common/__init__.py b/configs/common/__init__.py
index 1829385..5e72a60 100644
--- a/configs/common/__init__.py
+++ b/configs/common/__init__.py
@@ -34,3 +34,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Authors: Andreas Hansson
+
+from __future__ import print_function
+from __future__ import absolute_import
+
diff --git a/configs/common/cores/__init__.py b/configs/common/cores/__init__.py
index 7a2173e..c61e6d8 100644
--- a/configs/common/cores/__init__.py
+++ b/configs/common/cores/__init__.py
@@ -34,3 +34,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Authors: Andreas Sandberg
+
+from __future__ import print_function
+from __future__ import absolute_import
diff --git a/configs/common/cores/arm/HPI.py b/configs/common/cores/arm/HPI.py
index d105790..01c0884 100644
--- a/configs/common/cores/arm/HPI.py
+++ b/configs/common/cores/arm/HPI.py
@@ -46,6 +46,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 from m5.objects import *
 
diff --git a/configs/common/cores/arm/O3_ARM_v7a.py b/configs/common/cores/arm/O3_ARM_v7a.py
index b0ba128..3a1f9af 100644
--- a/configs/common/cores/arm/O3_ARM_v7a.py
+++ b/configs/common/cores/arm/O3_ARM_v7a.py
@@ -26,6 +26,8 @@
 #
 # Authors: Ron Dreslinski
 
+from __future__ import print_function
+from __future__ import absolute_import
 
 from m5.objects import *
 
diff --git a/configs/common/cores/arm/__init__.py b/configs/common/cores/arm/__init__.py
index 582e6b8..b90b61e 100644
--- a/configs/common/cores/arm/__init__.py
+++ b/configs/common/cores/arm/__init__.py
@@ -35,6 +35,9 @@
 #
 # Authors: Andreas Sandberg
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from pkgutil import iter_modules
 from importlib import import_module
 
@@ -44,7 +47,7 @@
 
 for c in _cpu_modules:
     try:
-        import_module("." + c, package=__package__)
+        import_module("." + c, package=__name__)
     except NameError:
         # Failed to import a CPU model due to a missing
         # dependency. This typically happens if gem5 has been compiled
diff --git a/configs/common/cores/arm/ex5_LITTLE.py b/configs/common/cores/arm/ex5_LITTLE.py
index 1ae0f16..85fdd55 100644
--- a/configs/common/cores/arm/ex5_LITTLE.py
+++ b/configs/common/cores/arm/ex5_LITTLE.py
@@ -29,6 +29,9 @@
 #          Anastasiia Butko
 #          Louisa Bessad
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.objects import *
 
 #-----------------------------------------------------------------------
diff --git a/configs/common/cores/arm/ex5_big.py b/configs/common/cores/arm/ex5_big.py
index 96323f4..445aa32 100644
--- a/configs/common/cores/arm/ex5_big.py
+++ b/configs/common/cores/arm/ex5_big.py
@@ -29,6 +29,9 @@
 #          Anastasiia Butko
 #          Louisa Bessad
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.objects import *
 
 #-----------------------------------------------------------------------
diff --git a/configs/common/cpu2000.py b/configs/common/cpu2000.py
index 8143e45..730a478 100644
--- a/configs/common/cpu2000.py
+++ b/configs/common/cpu2000.py
@@ -27,6 +27,7 @@
 # Authors: Nathan Binkert
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import os
 import sys
diff --git a/configs/dram/lat_mem_rd.py b/configs/dram/lat_mem_rd.py
index a1aa77d..fd92a63 100644
--- a/configs/dram/lat_mem_rd.py
+++ b/configs/dram/lat_mem_rd.py
@@ -36,6 +36,7 @@
 # Authors: Andreas Hansson
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import gzip
 import optparse
diff --git a/configs/dram/low_power_sweep.py b/configs/dram/low_power_sweep.py
index e9714a6..dc8de01 100644
--- a/configs/dram/low_power_sweep.py
+++ b/configs/dram/low_power_sweep.py
@@ -37,6 +37,7 @@
 #          Andreas Hansson
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import argparse
 
@@ -45,8 +46,9 @@
 from m5.util import addToPath
 from m5.stats import periodicStatDump
 
-addToPath(os.getcwd() + '/configs/common')
-import MemConfig
+addToPath('../')
+
+from common import MemConfig
 
 # This script aims at triggering low power state transitions in the DRAM
 # controller. The traffic generator is used in DRAM mode and traffic
diff --git a/configs/dram/sweep.py b/configs/dram/sweep.py
index 10ef748..61b3164 100644
--- a/configs/dram/sweep.py
+++ b/configs/dram/sweep.py
@@ -36,6 +36,7 @@
 # Authors: Andreas Hansson
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import math
 import optparse
diff --git a/configs/example/apu_se.py b/configs/example/apu_se.py
index 146863d..2b2d9c8 100644
--- a/configs/example/apu_se.py
+++ b/configs/example/apu_se.py
@@ -32,6 +32,7 @@
 # Authors: Sooraj Puthoor
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import optparse, os, re
 import math
diff --git a/configs/example/arm/devices.py b/configs/example/arm/devices.py
index 0c08ea2..c7d5a7c 100644
--- a/configs/example/arm/devices.py
+++ b/configs/example/arm/devices.py
@@ -38,6 +38,9 @@
 
 # System components used by the bigLITTLE.py configuration script
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import m5
 from m5.objects import *
 m5.util.addToPath('../../')
diff --git a/configs/example/arm/dist_bigLITTLE.py b/configs/example/arm/dist_bigLITTLE.py
index 5194fc7..5bce3fd 100644
--- a/configs/example/arm/dist_bigLITTLE.py
+++ b/configs/example/arm/dist_bigLITTLE.py
@@ -38,6 +38,9 @@
 # This configuration file extends the example ARM big.LITTLE(tm)
 # configuration to enabe dist-gem5 siulations of big.LITTLE systems.
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import argparse
 import os
 
diff --git a/configs/example/arm/fs_bigLITTLE.py b/configs/example/arm/fs_bigLITTLE.py
index f363872..678b038 100644
--- a/configs/example/arm/fs_bigLITTLE.py
+++ b/configs/example/arm/fs_bigLITTLE.py
@@ -41,6 +41,7 @@
 
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import argparse
 import os
diff --git a/configs/example/arm/fs_power.py b/configs/example/arm/fs_power.py
index 7b92c8d..0de6568 100644
--- a/configs/example/arm/fs_power.py
+++ b/configs/example/arm/fs_power.py
@@ -40,6 +40,7 @@
 # with example power models.
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import argparse
 import os
diff --git a/configs/example/arm/starter_fs.py b/configs/example/arm/starter_fs.py
index 6e53d7b..35ed2af 100644
--- a/configs/example/arm/starter_fs.py
+++ b/configs/example/arm/starter_fs.py
@@ -44,6 +44,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import os
 import m5
diff --git a/configs/example/arm/starter_se.py b/configs/example/arm/starter_se.py
index ef218d9..b76be5f 100644
--- a/configs/example/arm/starter_se.py
+++ b/configs/example/arm/starter_se.py
@@ -44,6 +44,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import os
 import m5
diff --git a/configs/example/etrace_replay.py b/configs/example/etrace_replay.py
index e64871a..588d0a4 100644
--- a/configs/example/etrace_replay.py
+++ b/configs/example/etrace_replay.py
@@ -38,6 +38,7 @@
 # Basic elastic traces replay script that configures a Trace CPU
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import optparse
 
diff --git a/configs/example/fs.py b/configs/example/fs.py
index 70275a0..695744e 100644
--- a/configs/example/fs.py
+++ b/configs/example/fs.py
@@ -42,6 +42,7 @@
 #          Brad Beckmann
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import optparse
 import sys
diff --git a/configs/example/garnet_synth_traffic.py b/configs/example/garnet_synth_traffic.py
index f5b7690..8396ddb 100644
--- a/configs/example/garnet_synth_traffic.py
+++ b/configs/example/garnet_synth_traffic.py
@@ -27,6 +27,7 @@
 # Author: Tushar Krishna
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import m5
 from m5.objects import *
diff --git a/configs/example/hmc_hello.py b/configs/example/hmc_hello.py
index d9a6c0f..a682519 100644
--- a/configs/example/hmc_hello.py
+++ b/configs/example/hmc_hello.py
@@ -30,6 +30,9 @@
 #
 # Author: Éder F. Zulian
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import sys
 import argparse
 
diff --git a/configs/example/hmctest.py b/configs/example/hmctest.py
index 091ed8b..32a8222 100644
--- a/configs/example/hmctest.py
+++ b/configs/example/hmctest.py
@@ -1,4 +1,6 @@
+
 from __future__ import print_function
+from __future__ import absolute_import
 
 import sys
 import argparse
diff --git a/configs/example/memcheck.py b/configs/example/memcheck.py
index 1dae86f..e758b67 100644
--- a/configs/example/memcheck.py
+++ b/configs/example/memcheck.py
@@ -40,6 +40,7 @@
 #          Andreas Hansson
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import optparse
 import random
diff --git a/configs/example/memtest.py b/configs/example/memtest.py
index 81c826a..1bbedfd 100644
--- a/configs/example/memtest.py
+++ b/configs/example/memtest.py
@@ -40,6 +40,7 @@
 #          Andreas Hansson
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import optparse
 import random
diff --git a/configs/example/read_config.py b/configs/example/read_config.py
index 0d60ec4..6ab5a81 100644
--- a/configs/example/read_config.py
+++ b/configs/example/read_config.py
@@ -46,6 +46,7 @@
 # debugging.
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import argparse
 import ConfigParser
diff --git a/configs/example/ruby_direct_test.py b/configs/example/ruby_direct_test.py
index 317fb47..d69df6e 100644
--- a/configs/example/ruby_direct_test.py
+++ b/configs/example/ruby_direct_test.py
@@ -29,6 +29,7 @@
 #          Brad Beckmann
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import m5
 from m5.objects import *
diff --git a/configs/example/ruby_gpu_random_test.py b/configs/example/ruby_gpu_random_test.py
index 1757177..63c4e9c 100644
--- a/configs/example/ruby_gpu_random_test.py
+++ b/configs/example/ruby_gpu_random_test.py
@@ -32,6 +32,7 @@
 # Authors: Brad Beckmann
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import m5
 from m5.objects import *
diff --git a/configs/example/ruby_mem_test.py b/configs/example/ruby_mem_test.py
index 880a150..592ab1c 100644
--- a/configs/example/ruby_mem_test.py
+++ b/configs/example/ruby_mem_test.py
@@ -29,6 +29,7 @@
 #          Brad Beckmann
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import m5
 from m5.objects import *
diff --git a/configs/example/ruby_random_test.py b/configs/example/ruby_random_test.py
index 15d474c..982557e 100644
--- a/configs/example/ruby_random_test.py
+++ b/configs/example/ruby_random_test.py
@@ -29,6 +29,7 @@
 #          Brad Beckmann
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import m5
 from m5.objects import *
diff --git a/configs/example/se.py b/configs/example/se.py
index 59af888..f3630db 100644
--- a/configs/example/se.py
+++ b/configs/example/se.py
@@ -43,6 +43,7 @@
 # "m5 test.py"
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import optparse
 import sys
diff --git a/configs/learning_gem5/part1/caches.py b/configs/learning_gem5/part1/caches.py
index 5183c13..5e87c2b 100644
--- a/configs/learning_gem5/part1/caches.py
+++ b/configs/learning_gem5/part1/caches.py
@@ -33,6 +33,10 @@
 gem5 configuration script. It uses the SimpleOpts wrapper to set up command
 line options from each individual class.
 """
+
+from __future__ import print_function
+from __future__ import absolute_import
+
 import m5
 from m5.objects import Cache
 
diff --git a/configs/learning_gem5/part1/simple.py b/configs/learning_gem5/part1/simple.py
index 5336b44..c624de0 100644
--- a/configs/learning_gem5/part1/simple.py
+++ b/configs/learning_gem5/part1/simple.py
@@ -38,6 +38,8 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
+
 
 # import the m5 (gem5) library created when gem5 is built
 import m5
diff --git a/configs/learning_gem5/part1/two_level.py b/configs/learning_gem5/part1/two_level.py
index 51d51c4..b6f8781 100644
--- a/configs/learning_gem5/part1/two_level.py
+++ b/configs/learning_gem5/part1/two_level.py
@@ -41,6 +41,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 # import the m5 (gem5) library created when gem5 is built
 import m5
diff --git a/configs/learning_gem5/part2/hello_goodbye.py b/configs/learning_gem5/part2/hello_goodbye.py
index e908ae0..e5ee5e7 100644
--- a/configs/learning_gem5/part2/hello_goodbye.py
+++ b/configs/learning_gem5/part2/hello_goodbye.py
@@ -37,6 +37,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 # import the m5 (gem5) library created when gem5 is built
 import m5
diff --git a/configs/learning_gem5/part2/run_simple.py b/configs/learning_gem5/part2/run_simple.py
index 1b729ae..7940c0e 100644
--- a/configs/learning_gem5/part2/run_simple.py
+++ b/configs/learning_gem5/part2/run_simple.py
@@ -36,6 +36,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 # import the m5 (gem5) library created when gem5 is built
 import m5
diff --git a/configs/learning_gem5/part2/simple_cache.py b/configs/learning_gem5/part2/simple_cache.py
index 98078df..c650242 100644
--- a/configs/learning_gem5/part2/simple_cache.py
+++ b/configs/learning_gem5/part2/simple_cache.py
@@ -34,6 +34,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 # import the m5 (gem5) library created when gem5 is built
 import m5
diff --git a/configs/learning_gem5/part2/simple_memobj.py b/configs/learning_gem5/part2/simple_memobj.py
index 066bca0..24c6a24 100644
--- a/configs/learning_gem5/part2/simple_memobj.py
+++ b/configs/learning_gem5/part2/simple_memobj.py
@@ -34,6 +34,7 @@
 """
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 # import the m5 (gem5) library created when gem5 is built
 import m5
diff --git a/configs/learning_gem5/part3/msi_caches.py b/configs/learning_gem5/part3/msi_caches.py
index 7bd24ef..42ec95a 100644
--- a/configs/learning_gem5/part3/msi_caches.py
+++ b/configs/learning_gem5/part3/msi_caches.py
@@ -36,6 +36,9 @@
 
 """
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import math
 
 from m5.defines import buildEnv
diff --git a/configs/learning_gem5/part3/ruby_caches_MI_example.py b/configs/learning_gem5/part3/ruby_caches_MI_example.py
index 104f0df..db39bac 100644
--- a/configs/learning_gem5/part3/ruby_caches_MI_example.py
+++ b/configs/learning_gem5/part3/ruby_caches_MI_example.py
@@ -38,6 +38,9 @@
 
 """
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import math
 
 from m5.defines import buildEnv
diff --git a/configs/learning_gem5/part3/ruby_test.py b/configs/learning_gem5/part3/ruby_test.py
index 692a87e..45c139b 100644
--- a/configs/learning_gem5/part3/ruby_test.py
+++ b/configs/learning_gem5/part3/ruby_test.py
@@ -35,13 +35,14 @@
 
 """
 from __future__ import print_function
+from __future__ import absolute_import
 
 # import the m5 (gem5) library created when gem5 is built
 import m5
 # import all of the SimObjects
 from m5.objects import *
 
-from test_caches import TestCacheSystem
+from .test_caches import TestCacheSystem
 
 # create the system we are going to simulate
 system = System()
diff --git a/configs/learning_gem5/part3/simple_ruby.py b/configs/learning_gem5/part3/simple_ruby.py
index 9b89b78..dda9e6d 100644
--- a/configs/learning_gem5/part3/simple_ruby.py
+++ b/configs/learning_gem5/part3/simple_ruby.py
@@ -38,6 +38,7 @@
 
 """
 from __future__ import print_function
+from __future__ import absolute_import
 
 # import the m5 (gem5) library created when gem5 is built
 import m5
@@ -46,7 +47,7 @@
 
 # You can import ruby_caches_MI_example to use the MI_example protocol instead
 # of the MSI protocol
-from msi_caches import MyCacheSystem
+from .msi_caches import MyCacheSystem
 
 # create the system we are going to simulate
 system = System()
diff --git a/configs/learning_gem5/part3/test_caches.py b/configs/learning_gem5/part3/test_caches.py
index 3721f4a..4b17250 100644
--- a/configs/learning_gem5/part3/test_caches.py
+++ b/configs/learning_gem5/part3/test_caches.py
@@ -36,12 +36,15 @@
 
 """
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.defines import buildEnv
 from m5.util import fatal
 
 from m5.objects import *
 
-from msi_caches import L1Cache, DirController, MyNetwork
+from .msi_caches import L1Cache, DirController, MyNetwork
 
 class TestCacheSystem(RubySystem):
 
diff --git a/configs/network/Network.py b/configs/network/Network.py
index 567e6b0..c1e55bc 100644
--- a/configs/network/Network.py
+++ b/configs/network/Network.py
@@ -26,6 +26,9 @@
 #
 # Authors: Tushar Krishna
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import math
 import m5
 from m5.objects import *
diff --git a/configs/network/__init__.py b/configs/network/__init__.py
index 1829385..32393d1 100644
--- a/configs/network/__init__.py
+++ b/configs/network/__init__.py
@@ -34,3 +34,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Authors: Andreas Hansson
+
+from __future__ import print_function
+from __future__ import absolute_import
diff --git a/configs/ruby/GPU_RfO.py b/configs/ruby/GPU_RfO.py
index afe9614..c9bda0b 100644
--- a/configs/ruby/GPU_RfO.py
+++ b/configs/ruby/GPU_RfO.py
@@ -36,8 +36,8 @@
 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('../')
 
diff --git a/configs/ruby/MI_example.py b/configs/ruby/MI_example.py
index e3395bd..5e3ec58 100644
--- a/configs/ruby/MI_example.py
+++ b/configs/ruby/MI_example.py
@@ -31,8 +31,8 @@
 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
diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py
index 03e836e..ffa5a02 100644
--- a/configs/ruby/Ruby.py
+++ b/configs/ruby/Ruby.py
@@ -81,7 +81,7 @@
                       help="Recycle latency for ruby controller input buffers")
 
     protocol = buildEnv['PROTOCOL']
-    exec "import %s" % protocol
+    exec("from . import %s" % protocol)
     eval("%s.define_options(parser)" % protocol)
     Network.define_options(parser)
 
@@ -144,7 +144,7 @@
         found in configs/topologies/BaseTopology.py
         This is a wrapper for the legacy topologies.
     """
-    exec "import topologies.%s as Topo" % options.topology
+    exec("import topologies.%s as Topo" % options.topology)
     topology = eval("Topo.%s(controllers)" % options.topology)
     return topology
 
@@ -160,7 +160,7 @@
     ruby.network = network
 
     protocol = buildEnv['PROTOCOL']
-    exec "import %s" % protocol
+    exec("from . import %s" % protocol)
     try:
         (cpu_sequencers, dir_cntrls, topology) = \
              eval("%s.create_system(options, full_system, system, dma_ports,\
diff --git a/configs/splash2/cluster.py b/configs/splash2/cluster.py
index 753fb0f..04195cc 100644
--- a/configs/splash2/cluster.py
+++ b/configs/splash2/cluster.py
@@ -31,6 +31,7 @@
 # "m5 test.py"
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import os
 import optparse
diff --git a/configs/splash2/run.py b/configs/splash2/run.py
index f97616a..c742664 100644
--- a/configs/splash2/run.py
+++ b/configs/splash2/run.py
@@ -30,6 +30,7 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import os
 import optparse
diff --git a/configs/topologies/BaseTopology.py b/configs/topologies/BaseTopology.py
index bd8ae25..180d437 100644
--- a/configs/topologies/BaseTopology.py
+++ b/configs/topologies/BaseTopology.py
@@ -26,6 +26,9 @@
 #
 # Authors: Jason Power
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 import m5
 
 class BaseTopology(object):
diff --git a/configs/topologies/Cluster.py b/configs/topologies/Cluster.py
index 2116479..a0e7df6 100644
--- a/configs/topologies/Cluster.py
+++ b/configs/topologies/Cluster.py
@@ -26,8 +26,10 @@
 #
 # Authors: Jason Power
 
+from __future__ import print_function
+from __future__ import absolute_import
 
-from BaseTopology import BaseTopology
+from .BaseTopology import BaseTopology
 
 class Cluster(BaseTopology):
     """ A cluster is a group of nodes which are all one hop from eachother
diff --git a/configs/topologies/Crossbar.py b/configs/topologies/Crossbar.py
index 447b1c5..d545d54 100644
--- a/configs/topologies/Crossbar.py
+++ b/configs/topologies/Crossbar.py
@@ -26,10 +26,13 @@
 #
 # Authors: Steve Reinhardt
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.params import *
 from m5.objects import *
 
-from BaseTopology import SimpleTopology
+from .BaseTopology import SimpleTopology
 
 class Crossbar(SimpleTopology):
     description='Crossbar'
diff --git a/configs/topologies/CrossbarGarnet.py b/configs/topologies/CrossbarGarnet.py
index 64f8001..6322a31 100644
--- a/configs/topologies/CrossbarGarnet.py
+++ b/configs/topologies/CrossbarGarnet.py
@@ -26,10 +26,13 @@
 #
 # Authors: Tushar Krishna
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.params import *
 from m5.objects import *
 
-from BaseTopology import SimpleTopology
+from .BaseTopology import SimpleTopology
 
 class CrossbarGarnet(SimpleTopology):
     description='CrossbarGarnet'
diff --git a/configs/topologies/MeshDirCorners_XY.py b/configs/topologies/MeshDirCorners_XY.py
index 2381624..95cb486 100644
--- a/configs/topologies/MeshDirCorners_XY.py
+++ b/configs/topologies/MeshDirCorners_XY.py
@@ -26,10 +26,13 @@
 #
 # Authors: Brad Beckmann
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.params import *
 from m5.objects import *
 
-from BaseTopology import SimpleTopology
+from .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.
diff --git a/configs/topologies/Mesh_XY.py b/configs/topologies/Mesh_XY.py
index 200d346..79575b3 100644
--- a/configs/topologies/Mesh_XY.py
+++ b/configs/topologies/Mesh_XY.py
@@ -28,10 +28,13 @@
 # Authors: Brad Beckmann
 #          Tushar Krishna
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.params import *
 from m5.objects import *
 
-from BaseTopology import SimpleTopology
+from .BaseTopology import SimpleTopology
 
 # Creates a generic Mesh assuming an equal number of cache
 # and directory controllers.
diff --git a/configs/topologies/Mesh_westfirst.py b/configs/topologies/Mesh_westfirst.py
index f327820..95cdae0 100644
--- a/configs/topologies/Mesh_westfirst.py
+++ b/configs/topologies/Mesh_westfirst.py
@@ -27,11 +27,13 @@
 #
 # Authors: Brad Beckmann
 #          Tushar Krishna
+from __future__ import print_function
+from __future__ import absolute_import
 
 from m5.params import *
 from m5.objects import *
 
-from BaseTopology import SimpleTopology
+from .BaseTopology import SimpleTopology
 
 # Creates a generic Mesh assuming an equal number of cache
 # and directory controllers.
diff --git a/configs/topologies/Pt2Pt.py b/configs/topologies/Pt2Pt.py
index 81d61d7..ce98dc5 100644
--- a/configs/topologies/Pt2Pt.py
+++ b/configs/topologies/Pt2Pt.py
@@ -28,10 +28,13 @@
 # Authors: Brad Beckmann
 #          Tushar Krishna
 
+from __future__ import print_function
+from __future__ import absolute_import
+
 from m5.params import *
 from m5.objects import *
 
-from BaseTopology import SimpleTopology
+from .BaseTopology import SimpleTopology
 
 class Pt2Pt(SimpleTopology):
     description='Pt2Pt'
diff --git a/configs/topologies/__init__.py b/configs/topologies/__init__.py
index 1829385..32393d1 100644
--- a/configs/topologies/__init__.py
+++ b/configs/topologies/__init__.py
@@ -34,3 +34,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Authors: Andreas Hansson
+
+from __future__ import print_function
+from __future__ import absolute_import