From: Andreas Sandberg Date: Thu, 21 Jan 2021 17:18:21 +0000 (+0000) Subject: scons: Remove Python 2.7 compatibility code X-Git-Tag: develop-gem5-snapshot~255 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d06a193c13320486f365118ee9f9f7ee79748b5d;p=gem5.git scons: Remove Python 2.7 compatibility code Remove the dependency on six and most 'import x from __future__'. A few instances of imports from the future have been left in place to ensure that Python 2.7 users still get an error message when invoking scons. Change-Id: I366275a6040f0084e91198b5b5c2a648bffbf2d2 Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39585 Tested-by: kokoro Reviewed-by: Gabe Black Maintainer: Gabe Black --- diff --git a/SConstruct b/SConstruct index b5505ff53..4cf2f1059 100755 --- a/SConstruct +++ b/SConstruct @@ -75,8 +75,6 @@ # ################################################### -from __future__ import print_function - # Global Python includes import atexit import itertools diff --git a/ext/libelf/SConscript b/ext/libelf/SConscript index 3bf5b3063..e2cc84727 100644 --- a/ext/libelf/SConscript +++ b/ext/libelf/SConscript @@ -28,8 +28,6 @@ # # Authors: Nathan Binkert -from __future__ import print_function - import os, subprocess Import('main') diff --git a/ext/systemc/SConscript b/ext/systemc/SConscript index cb0c61db4..0b6fb0cd1 100644 --- a/ext/systemc/SConscript +++ b/ext/systemc/SConscript @@ -23,8 +23,6 @@ # Authors: Christian Menard # Matthias Jung -from __future__ import print_function - import os from m5.util.terminal import get_termcap diff --git a/ext/systemc/src/sysc/kernel/SConscript.sc b/ext/systemc/src/sysc/kernel/SConscript.sc index ac79c2fb5..0e21f7461 100644 --- a/ext/systemc/src/sysc/kernel/SConscript.sc +++ b/ext/systemc/src/sysc/kernel/SConscript.sc @@ -23,8 +23,6 @@ # Authors: Christian Menard # Matthias Jung -from __future__ import print_function - Import('systemc', 'SystemCSource') SystemCSource( diff --git a/site_scons/gem5_scons/__init__.py b/site_scons/gem5_scons/__init__.py index 4208cf1a5..708002fe1 100644 --- a/site_scons/gem5_scons/__init__.py +++ b/site_scons/gem5_scons/__init__.py @@ -38,8 +38,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import os import sys import textwrap diff --git a/site_scons/site_tools/git.py b/site_scons/site_tools/git.py index 87738b8f0..a77cffb08 100644 --- a/site_scons/site_tools/git.py +++ b/site_scons/site_tools/git.py @@ -38,13 +38,11 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function import os import sys import gem5_scons.util from m5.util import readCommand -from six.moves import input git_style_message = """ You're missing the gem5 style or commit message hook. These hooks help diff --git a/src/SConscript b/src/SConscript index b55f48532..dc5726080 100644 --- a/src/SConscript +++ b/src/SConscript @@ -37,8 +37,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import array import bisect import distutils.spawn @@ -46,7 +44,6 @@ import functools import imp import os import re -import six import sys import zlib @@ -144,8 +141,7 @@ class SourceMeta(type): super(SourceMeta, cls).__init__(name, bases, dict) cls.all = SourceList() -@six.add_metaclass(SourceMeta) -class SourceFile(object): +class SourceFile(object, metaclass=SourceMeta): '''Base object that encapsulates the notion of a source file. This includes, the source node, target node, various manipulations of those. A source file also specifies a set of tags which @@ -157,14 +153,14 @@ class SourceFile(object): def __init__(self, source, tags=None, add_tags=None, append=None): if tags is None: tags='gem5 lib' - if isinstance(tags, six.string_types): + if isinstance(tags, str): tags = set([tags]) if not isinstance(tags, set): tags = set(tags) self.tags = tags if add_tags: - if isinstance(add_tags, six.string_types): + if isinstance(add_tags, str): add_tags = set([add_tags]) if not isinstance(add_tags, set): add_tags = set(add_tags) @@ -266,7 +262,7 @@ def blobToCpp(data, symbol, cpp_code, hpp_code=None, namespace=None): cpp_code(symbol_declaration + ' = {') cpp_code.indent() step = 16 - for i in six.moves.range(0, len(data), step): + for i in range(0, len(data), step): x = array.array('B', data[i:i+step]) cpp_code(''.join('%d,' % d for d in x)) cpp_code.dedent() @@ -487,8 +483,7 @@ class ExecutableMeta(type): cls.all = [] -@six.add_metaclass(ExecutableMeta) -class Executable(object): +class Executable(object, metaclass=ExecutableMeta): '''Base class for creating an executable from sources.''' abstract = True diff --git a/src/mem/ruby/SConscript b/src/mem/ruby/SConscript index b31416d64..aab03554d 100644 --- a/src/mem/ruby/SConscript +++ b/src/mem/ruby/SConscript @@ -26,8 +26,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - import os import sys diff --git a/src/systemc/tests/SConscript b/src/systemc/tests/SConscript index cf5051432..de330cbee 100644 --- a/src/systemc/tests/SConscript +++ b/src/systemc/tests/SConscript @@ -23,8 +23,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import print_function - Import('*') if env['USE_SYSTEMC'] and GetOption('with_systemc_tests'):