From eac80966c503b0bc940c119d9a0adafb9ccf50d4 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 24 Nov 2017 12:54:45 +0100 Subject: [PATCH 1/4] Fix scripts-root within `fail2ban.service` (relative install root-base directory). This is amend for e3b061e94b54067525c5e7f2ac716d1c838c9f20. Closes gh-1964 --- setup.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 11748778..5dbd5b1a 100755 --- a/setup.py +++ b/setup.py @@ -88,7 +88,13 @@ class install_scripts_f2b(install_scripts): def update_scripts(self, dry_run=False): buildroot = os.path.dirname(self.build_dir) - print('Creating %s/fail2ban.service (from fail2ban.service.in): @BINDIR@ -> %s' % (buildroot, self.install_dir)) + try: + root = self.distribution.command_options['install']['root'][1] + if self.install_dir.startswith(root): + install_dir = self.install_dir[len(root):] + except: # pragma: no cover + print('WARNING: Cannot find root-base option, check the bin-path to fail2ban-scripts in "fail2ban.service".') + print('Creating %s/fail2ban.service (from fail2ban.service.in): @BINDIR@ -> %s' % (buildroot, install_dir)) with open(os.path.join(source_dir, 'files/fail2ban.service.in'), 'r') as fn: lines = fn.readlines() fn = None @@ -96,7 +102,7 @@ class install_scripts_f2b(install_scripts): fn = open(os.path.join(buildroot, 'fail2ban.service'), 'w') try: for ln in lines: - ln = re.sub(r'@BINDIR@', lambda v: self.install_dir, ln) + ln = re.sub(r'@BINDIR@', lambda v: install_dir, ln) if dry_run: sys.stdout.write(' | ' + ln) continue From fa007bfa7cdc27c91727336f8ff64036f71ba379 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 24 Nov 2017 12:57:55 +0100 Subject: [PATCH 2/4] remove build folder, if created through setup-process in test --- fail2ban/tests/misctestcase.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fail2ban/tests/misctestcase.py b/fail2ban/tests/misctestcase.py index 373a7178..fda1a5cd 100644 --- a/fail2ban/tests/misctestcase.py +++ b/fail2ban/tests/misctestcase.py @@ -121,6 +121,7 @@ class SetupTest(unittest.TestCase): if not self.setup: return # if verbose skip didn't work out tmp = tempfile.mkdtemp() + remove_build = not os.path.exists('build') # suppress stdout (and stderr) if not heavydebug supdbgout = ' >/dev/null' if unittest.F2B.log_level >= logging.DEBUG else '' # HEAVYDEBUG try: @@ -178,6 +179,8 @@ class SetupTest(unittest.TestCase): # remove build directory os.system("%s %s clean --all%s" % (sys.executable, self.setup, (supdbgout + ' 2>&1') if supdbgout else '')) + if remove_build and os.path.exists('build'): + shutil.rmtree('build') class TestsUtilsTest(LogCaptureTestCase): From 7bf5980defad39c1928209c7636269f712858f44 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 24 Nov 2017 13:20:19 +0100 Subject: [PATCH 3/4] no root option if testing within virtualenv (fixed now). --- setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 5dbd5b1a..8da29268 100755 --- a/setup.py +++ b/setup.py @@ -88,10 +88,12 @@ class install_scripts_f2b(install_scripts): def update_scripts(self, dry_run=False): buildroot = os.path.dirname(self.build_dir) + install_dir = self.install_dir try: + # remove root-base from install scripts path: root = self.distribution.command_options['install']['root'][1] - if self.install_dir.startswith(root): - install_dir = self.install_dir[len(root):] + if install_dir.startswith(root): + install_dir = install_dir[len(root):] except: # pragma: no cover print('WARNING: Cannot find root-base option, check the bin-path to fail2ban-scripts in "fail2ban.service".') print('Creating %s/fail2ban.service (from fail2ban.service.in): @BINDIR@ -> %s' % (buildroot, install_dir)) From 100b531affe5bb3e6b3ee8f1aa59d3a1f5a74aeb Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 24 Nov 2017 13:33:20 +0100 Subject: [PATCH 4/4] travis: add build for python 3.7-dev and switch to newest pypy3.3 in travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d2b60ed1..0c611a95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,10 @@ python: - 3.4 - 3.5 - 3.6 + - 3.7-dev # disabled since setuptools dropped support for Python 3.0 - 3.2 # - pypy3 - - pypy3.3-5.2-alpha1 + - pypy3.3-5.5-alpha before_install: - echo "running under $TRAVIS_PYTHON_VERSION" - if [[ $TRAVIS_PYTHON_VERSION == 2* || $TRAVIS_PYTHON_VERSION == pypy* && $TRAVIS_PYTHON_VERSION != pypy3* ]]; then export F2B_PY_2=true && echo "Set F2B_PY_2"; fi