[gem5-dev] Change in gem5/gem5[develop]: python: Remove the m5.config and options.py mechanism.

2022-02-04 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/56387 )


Change subject: python: Remove the m5.config and options.py mechanism.
..

python: Remove the m5.config and options.py mechanism.

It appears that there is a mechanism where you could either have a .m5
directory in your home directory, or set an M5_CONFIG environment
variable to some other directory, where you could put an options.py
file. That file would then be passed the options dict which gem5's main
had extracted from its args, which it could modify as it liked.

First, I suspect that this mechanism was basically unknown and was just
a dark corner of gem5 people had forgotten about. Getting rid of it
will help clear out old cruft.

Second, this sort of file reaching in and fiddling with gem5's internal
data structures is dangerous and fragile, and could in almost any case
be replaced with a wrapper script or shell alias.

Change-Id: Ic828716979ea6379f60de796d23281ab075b38ec
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56387
Reviewed-by: Gabe Black 
Maintainer: Gabe Black 
Tested-by: kokoro 
---
M src/python/SConscript
D src/python/m5/config.py
M src/python/m5/main.py
3 files changed, 27 insertions(+), 57 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/SConscript b/src/python/SConscript
index 984ae82..343a696 100644
--- a/src/python/SConscript
+++ b/src/python/SConscript
@@ -217,7 +217,6 @@
 PySource('', 'importer.py')
 PySource('m5', 'm5/__init__.py')
 PySource('m5', 'm5/SimObject.py')
-PySource('m5', 'm5/config.py')
 PySource('m5', 'm5/core.py')
 PySource('m5', 'm5/debug.py')
 PySource('m5', 'm5/event.py')
diff --git a/src/python/m5/config.py b/src/python/m5/config.py
deleted file mode 100644
index 926ea14..000
--- a/src/python/m5/config.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright (c) 2008 The Hewlett-Packard Development Company
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met: redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer;
-# redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution;
-# neither the name of the copyright holders nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import os
-from os.path import isdir, isfile, join as joinpath
-
-
-confdir = os.environ.get('M5_CONFIG')
-
-if not confdir:
-# HOME is not set when running regressions, due to use of scons
-# Execute() function.
-homedir = os.environ.get('HOME')
-if homedir and isdir(joinpath(homedir, '.m5')):
-confdir = joinpath(homedir, '.m5')
-
-def get(name):
-if not confdir:
-return None
-conffile = joinpath(confdir, name)
-if not isfile(conffile):
-return None
-
-return conffile
-
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index f649e77..701d9f6 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -61,7 +61,6 @@


 def parse_options():
-from . import config
 from .options import OptionParser

 options = OptionParser(usage=usage, description=brief_copyright)
@@ -155,13 +154,6 @@
 option("--list-sim-objects", action='store_true', default=False,
 help="List all built-in SimObjects, their params and default  
values")


-# load the options.py config file to allow people to set their own
-# default options
-options_file = config.get('options.py')
-if options_file:
-scope = { 'options' : options }
-exec(compile(open(options_file).read(), options_file, 'exec'),  
scope)

-
 arguments = options.parse_args()
 return options,arguments


--
To view, visit 

[gem5-dev] Change in gem5/gem5[develop]: python: Remove the m5.config and options.py mechanism.

2022-02-03 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/56387 )



Change subject: python: Remove the m5.config and options.py mechanism.
..

python: Remove the m5.config and options.py mechanism.

It appears that there is a mechanism where you could either have a .m5
directory in your home directory, or set an M5_CONFIG environment
variable to some other directory, where you could put an options.py
file. That file would then be passed the options dict which gem5's main
had extracted from its args, which it could modify as it liked.

First, I suspect that this mechanism was basically unknown and was just
a dark corner of gem5 people had forgotten about. Getting rid of it
will help clear out old cruft.

Second, this sort of file reaching in and fiddling with gem5's internal
data structures is dangerous and fragile, and could in almost any case
be replaced with a wrapper script or shell alias.

Change-Id: Ic828716979ea6379f60de796d23281ab075b38ec
---
D src/python/m5/config.py
M src/python/m5/main.py
2 files changed, 23 insertions(+), 56 deletions(-)



diff --git a/src/python/m5/config.py b/src/python/m5/config.py
deleted file mode 100644
index 926ea14..000
--- a/src/python/m5/config.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright (c) 2008 The Hewlett-Packard Development Company
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met: redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer;
-# redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution;
-# neither the name of the copyright holders nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import os
-from os.path import isdir, isfile, join as joinpath
-
-
-confdir = os.environ.get('M5_CONFIG')
-
-if not confdir:
-# HOME is not set when running regressions, due to use of scons
-# Execute() function.
-homedir = os.environ.get('HOME')
-if homedir and isdir(joinpath(homedir, '.m5')):
-confdir = joinpath(homedir, '.m5')
-
-def get(name):
-if not confdir:
-return None
-conffile = joinpath(confdir, name)
-if not isfile(conffile):
-return None
-
-return conffile
-
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index f649e77..701d9f6 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -61,7 +61,6 @@


 def parse_options():
-from . import config
 from .options import OptionParser

 options = OptionParser(usage=usage, description=brief_copyright)
@@ -155,13 +154,6 @@
 option("--list-sim-objects", action='store_true', default=False,
 help="List all built-in SimObjects, their params and default  
values")


-# load the options.py config file to allow people to set their own
-# default options
-options_file = config.get('options.py')
-if options_file:
-scope = { 'options' : options }
-exec(compile(open(options_file).read(), options_file, 'exec'),  
scope)

-
 arguments = options.parse_args()
 return options,arguments


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56387
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ic828716979ea6379f60de796d23281ab075b38ec
Gerrit-Change-Number: 56387
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s