From d39f9a0a19333bb72bedabdd8673e1f153e063df Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Thu, 22 Jun 2017 22:51:03 -0400 Subject: [PATCH] Removal of "import magic" for avocado and avocado-rest-client These scripts rely on some Python library path manipulation to be able to load from the source tree. But, in fact that are a few reasons for not having those, including: * All functionality in `avocado` relies on plugins, which will not be available from the source tree unless a `$ setup.py develop` is executed, which automatically makes the "import magic" unnecessary. * Most users will end up using a setuptools generated "entry point" instead. For the sake of less code, I propose this (and all other?) magic to be removed. Signed-off-by: Cleber Rosa --- scripts/avocado | 8 -------- scripts/avocado-rest-client | 6 ------ selftests/functional/test_basic.py | 5 +++++ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/scripts/avocado b/scripts/avocado index f81893c1..7b04c53f 100755 --- a/scripts/avocado +++ b/scripts/avocado @@ -56,14 +56,6 @@ def handle_exception(*exc_info): sys.exit(-1) -# simple magic for using scripts within a source tree -basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -if os.path.isdir(os.path.join(basedir, 'avocado')): - os.environ['PATH'] += ":" + os.path.join(basedir, 'scripts') - os.environ['PATH'] += ":" + os.path.join(basedir, 'libexec') - sys.path.append(basedir) - - if __name__ == '__main__': sys.excepthook = handle_exception from avocado.core.app import AvocadoApp diff --git a/scripts/avocado-rest-client b/scripts/avocado-rest-client index dc02b21f..01addfb3 100755 --- a/scripts/avocado-rest-client +++ b/scripts/avocado-rest-client @@ -14,14 +14,8 @@ # Author: Cleber Rosa -import os import sys -# simple magic for using scripts within a source tree -basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -if os.path.isdir(os.path.join(basedir, 'avocado')): - sys.path.append(basedir) - from avocado.core.restclient.cli.app import App if __name__ == '__main__': diff --git a/selftests/functional/test_basic.py b/selftests/functional/test_basic.py index 0963ec96..5eef658c 100644 --- a/selftests/functional/test_basic.py +++ b/selftests/functional/test_basic.py @@ -763,6 +763,11 @@ class RunnerSimpleTest(unittest.TestCase): simplewarning.sh uses the avocado-bash-utils """ os.chdir(basedir) + # simplewarning.sh calls "avocado" without specifying a path + os.environ['PATH'] += ":" + os.path.join(basedir, 'scripts') + # simplewarning.sh calls "avocado exec-path" which hasn't + # access to an installed location for the libexec scripts + os.environ['PATH'] += ":" + os.path.join(basedir, 'libexec') cmd_line = ('%s run --job-results-dir %s --sysinfo=off ' 'examples/tests/simplewarning.sh --show-job-log' % (AVOCADO, self.tmpdir)) -- GitLab