setup.py: adding option to install without tests

Tests files are not always needed especially when installing on low
resource systems like an embedded one.
This patch adds the --without-tests option to skip installing the
tests files.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
pull/2605/head
Angelo Compagnucci 5 years ago
parent 3965d690b1
commit 5fa1f69264

@ -119,9 +119,11 @@ class install_scripts_f2b(install_scripts):
class install_command_f2b(install): class install_command_f2b(install):
user_options = install.user_options + [ user_options = install.user_options + [
('disable-2to3', None, 'Specify to deactivate 2to3, e.g. if the install runs from fail2ban test-cases.'), ('disable-2to3', None, 'Specify to deactivate 2to3, e.g. if the install runs from fail2ban test-cases.'),
('without-tests', None, 'without tests files installation'),
] ]
def initialize_options(self): def initialize_options(self):
self.disable_2to3 = None self.disable_2to3 = None
self.without_tests = None
install.initialize_options(self) install.initialize_options(self)
def finalize_options(self): def finalize_options(self):
global _2to3 global _2to3
@ -132,6 +134,13 @@ class install_command_f2b(install):
cmdclass = self.distribution.cmdclass cmdclass = self.distribution.cmdclass
cmdclass['build_py'] = build_py_2to3 cmdclass['build_py'] = build_py_2to3
cmdclass['build_scripts'] = build_scripts_2to3 cmdclass['build_scripts'] = build_scripts_2to3
if self.without_tests:
self.distribution.scripts.remove('bin/fail2ban-testcases')
self.distribution.packages.remove('fail2ban.tests')
self.distribution.packages.remove('fail2ban.tests.action_d')
del self.distribution.package_data['fail2ban.tests']
install.finalize_options(self) install.finalize_options(self)
def run(self): def run(self):
install.run(self) install.run(self)
@ -208,7 +217,7 @@ setup(
license = "GPL", license = "GPL",
platforms = "Posix", platforms = "Posix",
cmdclass = { cmdclass = {
'build_py': build_py, 'build_scripts': build_scripts, 'build_py': build_py, 'build_scripts': build_scripts,
'install_scripts': install_scripts_f2b, 'install': install_command_f2b 'install_scripts': install_scripts_f2b, 'install': install_command_f2b
}, },
scripts = [ scripts = [

Loading…
Cancel
Save