From 6c249dec5bbb2bc9625386c627ef3042b241e326 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 30 Sep 2023 15:36:41 +0000 Subject: [PATCH] load dev tools only when `MMGEN_DEVTOOLS` env var is set --- mmgen/cfg.py | 2 ++ mmgen/data/version | 2 +- scripts/exec_wrapper.py | 5 +++-- test/include/test_init.py | 4 ++++ test/objtest.py | 7 +++++-- test/test.py | 3 --- test/unit_tests.py | 7 +++++-- test/unit_tests_d/ut_devtools.py | 1 - 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 616b6f18..3142cf69 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -156,6 +156,7 @@ class Config(Lockable): debug_addrlist = False debug_subseed = False debug_tw = False + devtools = False # rpc: rpc_host = '' @@ -303,6 +304,7 @@ class Config(Lockable): 'MMGEN_DEBUG_TW', 'MMGEN_DEBUG_UTF8', 'MMGEN_DEBUG_SUBSEED', + 'MMGEN_DEVTOOLS', 'MMGEN_FORCE_256_COLOR', 'MMGEN_HOLD_PROTECT_DISABLE', 'MMGEN_QUIET', diff --git a/mmgen/data/version b/mmgen/data/version index 9999b6af..d8969871 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -14.0.dev4 +14.0.dev5 diff --git a/scripts/exec_wrapper.py b/scripts/exec_wrapper.py index 531c2113..dccd67fd 100755 --- a/scripts/exec_wrapper.py +++ b/scripts/exec_wrapper.py @@ -121,8 +121,9 @@ if exec_wrapper_os.getenv('MMGEN_TRACEMALLOC'): exec_wrapper_tracemalloc_setup() # import mmgen mods only after sys.path[0] is set to overlay root! -from mmgen.devinit import init_dev as exec_wrapper_init_dev -exec_wrapper_init_dev() +if exec_wrapper_os.getenv('MMGEN_DEVTOOLS'): + from mmgen.devinit import init_dev as exec_wrapper_init_dev + exec_wrapper_init_dev() exec_wrapper_tstart = exec_wrapper_time.time() diff --git a/test/include/test_init.py b/test/include/test_init.py index 2f421a94..6ef20c14 100755 --- a/test/include/test_init.py +++ b/test/include/test_init.py @@ -24,3 +24,7 @@ os.environ['PYTHONPATH'] = overlay_root if 'TMUX' in os.environ: del os.environ['TMUX'] + +if os.getenv('MMGEN_DEVTOOLS'): + from mmgen.devinit import init_dev + init_dev() diff --git a/test/objtest.py b/test/objtest.py index 1befe2f0..219a863e 100755 --- a/test/objtest.py +++ b/test/objtest.py @@ -24,8 +24,11 @@ import sys,os,re import include.test_init -from mmgen.devinit import init_dev -init_dev() +# for objtest, violate MMGen Project best practices and allow use of the dev tools +# in production code: +if not os.getenv('MMGEN_DEVTOOLS'): + from mmgen.devinit import init_dev + init_dev() # Import these _after_ local path's been added to sys.path from mmgen.common import * diff --git a/test/test.py b/test/test.py index f779c43a..73bc76e3 100755 --- a/test/test.py +++ b/test/test.py @@ -94,9 +94,6 @@ else: from mmgen.common import * -from mmgen.devinit import init_dev -init_dev() - from test.include.common import set_globals,test_py_log_fn,test_py_error_fn try: diff --git a/test/unit_tests.py b/test/unit_tests.py index 8930fd58..e55e1771 100755 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -24,8 +24,11 @@ import sys,os,time,importlib,platform import include.test_init -from mmgen.devinit import init_dev -init_dev() +# for the unit tests, violate MMGen Project best practices and allow use of the dev tools +# in production code: +if not os.getenv('MMGEN_DEVTOOLS'): + from mmgen.devinit import init_dev + init_dev() from mmgen.common import * from test.include.common import set_globals,end_msg diff --git a/test/unit_tests_d/ut_devtools.py b/test/unit_tests_d/ut_devtools.py index 34410d8c..4a6f4217 100755 --- a/test/unit_tests_d/ut_devtools.py +++ b/test/unit_tests_d/ut_devtools.py @@ -5,7 +5,6 @@ test.unit_tests_d.ut_devtools: devtools unit tests for the MMGen suite """ import os,json -from mmgen.devtools import * from mmgen.util import msg from . import unit_tests_base