summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorsebres <serg.brester@sebres.de>2016-08-11 18:34:18 +0200
committersebres <serg.brester@sebres.de>2016-08-11 18:34:18 +0200
commit77f451c4a38f60fabfa58e8b0a17d399bf7c7f05 (patch)
treec089a5b90fc42fb5493995b0a852f3a5543311a0 /setup.py
parentad19c8401b7d3de247caafb4457de8c53f4651c0 (diff)
downloadfail2ban-77f451c4a38f60fabfa58e8b0a17d399bf7c7f05.tar.gz
introduces new command "fail2ban-python", as automatically created symlink to python executable, where fail2ban currently installed (resp. its modules are located);
fixed pythonic filters and test scripts (running via "fail2ban-python" now); fixed test case "testSetupInstallRoot" not for default python (also using direct call, out of virtualenv);
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index 5579c981..fa66d4d6 100755
--- a/setup.py
+++ b/setup.py
@@ -38,12 +38,46 @@ except ImportError:
# python 2.x
from distutils.command.build_py import build_py
from distutils.command.build_scripts import build_scripts
+# all versions
+from distutils.command.install_scripts import install_scripts
+
import os
from os.path import isfile, join, isdir, realpath
import sys
import warnings
from glob import glob
+
+def updatePyExec(bindir, executable=None):
+ """Update fail2ban-python link to current python version (where f2b-modules located/installed)
+ """
+ bindir = os.path.realpath(bindir)
+ if executable is None:
+ executable = sys.executable
+ pypath = os.path.join(bindir, 'fail2ban-python')
+ # if not exists or point to another version - update link:
+ isfile = os.path.isfile(pypath)
+ if not isfile or os.path.realpath(pypath) != os.path.realpath(executable):
+ if isfile:
+ os.unlink(pypath)
+ os.symlink(executable, pypath)
+
+
+# Wrapper to install python binding (to current python version):
+class install_scripts_f2b(install_scripts):
+
+ def get_outputs(self):
+ outputs = install_scripts.get_outputs(self)
+ fn = None
+ for fn in outputs:
+ if os.path.basename(fn) == 'fail2ban-server':
+ break
+ bindir = os.path.dirname(fn)
+ print('creating fail2ban-python binding -> %s' % (bindir,))
+ updatePyExec(bindir)
+ return outputs
+
+
if setuptools and "test" in sys.argv:
import logging
logSys = logging.getLogger("fail2ban")
@@ -99,12 +133,16 @@ setup(
url = "http://www.fail2ban.org",
license = "GPL",
platforms = "Posix",
- cmdclass = {'build_py': build_py, 'build_scripts': build_scripts},
+ cmdclass = {
+ 'build_py': build_py, 'build_scripts': build_scripts,
+ 'install_scripts': install_scripts_f2b
+ },
scripts = [
'bin/fail2ban-client',
'bin/fail2ban-server',
'bin/fail2ban-regex',
'bin/fail2ban-testcases',
+ # 'bin/fail2ban-python', -- link (binary), will be installed via install_scripts_f2b wrapper
],
packages = [
'fail2ban',