setup.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from __future__ import print_function
  2. import os
  3. import re
  4. import sys
  5. import shutil
  6. from distutils.core import setup
  7. from distutils.command.build_py import build_py
  8. # Get the Suricata version from configure.ac.
  9. version = None
  10. if os.path.exists("../configure.ac"):
  11. with open("../configure.ac", "r") as conf:
  12. for line in conf:
  13. if line.find("AC_INIT") > 1:
  14. m = re.search("AC_INIT\(\[suricata\],\[(\d.+)\]\)", line)
  15. if m:
  16. version = m.group(1)
  17. break
  18. else:
  19. print("error: failed to parse Suricata version from: %s" % (
  20. line.strip()), file=sys.stderr)
  21. sys.exit(1)
  22. if version is None:
  23. print("error: failed to find Suricata version", file=sys.stderr)
  24. sys.exit(1)
  25. class do_build(build_py):
  26. def run(self):
  27. build_py.run(self)
  28. defaults_py_out = os.path.join(
  29. self.build_lib, "suricata", "config", "defaults.py")
  30. if not os.path.exists(defaults_py_out):
  31. # Must be an out of tree build, find defaults.py.
  32. defaults_py_in = os.path.join(
  33. self.build_lib, "..", "suricata", "config", "defaults.py")
  34. if os.path.exists(defaults_py_in):
  35. shutil.copy(defaults_py_in, defaults_py_out)
  36. else:
  37. print("error: failed to find defaults.py")
  38. sys.exit(1)
  39. setup(
  40. name="suricata",
  41. description="Suricata control tools",
  42. version=version,
  43. author='OISF Developers, Eric Leblond',
  44. author_email='oisf-devel@lists.openinfosecfoundation.org, eric@regit.org',
  45. url='https://www.suricata.io/',
  46. packages=[
  47. "suricata",
  48. "suricata.config",
  49. "suricata.ctl",
  50. "suricata.sc",
  51. "suricatasc",
  52. ],
  53. scripts=[
  54. "bin/suricatactl",
  55. "bin/suricatasc",
  56. ],
  57. provides=['suricatactl', 'suricatasc'],
  58. requires=['argparse','simplejson'],
  59. classifiers=[
  60. 'Development Status :: 5 - Production/Stable',
  61. 'Environment :: Console',
  62. 'Intended Audience :: System Administrators',
  63. 'License :: OSI Approved :: GNU General Public License (GPL)',
  64. 'Operating System :: POSIX',
  65. 'Programming Language :: Python',
  66. 'Topic :: System :: Systems Administration',
  67. ],
  68. cmdclass={'build_py': do_build},
  69. )